Sync: Fix support for tgaddr parameter
This commit is contained in:
parent
b47f8c765e
commit
9fe5ca5c45
@ -30,7 +30,6 @@ import {
|
||||
import { hasStoredSession } from '../util/sessions';
|
||||
import { INITIAL_STATE } from './initial';
|
||||
import { parseLocationHash } from '../util/routing';
|
||||
import { LOCATION_HASH } from '../hooks/useHistoryBack';
|
||||
import { isUserId } from '../modules/helpers';
|
||||
import { getOrderedIds } from '../util/folderManager';
|
||||
|
||||
@ -120,7 +119,7 @@ function readCache(initialState: GlobalState): GlobalState {
|
||||
...cached,
|
||||
};
|
||||
|
||||
const parsedMessageList = !IS_SINGLE_COLUMN_LAYOUT ? parseLocationHash(LOCATION_HASH) : undefined;
|
||||
const parsedMessageList = !IS_SINGLE_COLUMN_LAYOUT ? parseLocationHash() : undefined;
|
||||
|
||||
return {
|
||||
...newState,
|
||||
|
||||
@ -81,7 +81,6 @@ async function loadAndReplaceMessages() {
|
||||
let areMessagesLoaded = false;
|
||||
|
||||
let global = getGlobal();
|
||||
const { chatId: currentChatId, threadId: currentThreadId } = selectCurrentMessageList(global) || {};
|
||||
|
||||
// Memoize drafts
|
||||
const draftChatIds = Object.keys(global.messages.byChatId);
|
||||
@ -94,8 +93,10 @@ async function loadAndReplaceMessages() {
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
if (currentChatId) {
|
||||
const result = await loadTopMessages(global.chats.byId[currentChatId]);
|
||||
const { chatId: currentChatId, threadId: currentThreadId } = selectCurrentMessageList(global) || {};
|
||||
const currentChat = currentChatId ? global.chats.byId[currentChatId] : undefined;
|
||||
if (currentChatId && currentChat) {
|
||||
const result = await loadTopMessages(currentChat);
|
||||
global = getGlobal();
|
||||
const { chatId: newCurrentChatId } = selectCurrentMessageList(global) || {};
|
||||
const threadInfo = currentThreadId && selectThreadInfo(global, currentChatId, currentThreadId);
|
||||
|
||||
@ -1,18 +1,23 @@
|
||||
import { MessageList, MessageListType } from '../global/types';
|
||||
import { MAIN_THREAD_ID } from '../api/types';
|
||||
|
||||
export const createMessageHash = (messageList: MessageList): string => (
|
||||
messageList.chatId.toString()
|
||||
+ (messageList.type !== 'thread' ? `_${messageList.type}`
|
||||
: (messageList.threadId !== -1 ? `_${messageList.threadId}` : ''))
|
||||
);
|
||||
import { LOCATION_HASH } from '../hooks/useHistoryBack';
|
||||
|
||||
export const parseLocationHash = (value: string): MessageList | undefined => {
|
||||
if (!value) return undefined;
|
||||
export function createMessageHash(messageList: MessageList) {
|
||||
const typeOrThreadId = messageList.type !== 'thread' ? (
|
||||
`_${messageList.type}`
|
||||
) : messageList.threadId !== -1 ? (
|
||||
`_${messageList.threadId}`
|
||||
) : '';
|
||||
|
||||
const [chatId, typeOrThreadId] = value.replace(/^#/, '').split('_');
|
||||
return `${messageList.chatId}${typeOrThreadId}`;
|
||||
}
|
||||
|
||||
if (!chatId) return undefined;
|
||||
export function parseLocationHash() {
|
||||
if (!LOCATION_HASH) return undefined;
|
||||
|
||||
const [chatId, typeOrThreadId] = LOCATION_HASH.replace(/^#/, '').split('_');
|
||||
if (!chatId?.match(/^-?\d+$/)) return undefined;
|
||||
|
||||
const isType = ['thread', 'pinned', 'scheduled'].includes(typeOrThreadId);
|
||||
|
||||
@ -21,4 +26,4 @@ export const parseLocationHash = (value: string): MessageList | undefined => {
|
||||
type: Boolean(typeOrThreadId) && isType ? (typeOrThreadId as MessageListType) : 'thread',
|
||||
threadId: Boolean(typeOrThreadId) && !isType ? Number(typeOrThreadId) : MAIN_THREAD_ID,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user