blob: 4b4e729edab7300cb4741175dec9ce96c9c7b03c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { observable, reaction } from 'mobx';
import Store from '../../stores/lib/Store';
import CachedRequest from '../../stores/lib/CachedRequest';
const debug = require('debug')('Franz:feature:workspaces');
export default class WorkspacesStore extends Store {
@observable allWorkspacesRequest = new CachedRequest(this.api, 'getUserWorkspaces');
constructor(stores, api, actions, state) {
super(stores, api, actions);
this.state = state;
}
setup() {
debug('fetching user workspaces');
this.allWorkspacesRequest.execute();
reaction(
() => this.allWorkspacesRequest.result,
workspaces => this.setWorkspaces(workspaces),
);
}
setWorkspaces = (workspaces) => {
debug('setting user workspaces', workspaces.slice());
this.state.workspaces = workspaces;
};
}
|