-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathignore.js
More file actions
35 lines (30 loc) · 1016 Bytes
/
ignore.js
File metadata and controls
35 lines (30 loc) · 1016 Bytes
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
import * as settings from 'src/utils/settings/index.js';
import * as api from 'src/utils/4.api.js';
import ignoreUser from 'src/utils/ignoreUser.js';
const ignorePrefix = 'underscript.ignore.';
function ignore(user) {
const name = user.username || user.name;
const id = user.id || user.idUser;
if (!name || !id) throw new Error('Invalid user');
if (isIgnored(user)) return;
const key = `${ignorePrefix}${id}`;
ignoreUser(name, key, true);
}
function unignore(user) {
const name = user.username || user.name;
const id = user.id || user.idUser;
if (!name || !id) throw new Error('Invalid user');
const key = `${ignorePrefix}${id}`;
settings.remove(key);
}
function isIgnored(user) {
const name = user.username || user.name;
const id = user.id || user.idUser;
if (!name || !id) throw new Error('Invalid user');
const key = `${ignorePrefix}${id}`;
return !!settings.value(key);
}
const user = api.mod.user;
user.ignore = ignore;
user.unIgnore = unignore;
user.isIgnored = isIgnored;