|
1
|
|
|
|
|
2
|
|
|
import ko from 'ko'; |
|
3
|
|
|
import {Focused, KeyState} from 'Common/Enums'; |
|
4
|
|
|
|
|
5
|
|
|
import {keyScope, leftPanelDisabled} from 'Common/Globals'; |
|
6
|
|
|
import {isNonEmptyArray} from 'Common/Utils'; |
|
7
|
|
|
|
|
8
|
|
|
import * as Settings from 'Storage/Settings'; |
|
9
|
|
|
|
|
10
|
|
|
import {AbstractAppStore} from 'Stores/AbstractApp'; |
|
11
|
|
|
|
|
12
|
|
|
class AppUserStore extends AbstractAppStore |
|
13
|
|
|
{ |
|
14
|
|
|
constructor() { |
|
15
|
|
|
super(); |
|
16
|
|
|
|
|
17
|
|
|
this.currentAudio = ko.observable(''); |
|
18
|
|
|
|
|
19
|
|
|
this.focusedState = ko.observable(Focused.None); |
|
20
|
|
|
|
|
21
|
|
|
const isMobile = Settings.appSettingsGet('mobile'); |
|
22
|
|
|
|
|
23
|
|
|
this.focusedState.subscribe((value) => { |
|
24
|
|
|
switch (value) |
|
25
|
|
|
{ |
|
26
|
|
|
case Focused.MessageList: |
|
27
|
|
|
keyScope(KeyState.MessageList); |
|
28
|
|
|
if (isMobile) { |
|
29
|
|
|
leftPanelDisabled(true); |
|
30
|
|
|
} |
|
31
|
|
|
break; |
|
32
|
|
|
case Focused.MessageView: |
|
33
|
|
|
keyScope(KeyState.MessageView); |
|
34
|
|
|
if (isMobile) { |
|
35
|
|
|
leftPanelDisabled(true); |
|
36
|
|
|
} |
|
37
|
|
|
break; |
|
38
|
|
|
case Focused.FolderList: |
|
39
|
|
|
keyScope(KeyState.FolderList); |
|
40
|
|
|
if (isMobile) { |
|
41
|
|
|
leftPanelDisabled(false); |
|
42
|
|
|
} |
|
43
|
|
|
break; |
|
44
|
|
|
default: |
|
45
|
|
|
break; |
|
46
|
|
|
} |
|
47
|
|
|
}); |
|
48
|
|
|
|
|
49
|
|
|
this.projectHash = ko.observable(''); |
|
50
|
|
|
this.threadsAllowed = ko.observable(false); |
|
51
|
|
|
|
|
52
|
|
|
this.composeInEdit = ko.observable(false); |
|
53
|
|
|
|
|
54
|
|
|
this.contactsAutosave = ko.observable(false); |
|
55
|
|
|
this.useLocalProxyForExternalImages = ko.observable(false); |
|
56
|
|
|
|
|
57
|
|
|
this.contactsIsAllowed = ko.observable(false); |
|
58
|
|
|
|
|
59
|
|
|
this.attachmentsActions = ko.observableArray([]); |
|
60
|
|
|
|
|
61
|
|
|
this.devEmail = ''; |
|
62
|
|
|
this.devPassword = ''; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
populate() { |
|
66
|
|
|
|
|
67
|
|
|
super.populate(); |
|
68
|
|
|
|
|
69
|
|
|
this.projectHash(Settings.settingsGet('ProjectHash')); |
|
70
|
|
|
|
|
71
|
|
|
this.contactsAutosave(!!Settings.settingsGet('ContactsAutosave')); |
|
72
|
|
|
this.useLocalProxyForExternalImages(!!Settings.settingsGet('UseLocalProxyForExternalImages')); |
|
73
|
|
|
|
|
74
|
|
|
this.contactsIsAllowed(!!Settings.settingsGet('ContactsIsAllowed')); |
|
75
|
|
|
|
|
76
|
|
|
const attachmentsActions = Settings.appSettingsGet('attachmentsActions'); |
|
77
|
|
|
this.attachmentsActions(isNonEmptyArray(attachmentsActions) ? attachmentsActions : []); |
|
78
|
|
|
|
|
79
|
|
|
this.devEmail = Settings.settingsGet('DevEmail'); |
|
80
|
|
|
this.devPassword = Settings.settingsGet('DevPassword'); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
export default new AppUserStore(); |
|
85
|
|
|
|