diff options
Diffstat (limited to 'webapp/stores')
-rw-r--r-- | webapp/stores/integration_store.jsx | 43 | ||||
-rw-r--r-- | webapp/stores/modal_store.jsx | 1 |
2 files changed, 43 insertions, 1 deletions
diff --git a/webapp/stores/integration_store.jsx b/webapp/stores/integration_store.jsx index 454e6290b..a23b9d206 100644 --- a/webapp/stores/integration_store.jsx +++ b/webapp/stores/integration_store.jsx @@ -20,6 +20,8 @@ class IntegrationStore extends EventEmitter { this.outgoingWebhooks = new Map(); this.commands = new Map(); + + this.oauthApps = new Map(); } addChangeListener(callback) { @@ -149,6 +151,35 @@ class IntegrationStore extends EventEmitter { this.setCommands(teamId, commands); } + hasReceivedOAuthApps(userId) { + return this.oauthApps.has(userId); + } + + getOAuthApps(userId) { + return this.oauthApps.get(userId) || []; + } + + setOAuthApps(userId, oauthApps) { + this.oauthApps.set(userId, oauthApps); + } + + addOAuthApp(oauthApp) { + const userId = oauthApp.creator_id; + const oauthApps = this.getOAuthApps(userId); + + oauthApps.push(oauthApp); + + this.setOAuthApps(userId, oauthApps); + } + + removeOAuthApp(userId, id) { + let apps = this.getOAuthApps(userId); + + apps = apps.filter((app) => app.id !== id); + + this.setOAuthApps(userId, apps); + } + handleEventPayload(payload) { const action = payload.action; @@ -197,6 +228,18 @@ class IntegrationStore extends EventEmitter { this.removeCommand(action.teamId, action.id); this.emitChange(); break; + case ActionTypes.RECEIVED_OAUTHAPPS: + this.setOAuthApps(action.userId, action.oauthApps); + this.emitChange(); + break; + case ActionTypes.RECEIVED_OAUTHAPP: + this.addOAuthApp(action.oauthApp); + this.emitChange(); + break; + case ActionTypes.REMOVED_OAUTHAPP: + this.removeOAuthApp(action.userId, action.id); + this.emitChange(); + break; } } } diff --git a/webapp/stores/modal_store.jsx b/webapp/stores/modal_store.jsx index 0209f3993..9961475b2 100644 --- a/webapp/stores/modal_store.jsx +++ b/webapp/stores/modal_store.jsx @@ -37,7 +37,6 @@ class ModalStoreClass extends EventEmitter { case ActionTypes.TOGGLE_DELETE_POST_MODAL: case ActionTypes.TOGGLE_GET_POST_LINK_MODAL: case ActionTypes.TOGGLE_GET_TEAM_INVITE_LINK_MODAL: - case ActionTypes.TOGGLE_REGISTER_APP_MODAL: case ActionTypes.TOGGLE_GET_PUBLIC_LINK_MODAL: this.emit(type, value, args); break; |