Skip to content

Commit 0ff04a2

Browse files
committed
Pass RHS state to the pop-out
1 parent 69b9162 commit 0ff04a2

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

webapp/src/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {isSystemMessage} from 'mattermost-redux/utils/post_utils';
77
import AttachCommentToIssuePostMenuAction from '@/components/post_menu_actions/attach_comment_to_issue';
88
import AttachCommentToIssueModal from '@/components/modals/attach_comment_to_issue';
99

10-
import {getConnected, openAttachCommentToIssueModal, openCreateIssueModal, setShowRHSAction} from '@/actions';
10+
import {getConnected, openAttachCommentToIssueModal, openCreateIssueModal, setShowRHSAction, getSidebarContent, updateRhsState} from '@/actions';
1111

1212
import CreateIssueModal from './components/modals/create_issue';
1313
import CreateIssuePostMenuAction from './components/post_menu_action/create_issue';
@@ -71,6 +71,23 @@ class PluginClass {
7171
const {showRHSPlugin} = registry.registerRightHandSidebarComponent(SidebarRight, 'GitHub');
7272
store.dispatch(setShowRHSAction(() => store.dispatch(showRHSPlugin)));
7373

74+
registry.registerRHSPluginPopoutListener(pluginId, (teamName, channelName, listeners) => {
75+
listeners.onMessageFromPopout((channel) => {
76+
if (channel === 'GET_RHS_STATE') {
77+
listeners.sendToPopout('SEND_RHS_STATE', store.getState()[`plugins-${manifest.id}`].rhsState);
78+
}
79+
});
80+
});
81+
if (window.WebappUtils.popouts.isPopoutWindow()) {
82+
store.dispatch(getSidebarContent());
83+
window.WebappUtils.popouts.onMessageFromParent((channel, state) => {
84+
if (channel === 'SEND_RHS_STATE') {
85+
store.dispatch(updateRhsState(state));
86+
}
87+
});
88+
window.WebappUtils.popouts.sendToParent('GET_RHS_STATE');
89+
}
90+
7491
registry.registerWebSocketEventHandler(`custom_${pluginId}_connect`, handleConnect(store));
7592
registry.registerWebSocketEventHandler(`custom_${pluginId}_disconnect`, handleDisconnect(store));
7693
registry.registerWebSocketEventHandler(`custom_${pluginId}_config_update`, handleConfigurationUpdate(store));

0 commit comments

Comments
 (0)