Support handling deeplinks in plugins
Summary:
This adds support for handling incoming deeplinks in a Sandy plugin, which can be done by using a `client.onDeepLink(deepLink => { } )` listener
Also generalized deeplinks to not just support strings, but also richer objects, which is beneficial to plugin to plugin linking.
Reviewed By: jknoxville
Differential Revision: D22524749
fbshipit-source-id: 2cbe8d52f6eac91a1c1c8c8494706952920b9181
This commit is contained in:
committed by
Facebook GitHub Bot
parent
485b4c9827
commit
f0c54667e0
@@ -101,7 +101,7 @@ type StateFromProps = {
|
||||
activePlugin: PluginDefinition | undefined;
|
||||
target: Client | BaseDevice | null;
|
||||
pluginKey: string | null;
|
||||
deepLinkPayload: string | null;
|
||||
deepLinkPayload: unknown;
|
||||
selectedApp: string | null;
|
||||
isArchivedDevice: boolean;
|
||||
pendingMessages: Message[] | undefined;
|
||||
@@ -113,7 +113,7 @@ type DispatchFromProps = {
|
||||
selectPlugin: (payload: {
|
||||
selectedPlugin: string | null;
|
||||
selectedApp?: string | null;
|
||||
deepLinkPayload: string | null;
|
||||
deepLinkPayload: unknown;
|
||||
}) => any;
|
||||
setPluginState: (payload: {pluginKey: string; state: any}) => void;
|
||||
setStaticView: (payload: StaticView) => void;
|
||||
@@ -178,6 +178,13 @@ class PluginContainer extends PureComponent<Props, State> {
|
||||
|
||||
componentDidUpdate() {
|
||||
this.processMessageQueue();
|
||||
// make sure deeplinks are propagated
|
||||
const {deepLinkPayload, target, activePlugin} = this.props;
|
||||
if (deepLinkPayload && target instanceof Client && activePlugin) {
|
||||
target.sandyPluginStates
|
||||
.get(activePlugin.id)
|
||||
?.triggerDeepLink(deepLinkPayload);
|
||||
}
|
||||
}
|
||||
|
||||
processMessageQueue() {
|
||||
@@ -373,7 +380,7 @@ class PluginContainer extends PureComponent<Props, State> {
|
||||
setPersistedState: (state) => setPluginState({pluginKey, state}),
|
||||
target,
|
||||
deepLinkPayload: this.props.deepLinkPayload,
|
||||
selectPlugin: (pluginID: string, deepLinkPayload: string | null) => {
|
||||
selectPlugin: (pluginID: string, deepLinkPayload: unknown) => {
|
||||
const {target} = this.props;
|
||||
// check if plugin will be available
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user