mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 04:25:31 +08:00
b3bf4ad65d
Summary: - Adds a couple of helper methods to theme manager and updates how a theme package is enabled to be consistent with how we actually want to activate themes. - Adds small select component to choose a theme or install a new one. Test Plan: - Manual Reviewers: evan, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2355
32 lines
716 B
CoffeeScript
32 lines
716 B
CoffeeScript
Q = require 'q'
|
|
Package = require './package'
|
|
|
|
module.exports =
|
|
class ThemePackage extends Package
|
|
getType: -> 'theme'
|
|
|
|
getStyleSheetPriority: -> 1
|
|
|
|
enable: ->
|
|
NylasEnv.themes.setActiveTheme(@name)
|
|
|
|
disable: ->
|
|
NylasEnv.config.removeAtKeyPath('core.themes', @name)
|
|
|
|
load: ->
|
|
@measure 'loadTime', =>
|
|
try
|
|
@metadata ?= Package.loadMetadata(@path)
|
|
catch error
|
|
console.warn "Failed to load theme named '#{@name}'", error.stack ? error
|
|
this
|
|
|
|
activate: ->
|
|
return @activationDeferred.promise if @activationDeferred?
|
|
|
|
@activationDeferred = Q.defer()
|
|
@measure 'activateTime', =>
|
|
@loadStylesheets()
|
|
@activateNow()
|
|
|
|
@activationDeferred.promise
|