nodebb-plugin-mentions 3.0.12 → 3.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/static/autofill.js
CHANGED
|
@@ -33,12 +33,18 @@ $(document).ready(function () {
|
|
|
33
33
|
if (err) {
|
|
34
34
|
return callback([]);
|
|
35
35
|
}
|
|
36
|
+
const termLowerCase = term.toLocaleLowerCase();
|
|
37
|
+
const localMatches = localUserList.filter(
|
|
38
|
+
u => u.username.startsWith(termLowerCase)
|
|
39
|
+
);
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
// remove local matches from search results
|
|
42
|
+
users = users.filter(u => !localMatches.find(lu => lu.uid === u.uid));
|
|
43
|
+
mentions = usersToMentions(sortUsers(localMatches).concat(sortUsers(users)), helpers);
|
|
38
44
|
|
|
39
45
|
// Add groups that start with the search term
|
|
40
46
|
const groupMentions = groupList.filter(function (groupName) {
|
|
41
|
-
return groupName.toLocaleLowerCase().startsWith(
|
|
47
|
+
return groupName.toLocaleLowerCase().startsWith(termLowerCase);
|
|
42
48
|
}).sort(function (a, b) {
|
|
43
49
|
return a.toLocaleLowerCase() > b.toLocaleLowerCase() ? 1 : -1;
|
|
44
50
|
});
|
|
@@ -93,21 +99,28 @@ $(document).ready(function () {
|
|
|
93
99
|
|
|
94
100
|
function loadTopicUsers(element) {
|
|
95
101
|
require(['composer', 'alerts'], function (composer, alerts) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
function findTid() {
|
|
103
|
+
const composerEl = element.parents('.composer').get(0);
|
|
104
|
+
if (composerEl) {
|
|
105
|
+
const uuid = composerEl.getAttribute('data-uuid');
|
|
106
|
+
const composerObj = composer.posts[uuid];
|
|
107
|
+
if (composerObj && composerObj.tid) {
|
|
108
|
+
return composerObj.tid;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (ajaxify.data.template.topic) {
|
|
112
|
+
return ajaxify.data.tid;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!composerObj.tid) {
|
|
117
|
+
const tid = findTid();
|
|
118
|
+
if (!tid) {
|
|
105
119
|
localUserList = [];
|
|
106
120
|
return;
|
|
107
121
|
}
|
|
108
|
-
|
|
109
122
|
socket.emit('plugins.mentions.getTopicUsers', {
|
|
110
|
-
tid:
|
|
123
|
+
tid: tid,
|
|
111
124
|
}, function (err, users) {
|
|
112
125
|
if (err) {
|
|
113
126
|
return alerts.error(err);
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const db = module.parent.require('./database');
|
|
5
|
-
const batch = module.parent.require('./batch');
|
|
6
|
-
module.exports = {
|
|
7
|
-
name: 'Delete mentions:sent:<pid> sorted sets',
|
|
8
|
-
timestamp: Date.UTC(2021, 10, 2),
|
|
9
|
-
method: async function () {
|
|
10
|
-
const { progress } = this;
|
|
11
|
-
const nextPid = await db.getObjectField('global', 'nextPid');
|
|
12
|
-
const allPids = [];
|
|
13
|
-
for (let pid = 1; pid < nextPid; ++ pid) {
|
|
14
|
-
allPids.push(pid);
|
|
15
|
-
}
|
|
16
|
-
await batch.processArray(allPids, async (pids) => {
|
|
17
|
-
progress.incr(pids.length);
|
|
18
|
-
await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
|
|
19
|
-
}, {
|
|
20
|
-
batch: 500,
|
|
21
|
-
});
|
|
22
|
-
},
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const db = module.parent.require('./database');
|
|
5
|
+
const batch = module.parent.require('./batch');
|
|
6
|
+
module.exports = {
|
|
7
|
+
name: 'Delete mentions:sent:<pid> sorted sets',
|
|
8
|
+
timestamp: Date.UTC(2021, 10, 2),
|
|
9
|
+
method: async function () {
|
|
10
|
+
const { progress } = this;
|
|
11
|
+
const nextPid = await db.getObjectField('global', 'nextPid');
|
|
12
|
+
const allPids = [];
|
|
13
|
+
for (let pid = 1; pid < nextPid; ++ pid) {
|
|
14
|
+
allPids.push(pid);
|
|
15
|
+
}
|
|
16
|
+
await batch.processArray(allPids, async (pids) => {
|
|
17
|
+
progress.incr(pids.length);
|
|
18
|
+
await db.deleteAll(pids.map(pid => `mentions:sent:${pid}`));
|
|
19
|
+
}, {
|
|
20
|
+
batch: 500,
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
23
|
};
|