Keep Navigation plugin alive even when disabled

Summary:
Navigation plugin is a special cause that will remain connected and process messages directly even when disabled, this is to make sure the bookmarks feature keeps working even when the plugin is not enabled.

Changelog: [Sandy][Navigation] on Android, the currently active deeplink of the application will now be shown in the sidebar

Reviewed By: jknoxville

Differential Revision: D24890375

fbshipit-source-id: eb5e4141740e0436396cea5a7aae24337f2e903e
This commit is contained in:
Michel Weststrate
2020-11-12 04:13:16 -08:00
committed by Facebook GitHub Bot
parent 273b895e30
commit b66f452271
4 changed files with 122 additions and 4 deletions

View File

@@ -295,7 +295,7 @@ export default class Client extends EventEmitter {
// start a plugin on start if it is a SandyPlugin, which is starred, and doesn't have persisted state yet
if (
isSandyPlugin(plugin) &&
isEnabled &&
(isEnabled || defaultEnabledBackgroundPlugins.includes(plugin.id)) &&
!this.sandyPluginStates.has(plugin.id)
) {
// TODO: needs to be wrapped in error tracking T68955280
@@ -306,7 +306,10 @@ export default class Client extends EventEmitter {
}
}
stopPluginIfNeeded(pluginId: string) {
stopPluginIfNeeded(pluginId: string, force = false) {
if (defaultEnabledBackgroundPlugins.includes(pluginId) && !force) {
return;
}
const pluginKey = getPluginKey(
this.id,
{serial: this.query.device_id},
@@ -322,7 +325,7 @@ export default class Client extends EventEmitter {
close() {
this.emit('close');
this.plugins.forEach((pluginId) => this.stopPluginIfNeeded(pluginId));
this.plugins.forEach((pluginId) => this.stopPluginIfNeeded(pluginId, true));
}
// gets a plugin by pluginId