blob: 752f71371c93c2d449e3e00d83ed186bbc26e9fa (
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
30
31
32
33
34
35
36
37
38
39
40
41
|
import { computed, observable } from 'mobx';
import { FeatureStore } from '../utils/FeatureStore';
import { DEFAULT_SERVICE_LIMIT } from '.';
const debug = require('debug')('Franz:feature:serviceLimit:store');
export class ServiceLimitStore extends FeatureStore {
@observable isServiceLimitEnabled = false;
start(stores, actions) {
debug('start');
this.stores = stores;
this.actions = actions;
this.isServiceLimitEnabled = true;
}
stop() {
super.stop();
this.isServiceLimitEnabled = false;
}
@computed get userHasReachedServiceLimit() {
if (!this.isServiceLimitEnabled) return false;
const { user } = this.stores;
return !user.isPremium && this.serviceCount >= this.serviceLimit;
}
@computed get serviceLimit() {
return this.stores.features.features.serviceLimitCount || DEFAULT_SERVICE_LIMIT;
}
@computed get serviceCount() {
return this.stores.services.all.length;
}
}
export default ServiceLimitStore;
|