mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-13 11:38:31 +08:00
feat(plugin): activate & deactivate plugins via a nylas: url
This commit is contained in:
parent
dbc81a87a4
commit
9ec3daff0a
2 changed files with 12 additions and 1 deletions
|
@ -707,6 +707,8 @@ export default class Application extends EventEmitter {
|
|||
} else if (parts.protocol === 'nylas:') {
|
||||
if (parts.host === 'calendar') {
|
||||
this.openCalendarURL(parts.path);
|
||||
} else if (parts.host === 'plugins') {
|
||||
main.sendMessage('changePluginStateFromUrl', urlToOpen);
|
||||
} else {
|
||||
main.sendMessage('openExternalThread', urlToOpen);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
path = require 'path'
|
||||
url = require 'url'
|
||||
|
||||
_ = require 'underscore'
|
||||
{remote} = require 'electron'
|
||||
{ipcRenderer, remote} = require 'electron'
|
||||
EmitterMixin = require('emissary').Emitter
|
||||
{Emitter} = require 'event-kit'
|
||||
fs = require 'fs-plus'
|
||||
|
@ -58,6 +59,8 @@ class PackageManager
|
|||
@packageActivators = []
|
||||
@registerPackageActivator(this, ['nylas'])
|
||||
|
||||
ipcRenderer.on("changePluginStateFromUrl", @_onChangePluginState)
|
||||
|
||||
|
||||
pluginIdFor: (packageName) =>
|
||||
env = NylasEnv.config.get("env")
|
||||
|
@ -67,6 +70,12 @@ class PackageManager
|
|||
@cachedPackagePluginIds[cacheKey] = @_resolvePluginIdFor(packageName, env)
|
||||
return @cachedPackagePluginIds[cacheKey]
|
||||
|
||||
_onChangePluginState: (event, urlToOpen = "") =>
|
||||
{query} = url.parse(urlToOpen, true)
|
||||
for name, state of query
|
||||
if state is "off" then @deactivatePackage(name)
|
||||
else if state is "on" then @activatePackage(name)
|
||||
|
||||
_resolvePluginIdFor: (packageName, env) =>
|
||||
metadata = @loadedPackages[packageName]?.metadata
|
||||
|
||||
|
|
Loading…
Reference in a new issue