|
|
|
@ -329,6 +329,8 @@ async function getMessages({
|
|
|
|
|
conversationKey: string;
|
|
|
|
|
messageId: string | null;
|
|
|
|
|
}): Promise<Array<MessageModelPropsWithoutConvoProps>> {
|
|
|
|
|
const beforeTimestamp = Date.now();
|
|
|
|
|
|
|
|
|
|
const conversation = getConversationController().get(conversationKey);
|
|
|
|
|
if (!conversation) {
|
|
|
|
|
// no valid conversation, early return
|
|
|
|
@ -343,6 +345,8 @@ async function getMessages({
|
|
|
|
|
const messageProps: Array<MessageModelPropsWithoutConvoProps> = messageSet.models.map(m =>
|
|
|
|
|
m.getMessageModelProps()
|
|
|
|
|
);
|
|
|
|
|
const time = Date.now() - beforeTimestamp;
|
|
|
|
|
window?.log?.info(`Loading ${messageProps.length} messages took ${time}ms to load.`);
|
|
|
|
|
return messageProps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -373,13 +377,10 @@ export const fetchTopMessagesForConversation = createAsyncThunk(
|
|
|
|
|
window.log.info('fetchTopMessagesForConversation: we are already at the top');
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
const beforeTimestamp = Date.now();
|
|
|
|
|
const messagesProps = await getMessages({
|
|
|
|
|
conversationKey,
|
|
|
|
|
messageId: oldTopMessageId,
|
|
|
|
|
});
|
|
|
|
|
const time = Date.now() - beforeTimestamp;
|
|
|
|
|
window?.log?.info(`Loading ${messagesProps.length} messages took ${time}ms to load.`);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
conversationKey,
|
|
|
|
@ -405,7 +406,6 @@ export const fetchBottomMessagesForConversation = createAsyncThunk(
|
|
|
|
|
conversationKey: string;
|
|
|
|
|
oldBottomMessageId: string | null;
|
|
|
|
|
}): Promise<FetchedBottomMessageResults> => {
|
|
|
|
|
const beforeTimestamp = Date.now();
|
|
|
|
|
// no need to load more bottom if we are already at the bottom
|
|
|
|
|
const mostRecentMessage = await getLastMessageInConversation(conversationKey);
|
|
|
|
|
|
|
|
|
@ -417,8 +417,6 @@ export const fetchBottomMessagesForConversation = createAsyncThunk(
|
|
|
|
|
conversationKey,
|
|
|
|
|
messageId: oldBottomMessageId,
|
|
|
|
|
});
|
|
|
|
|
const time = Date.now() - beforeTimestamp;
|
|
|
|
|
window?.log?.info(`Loading ${messagesProps.length} messages took ${time}ms to load.`);
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
conversationKey,
|
|
|
|
|