mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-17 19:21:04 +01:00
feat: add direct message link (#12138)
* feat: add direct message link /message/:mid add /:index? to chat routes add copy link to chat messages add messageCount to each room object add infinitescroll in both directions to chat * fix more tests * test: more text fixes * test: fix tests * remove async * dont crash if element not in dom clamp scrollToIndex values to 0, msgCount
This commit is contained in:
committed by
GitHub
parent
7a8c27bf90
commit
4c4f3ac983
@@ -244,13 +244,29 @@ chatsAPI.kick = async (caller, data) => {
|
||||
return chatsAPI.users(caller, data);
|
||||
};
|
||||
|
||||
chatsAPI.listMessages = async (caller, { uid, roomId, start }) => {
|
||||
chatsAPI.listMessages = async (caller, { uid, roomId, start, direction = null }) => {
|
||||
const count = 50;
|
||||
let stop = start + count - 1;
|
||||
if (direction === 1 || direction === -1) {
|
||||
const msgCount = await db.getObjectField(`chat:room:${roomId}`, 'messageCount');
|
||||
start = msgCount - start;
|
||||
if (direction === 1) {
|
||||
start -= count + 1;
|
||||
}
|
||||
stop = start + count - 1;
|
||||
start = Math.max(0, start);
|
||||
if (stop <= -1) {
|
||||
return { messages: [] };
|
||||
}
|
||||
stop = Math.max(0, stop);
|
||||
}
|
||||
|
||||
const messages = await messaging.getMessages({
|
||||
callerUid: caller.uid,
|
||||
uid,
|
||||
roomId,
|
||||
start,
|
||||
count: 50,
|
||||
count: stop - start + 1,
|
||||
});
|
||||
|
||||
return { messages };
|
||||
|
||||
Reference in New Issue
Block a user