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:
Barış Soner Uşaklı
2023-10-31 10:15:06 -04:00
committed by GitHub
parent 7a8c27bf90
commit 4c4f3ac983
18 changed files with 236 additions and 44 deletions

View File

@@ -43,13 +43,17 @@ Messaging.getMessages = async (params) => {
if (!ok) {
return;
}
const mids = await getMessageIds(roomId, uid, start, stop);
const [mids, messageCount] = await Promise.all([
getMessageIds(roomId, uid, start, stop),
db.getObjectField(`chat:room:${roomId}`, 'messageCount'),
]);
if (!mids.length) {
return [];
}
const count = parseInt(messageCount, 10) || 0;
const indices = {};
mids.forEach((mid, index) => {
indices[mid] = start + index;
indices[mid] = count - start - index - 1;
});
mids.reverse();