Show quick notification if plugin interaction fails

Summary:
Per title, if a plugin makes a client call, show a quick notif so that the user knows why his plugin interactions aren't responding in case the plugin doesn't use `isConnected` guards.

This might turn out to be too spammy, but I think it should be ok.

Reviewed By: nikoant

Differential Revision: D26277099

fbshipit-source-id: bd555ea84acae6189ec7f8fff0fc0a088dbc5337
This commit is contained in:
Michel Weststrate
2021-02-09 04:12:09 -08:00
committed by Facebook GitHub Bot
parent 60cfcb54a1
commit 54f9ff260b
2 changed files with 10 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ import {flipperMessagesClientPlugin} from './utils/self-inspection/plugins/Flipp
import {getFlipperLibImplementation} from './utils/flipperLibImplementation';
import {freeze} from 'immer';
import GK from './fb-stubs/GK';
import {message} from 'antd';
type Plugins = Array<string>;
@@ -601,8 +602,14 @@ export default class Client extends EventEmitter {
const mark = this.getPerformanceMark(metadata);
performance.mark(mark);
if (!this.connected) {
if (!this.connected.get()) {
message.warn({
content: 'Not connected',
key: 'appnotconnectedwarning',
duration: 0.5,
});
reject(new Error('Not connected to client'));
return;
}
if (!fromPlugin || this.isAcceptingMessagesFromPlugin(plugin)) {
this.connection!.requestResponse({
@@ -714,7 +721,7 @@ export default class Client extends EventEmitter {
deinitPlugin(pluginId: string) {
this.activePlugins.delete(pluginId);
this.sandyPluginStates.get(pluginId)?.disconnect();
if (this.connected) {
if (this.connected.get()) {
this.rawSend('deinit', {plugin: pluginId});
}
}

View File

@@ -82,7 +82,7 @@
.ant-notification-notice-message {
color: @background-default;
}
.ant-notification-notice {
.ant-notification-notice, .ant-message-notice-content {
background: @text-color-primary;
color: @background-default;
}