Message List: Some fixes for navigation history
This commit is contained in:
parent
250296ee52
commit
4e546ebf41
@ -88,6 +88,7 @@ export const MOBILE_SCREEN_LANDSCAPE_MAX_WIDTH = 950; // px
|
|||||||
export const MOBILE_SCREEN_LANDSCAPE_MAX_HEIGHT = 450; // px
|
export const MOBILE_SCREEN_LANDSCAPE_MAX_HEIGHT = 450; // px
|
||||||
|
|
||||||
export const LOCAL_MESSAGE_ID_BASE = 1e9;
|
export const LOCAL_MESSAGE_ID_BASE = 1e9;
|
||||||
|
export const TMP_CHAT_ID = '0';
|
||||||
|
|
||||||
export const ANIMATION_END_DELAY = 100;
|
export const ANIMATION_END_DELAY = 100;
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,10 @@ import {
|
|||||||
TOP_CHAT_MESSAGES_PRELOAD_LIMIT,
|
TOP_CHAT_MESSAGES_PRELOAD_LIMIT,
|
||||||
CHAT_LIST_LOAD_SLICE,
|
CHAT_LIST_LOAD_SLICE,
|
||||||
TIPS_USERNAME,
|
TIPS_USERNAME,
|
||||||
LOCALIZED_TIPS, RE_TG_LINK, SERVICE_NOTIFICATIONS_USER_ID,
|
LOCALIZED_TIPS,
|
||||||
|
RE_TG_LINK,
|
||||||
|
SERVICE_NOTIFICATIONS_USER_ID,
|
||||||
|
TMP_CHAT_ID,
|
||||||
} from '../../../config';
|
} from '../../../config';
|
||||||
import { callApi } from '../../../api/gramjs';
|
import { callApi } from '../../../api/gramjs';
|
||||||
import {
|
import {
|
||||||
@ -47,8 +50,6 @@ import { processDeepLink } from '../../../util/deeplink';
|
|||||||
|
|
||||||
const TOP_CHAT_MESSAGES_PRELOAD_INTERVAL = 100;
|
const TOP_CHAT_MESSAGES_PRELOAD_INTERVAL = 100;
|
||||||
const CHATS_PRELOAD_INTERVAL = 300;
|
const CHATS_PRELOAD_INTERVAL = 300;
|
||||||
// We expect this ID does not exist
|
|
||||||
const TMP_CHAT_ID = -1;
|
|
||||||
|
|
||||||
const runThrottledForLoadChats = throttle((cb) => cb(), CHATS_PRELOAD_INTERVAL, true);
|
const runThrottledForLoadChats = throttle((cb) => cb(), CHATS_PRELOAD_INTERVAL, true);
|
||||||
const runThrottledForLoadTopChats = throttle((cb) => cb(), 3000, true);
|
const runThrottledForLoadTopChats = throttle((cb) => cb(), 3000, true);
|
||||||
@ -158,17 +159,17 @@ addReducer('focusMessageInComments', (global, actions, payload) => {
|
|||||||
|
|
||||||
addReducer('openSupportChat', (global, actions) => {
|
addReducer('openSupportChat', (global, actions) => {
|
||||||
const chat = selectSupportChat(global);
|
const chat = selectSupportChat(global);
|
||||||
|
|
||||||
actions.openChat({ id: chat ? chat.id : TMP_CHAT_ID });
|
|
||||||
|
|
||||||
if (chat) {
|
if (chat) {
|
||||||
|
actions.openChat({ id: chat.id, shouldReplaceHistory: true });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions.openChat({ id: TMP_CHAT_ID, shouldReplaceHistory: true });
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const result = await callApi('fetchChat', { type: 'support' });
|
const result = await callApi('fetchChat', { type: 'support' });
|
||||||
if (result) {
|
if (result) {
|
||||||
actions.openChat({ id: result.chatId });
|
actions.openChat({ id: result.chatId, shouldReplaceHistory: true });
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
});
|
});
|
||||||
@ -1071,7 +1072,7 @@ async function createChannel(title: string, users: ApiUser[], about?: string, ph
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
getDispatch().openChat({ id: channelId });
|
getDispatch().openChat({ id: channelId, shouldReplaceHistory: true });
|
||||||
|
|
||||||
if (channelId && accessHash && photo) {
|
if (channelId && accessHash && photo) {
|
||||||
await callApi('editChatPhoto', { chatId: channelId, accessHash, photo });
|
await callApi('editChatPhoto', { chatId: channelId, accessHash, photo });
|
||||||
@ -1103,7 +1104,7 @@ async function createGroupChat(title: string, users: ApiUser[], photo?: File) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
getDispatch().openChat({ id: chatId });
|
getDispatch().openChat({ id: chatId, shouldReplaceHistory: true });
|
||||||
|
|
||||||
if (chatId && photo) {
|
if (chatId && photo) {
|
||||||
await callApi('editChatPhoto', { chatId, photo });
|
await callApi('editChatPhoto', { chatId, photo });
|
||||||
|
|||||||
@ -4,7 +4,9 @@ import {
|
|||||||
import { ApiMessage, ApiThreadInfo, MAIN_THREAD_ID } from '../../api/types';
|
import { ApiMessage, ApiThreadInfo, MAIN_THREAD_ID } from '../../api/types';
|
||||||
import { FocusDirection } from '../../types';
|
import { FocusDirection } from '../../types';
|
||||||
|
|
||||||
import { IS_TEST, MESSAGE_LIST_SLICE, MESSAGE_LIST_VIEWPORT_LIMIT } from '../../config';
|
import {
|
||||||
|
IS_TEST, MESSAGE_LIST_SLICE, MESSAGE_LIST_VIEWPORT_LIMIT, TMP_CHAT_ID,
|
||||||
|
} from '../../config';
|
||||||
import {
|
import {
|
||||||
selectListedIds,
|
selectListedIds,
|
||||||
selectChatMessages,
|
selectChatMessages,
|
||||||
@ -23,8 +25,6 @@ import {
|
|||||||
areSortedArraysEqual, omit, pickTruthy, unique,
|
areSortedArraysEqual, omit, pickTruthy, unique,
|
||||||
} from '../../util/iteratees';
|
} from '../../util/iteratees';
|
||||||
|
|
||||||
const TMP_CHAT_ID = '-1';
|
|
||||||
|
|
||||||
type MessageStoreSections = {
|
type MessageStoreSections = {
|
||||||
byId: Record<number, ApiMessage>;
|
byId: Record<number, ApiMessage>;
|
||||||
threadsById: Record<number, Thread>;
|
threadsById: Record<number, Thread>;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user