forked from streetwriters/notesnook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.js
86 lines (72 loc) · 2.71 KB
/
common.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2022 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import EventManager from "./utils/event-manager";
export const EV = new EventManager();
export async function checkIsUserPremium(type) {
// if (process.env.NODE_ENV === "test") return true;
const results = await EV.publishWithResult(EVENTS.userCheckStatus, type);
if (typeof results === "boolean") return results;
return results.some((r) => r.type === type && r.result === true);
}
export function sendAttachmentsProgressEvent(type, groupId, total, current) {
EV.publish(EVENTS.attachmentsLoading, {
type,
groupId,
total,
current: current === undefined ? total : current
});
}
export function sendSyncProgressEvent(EV, type, total, current) {
EV.publish(EVENTS.syncProgress, {
type,
total,
current: current === undefined ? total : current
});
}
export const CLIENT_ID = "notesnook";
export const CHECK_IDS = {
noteColor: "note:color",
noteTag: "note:tag",
noteExport: "note:export",
vaultAdd: "vault:add",
notebookAdd: "notebook:add",
backupEncrypt: "backup:encrypt",
databaseSync: "database:sync"
};
export const EVENTS = {
userCheckStatus: "user:checkStatus",
userSubscriptionUpdated: "user:subscriptionUpdated",
userEmailConfirmed: "user:emailConfirmed",
userLoggedIn: "user:loggedIn",
userLoggedOut: "user:loggedOut",
userFetched: "user:fetched",
userSignedUp: "user:signedUp",
userSessionExpired: "user:sessionExpired",
databaseSyncRequested: "db:syncRequested",
syncProgress: "sync:progress",
syncCompleted: "sync:completed",
databaseUpdated: "db:updated",
databaseCollectionInitiated: "db:collectionInitiated",
appRefreshRequested: "app:refreshRequested",
noteRemoved: "note:removed",
tokenRefreshed: "token:refreshed",
userUnauthorized: "user:unauthorized",
attachmentsLoading: "attachments:loading",
attachmentDeleted: "attachment:deleted",
mediaAttachmentDownloaded: "attachments:mediaDownloaded",
vaultLocked: "vault:locked",
systemTimeInvalid: "system:invalidTime"
};
export const CURRENT_DATABASE_VERSION = 5.6;