-
Notifications
You must be signed in to change notification settings - Fork 42
/
store.ts
54 lines (53 loc) · 1.69 KB
/
store.ts
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { action, computed, observable } from 'mobx';
import storage from 'store';
import { createActionBindings } from '../../lib/ActionBinding';
import { Store } from '../../lib/Store';
import { StakePoolsApi } from './api';
import {
UNMODERATED_WARNING_PERIOD,
UNMODERATED_WARNING_STORAGE_KEY,
} from './constants';
import { StakePoolsActions } from './index';
import DUMMY_DATA from './stakingStakePools.dummy.json';
export class StakePoolsStore extends Store {
private readonly stakePoolsApi: StakePoolsApi;
@observable private showUnmoderatedDataStorage: number | null;
constructor(
stakePoolsActions: StakePoolsActions,
stakePoolsApi: StakePoolsApi
) {
super();
this.stakePoolsApi = stakePoolsApi;
this.showUnmoderatedDataStorage = storage.get(
UNMODERATED_WARNING_STORAGE_KEY
);
this.registerActions(
createActionBindings([
[
stakePoolsActions.handleAcceptUnmoderatedData,
this.handleAcceptUnmoderatedData,
],
])
);
// this.stakePoolsApi.getStakePoolsQuery.execute({
// limit: 10,
// offset: 0,
// });
}
@computed get showUnmoderatedData() {
const { showUnmoderatedDataStorage } = this;
if (!showUnmoderatedDataStorage) {
return false;
}
const now: number = new Date().getTime();
return showUnmoderatedDataStorage - now <= UNMODERATED_WARNING_PERIOD;
}
@computed get stakePoolsList() {
return DUMMY_DATA; // this.stakePoolsApi.getStakePoolsQuery.result;
}
@action private handleAcceptUnmoderatedData = () => {
const now: number = new Date().getTime();
this.showUnmoderatedDataStorage = now;
storage.set(UNMODERATED_WARNING_STORAGE_KEY, now);
};
}