From d4101a48b3eee8b1fb177831aa02a4b4fbec2588 Mon Sep 17 00:00:00 2001 From: Markus Hatvan Date: Sat, 18 Sep 2021 11:15:25 +0200 Subject: chore: convert various files from JS to TS (#1959) --- src/features/workspaces/index.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/features/workspaces/index.ts (limited to 'src/features/workspaces/index.ts') diff --git a/src/features/workspaces/index.ts b/src/features/workspaces/index.ts new file mode 100644 index 000000000..ecca64b41 --- /dev/null +++ b/src/features/workspaces/index.ts @@ -0,0 +1,28 @@ +import { reaction } from 'mobx'; +import WorkspacesStore from './store'; +import { resetApiRequests } from './api'; + +const debug = require('debug')('Ferdi:feature:workspaces'); + +export const workspaceStore = new WorkspacesStore(); + +export default function initWorkspaces(stores, actions) { + stores.workspaces = workspaceStore; + const { features } = stores; + + // Toggle workspace feature + reaction( + () => features.features.isWorkspaceEnabled, + isEnabled => { + if (isEnabled && !workspaceStore.isFeatureActive) { + debug('Initializing `workspaces` feature'); + workspaceStore.start(stores, actions); + } else if (workspaceStore.isFeatureActive) { + debug('Disabling `workspaces` feature'); + workspaceStore.stop(); + resetApiRequests(); + } + }, + { fireImmediately: true }, + ); +} -- cgit v1.2.3-70-g09d2