Update Manager: Various fixes
This commit is contained in:
parent
5c52c1ea5c
commit
38b0336bdb
@ -30,7 +30,12 @@ import {
|
|||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import { ChatAbortController } from '../ChatAbortController';
|
import { ChatAbortController } from '../ChatAbortController';
|
||||||
import {
|
import {
|
||||||
updateChannelState, getDifference, init as initUpdatesManager, processUpdate, reset as resetUpdatesManager,
|
updateChannelState,
|
||||||
|
getDifference,
|
||||||
|
init as initUpdatesManager,
|
||||||
|
processUpdate,
|
||||||
|
reset as resetUpdatesManager,
|
||||||
|
scheduleGetChannelDifference,
|
||||||
} from '../updateManager';
|
} from '../updateManager';
|
||||||
|
|
||||||
const DEFAULT_USER_AGENT = 'Unknown UserAgent';
|
const DEFAULT_USER_AGENT = 'Unknown UserAgent';
|
||||||
@ -482,3 +487,7 @@ export function setAllowHttpTransport(allowHttpTransport: boolean) {
|
|||||||
export function setShouldDebugExportedSenders(value: boolean) {
|
export function setShouldDebugExportedSenders(value: boolean) {
|
||||||
client.setShouldDebugExportedSenders(value);
|
client.setShouldDebugExportedSenders(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function requestChannelDifference(channelId: string) {
|
||||||
|
scheduleGetChannelDifference(channelId);
|
||||||
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
export {
|
export {
|
||||||
destroy, disconnect, downloadMedia, fetchCurrentUser, repairFileReference, abortChatRequests, abortRequestGroup,
|
destroy, disconnect, downloadMedia, fetchCurrentUser, repairFileReference, abortChatRequests, abortRequestGroup,
|
||||||
setForceHttpTransport, setShouldDebugExportedSenders, setAllowHttpTransport,
|
setForceHttpTransport, setShouldDebugExportedSenders, setAllowHttpTransport, requestChannelDifference,
|
||||||
} from './client';
|
} from './client';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { UpdateConnectionState, UpdateServerTimeOffset } from '../../lib/gramjs/
|
|||||||
import { DEBUG } from '../../config';
|
import { DEBUG } from '../../config';
|
||||||
import localDb from './localDb';
|
import localDb from './localDb';
|
||||||
import SortedQueue from '../../util/SortedQueue';
|
import SortedQueue from '../../util/SortedQueue';
|
||||||
import { dispatchUserAndChatUpdates, requestSync, updater } from './updater';
|
import { dispatchUserAndChatUpdates, sendUpdate, updater } from './updater';
|
||||||
import { addEntitiesToLocalDb } from './helpers';
|
import { addEntitiesToLocalDb } from './helpers';
|
||||||
import { buildInputEntity } from './gramjsBuilders';
|
import { buildInputEntity } from './gramjsBuilders';
|
||||||
import { buildApiPeerId } from './apiBuilders/peers';
|
import { buildApiPeerId } from './apiBuilders/peers';
|
||||||
@ -17,8 +17,8 @@ export type State = {
|
|||||||
pts: number;
|
pts: number;
|
||||||
qts: number;
|
qts: number;
|
||||||
};
|
};
|
||||||
type SeqUpdate = GramJs.Updates | GramJs.UpdatesCombined;
|
type SeqUpdate = (GramJs.Updates | GramJs.UpdatesCombined) & { _isFromDifference?: true };
|
||||||
type PtsUpdate = GramJs.TypeUpdate & { pts: number };
|
type PtsUpdate = GramJs.TypeUpdate & { pts: number } & { _isFromDifference?: true };
|
||||||
|
|
||||||
const COMMON_BOX_QUEUE_ID = '0';
|
const COMMON_BOX_QUEUE_ID = '0';
|
||||||
const CHANNEL_DIFFERENCE_LIMIT = 1000;
|
const CHANNEL_DIFFERENCE_LIMIT = 1000;
|
||||||
@ -49,7 +49,7 @@ export function applyState(state: State) {
|
|||||||
localDb.commonBoxState.qts = state.qts;
|
localDb.commonBoxState.qts = state.qts;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function processUpdate(update: Update) {
|
export function processUpdate(update: Update, isFromDifference?: boolean) {
|
||||||
if (update instanceof UpdateConnectionState) {
|
if (update instanceof UpdateConnectionState) {
|
||||||
if (update.state === UpdateConnectionState.connected && isInited) {
|
if (update.state === UpdateConnectionState.connected && isInited) {
|
||||||
scheduleGetDifference();
|
scheduleGetDifference();
|
||||||
@ -70,6 +70,11 @@ export function processUpdate(update: Update) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (update instanceof GramJs.Updates || update instanceof GramJs.UpdatesCombined) {
|
if (update instanceof GramJs.Updates || update instanceof GramJs.UpdatesCombined) {
|
||||||
|
if (isFromDifference) {
|
||||||
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
(update as SeqUpdate)._isFromDifference = true;
|
||||||
|
}
|
||||||
|
|
||||||
saveSeqUpdate(update);
|
saveSeqUpdate(update);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,6 +84,10 @@ export function processUpdate(update: Update) {
|
|||||||
getChannelDifference(getUpdateChannelId(update));
|
getChannelDifference(getUpdateChannelId(update));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (isFromDifference) {
|
||||||
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
(update as PtsUpdate)._isFromDifference = true;
|
||||||
|
}
|
||||||
savePtsUpdate(update);
|
savePtsUpdate(update);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -165,7 +174,8 @@ function popSeqQueue() {
|
|||||||
const localSeq = localDb.commonBoxState.seq;
|
const localSeq = localDb.commonBoxState.seq;
|
||||||
const seqStart = 'seqStart' in update ? update.seqStart : update.seq;
|
const seqStart = 'seqStart' in update ? update.seqStart : update.seq;
|
||||||
|
|
||||||
if (seqStart === 0) {
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
if (seqStart === 0 || (update._isFromDifference && seqStart >= localSeq + 1)) {
|
||||||
applyUpdate(update);
|
applyUpdate(update);
|
||||||
} else if (seqStart === localSeq + 1) {
|
} else if (seqStart === localSeq + 1) {
|
||||||
clearTimeout(seqTimeout);
|
clearTimeout(seqTimeout);
|
||||||
@ -198,7 +208,10 @@ function popPtsQueue(channelId: string) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pts === localPts + ptsCount) {
|
// eslint-disable-next-line no-underscore-dangle
|
||||||
|
if (update._isFromDifference && pts >= localPts + ptsCount) {
|
||||||
|
applyUpdate(update);
|
||||||
|
} else if (pts === localPts + ptsCount) {
|
||||||
clearTimeout(PTS_TIMEOUTS.get(channelId));
|
clearTimeout(PTS_TIMEOUTS.get(channelId));
|
||||||
PTS_TIMEOUTS.delete(channelId);
|
PTS_TIMEOUTS.delete(channelId);
|
||||||
|
|
||||||
@ -216,7 +229,7 @@ function popPtsQueue(channelId: string) {
|
|||||||
popPtsQueue(channelId);
|
popPtsQueue(channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function scheduleGetChannelDifference(channelId: string) {
|
export function scheduleGetChannelDifference(channelId: string) {
|
||||||
if (PTS_TIMEOUTS.has(channelId)) return;
|
if (PTS_TIMEOUTS.has(channelId)) return;
|
||||||
|
|
||||||
const timeout = setTimeout(async () => {
|
const timeout = setTimeout(async () => {
|
||||||
@ -258,6 +271,11 @@ export async function getDifference() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendUpdate({
|
||||||
|
'@type': 'updateFetchingDifference',
|
||||||
|
isFetching: true,
|
||||||
|
});
|
||||||
|
|
||||||
const response = await invoke(new GramJs.updates.GetDifference({
|
const response = await invoke(new GramJs.updates.GetDifference({
|
||||||
pts: localDb.commonBoxState.pts,
|
pts: localDb.commonBoxState.pts,
|
||||||
date: localDb.commonBoxState.date,
|
date: localDb.commonBoxState.date,
|
||||||
@ -275,6 +293,10 @@ export async function getDifference() {
|
|||||||
if (response instanceof GramJs.updates.DifferenceEmpty) {
|
if (response instanceof GramJs.updates.DifferenceEmpty) {
|
||||||
localDb.commonBoxState.seq = response.seq;
|
localDb.commonBoxState.seq = response.seq;
|
||||||
localDb.commonBoxState.date = response.date;
|
localDb.commonBoxState.date = response.date;
|
||||||
|
sendUpdate({
|
||||||
|
'@type': 'updateFetchingDifference',
|
||||||
|
isFetching: false,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +307,13 @@ export async function getDifference() {
|
|||||||
|
|
||||||
if (response instanceof GramJs.updates.DifferenceSlice) {
|
if (response instanceof GramJs.updates.DifferenceSlice) {
|
||||||
getDifference();
|
getDifference();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendUpdate({
|
||||||
|
'@type': 'updateFetchingDifference',
|
||||||
|
isFetching: false,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getChannelDifference(channelId: string) {
|
async function getChannelDifference(channelId: string) {
|
||||||
@ -336,7 +364,9 @@ async function getChannelDifference(channelId: string) {
|
|||||||
function forceSync() {
|
function forceSync() {
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
requestSync();
|
sendUpdate({
|
||||||
|
'@type': 'requestSync',
|
||||||
|
});
|
||||||
|
|
||||||
loadRemoteState();
|
loadRemoteState();
|
||||||
}
|
}
|
||||||
@ -389,7 +419,7 @@ function processDifference(
|
|||||||
dispatchUserAndChatUpdates(difference.chats);
|
dispatchUserAndChatUpdates(difference.chats);
|
||||||
|
|
||||||
difference.otherUpdates.forEach((update) => {
|
difference.otherUpdates.forEach((update) => {
|
||||||
processUpdate(update);
|
processUpdate(update, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import type { GroupCallConnectionData } from '../../lib/secret-sauce';
|
import type { GroupCallConnectionData } from '../../lib/secret-sauce';
|
||||||
import { Api as GramJs, connection } from '../../lib/gramjs';
|
import { Api as GramJs, connection } from '../../lib/gramjs';
|
||||||
import type {
|
import type {
|
||||||
ApiMessage, ApiMessageExtendedMediaPreview, ApiUpdateConnectionStateType, OnApiUpdate,
|
ApiMessage, ApiMessageExtendedMediaPreview, ApiUpdate, ApiUpdateConnectionStateType, OnApiUpdate,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
|
|
||||||
import { DEBUG, GENERAL_TOPIC_ID } from '../../config';
|
import { DEBUG, GENERAL_TOPIC_ID } from '../../config';
|
||||||
@ -117,10 +117,8 @@ export function dispatchUserAndChatUpdates(entities: (GramJs.TypeUser | GramJs.T
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function requestSync() {
|
export function sendUpdate(update: ApiUpdate) {
|
||||||
onUpdate({
|
onUpdate(update);
|
||||||
'@type': 'requestSync',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updater(update: Update) {
|
export function updater(update: Update) {
|
||||||
|
|||||||
@ -615,6 +615,11 @@ export type ApiUpdateMessageTranslations = {
|
|||||||
toLanguageCode: string;
|
toLanguageCode: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ApiUpdateFetchingDifference = {
|
||||||
|
'@type': 'updateFetchingDifference';
|
||||||
|
isFetching: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export type ApiRequestReconnectApi = {
|
export type ApiRequestReconnectApi = {
|
||||||
'@type': 'requestReconnectApi';
|
'@type': 'requestReconnectApi';
|
||||||
};
|
};
|
||||||
@ -649,7 +654,7 @@ export type ApiUpdate = (
|
|||||||
ApiUpdatePhoneCallConnectionState | ApiUpdateBotMenuButton | ApiUpdateTranscribedAudio | ApiUpdateUserEmojiStatus |
|
ApiUpdatePhoneCallConnectionState | ApiUpdateBotMenuButton | ApiUpdateTranscribedAudio | ApiUpdateUserEmojiStatus |
|
||||||
ApiUpdateMessageExtendedMedia | ApiUpdateConfig | ApiUpdateTopicNotifyExceptions | ApiUpdatePinnedTopic |
|
ApiUpdateMessageExtendedMedia | ApiUpdateConfig | ApiUpdateTopicNotifyExceptions | ApiUpdatePinnedTopic |
|
||||||
ApiUpdatePinnedTopicsOrder | ApiUpdateTopic | ApiUpdateTopics | ApiUpdateRecentEmojiStatuses |
|
ApiUpdatePinnedTopicsOrder | ApiUpdateTopic | ApiUpdateTopics | ApiUpdateRecentEmojiStatuses |
|
||||||
ApiUpdateRecentReactions | ApiRequestReconnectApi | ApiRequestSync
|
ApiUpdateRecentReactions | ApiRequestReconnectApi | ApiRequestSync | ApiUpdateFetchingDifference
|
||||||
);
|
);
|
||||||
|
|
||||||
export type OnApiUpdate = (update: ApiUpdate) => void;
|
export type OnApiUpdate = (update: ApiUpdate) => void;
|
||||||
|
|||||||
@ -93,7 +93,7 @@ type StateProps =
|
|||||||
hasPasscode?: boolean;
|
hasPasscode?: boolean;
|
||||||
canSetPasscode?: boolean;
|
canSetPasscode?: boolean;
|
||||||
}
|
}
|
||||||
& Pick<GlobalState, 'connectionState' | 'isSyncing' | 'archiveSettings'>
|
& Pick<GlobalState, 'connectionState' | 'isSyncing' | 'isFetchingDifference' | 'archiveSettings'>
|
||||||
& Pick<TabState, 'canInstall'>;
|
& Pick<TabState, 'canInstall'>;
|
||||||
|
|
||||||
const CLEAR_DATE_SEARCH_PARAM = { date: undefined };
|
const CLEAR_DATE_SEARCH_PARAM = { date: undefined };
|
||||||
@ -121,6 +121,7 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
|
|||||||
animationLevel,
|
animationLevel,
|
||||||
connectionState,
|
connectionState,
|
||||||
isSyncing,
|
isSyncing,
|
||||||
|
isFetchingDifference,
|
||||||
isMessageListOpen,
|
isMessageListOpen,
|
||||||
isConnectionStatusMinimized,
|
isConnectionStatusMinimized,
|
||||||
areChatsLoaded,
|
areChatsLoaded,
|
||||||
@ -154,7 +155,12 @@ const LeftMainHeader: FC<OwnProps & StateProps> = ({
|
|||||||
const archivedUnreadChatsCount = useFolderManagerForUnreadCounters()[ARCHIVED_FOLDER_ID]?.chatsCount || 0;
|
const archivedUnreadChatsCount = useFolderManagerForUnreadCounters()[ARCHIVED_FOLDER_ID]?.chatsCount || 0;
|
||||||
|
|
||||||
const { connectionStatus, connectionStatusText, connectionStatusPosition } = useConnectionStatus(
|
const { connectionStatus, connectionStatusText, connectionStatusPosition } = useConnectionStatus(
|
||||||
lang, connectionState, isSyncing, isMessageListOpen, isConnectionStatusMinimized, !areChatsLoaded,
|
lang,
|
||||||
|
connectionState,
|
||||||
|
isSyncing || isFetchingDifference,
|
||||||
|
isMessageListOpen,
|
||||||
|
isConnectionStatusMinimized,
|
||||||
|
!areChatsLoaded,
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleLockScreenHotkey = useLastCallback((e: KeyboardEvent) => {
|
const handleLockScreenHotkey = useLastCallback((e: KeyboardEvent) => {
|
||||||
@ -485,7 +491,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
query: searchQuery, fetchingStatus, chatId, date,
|
query: searchQuery, fetchingStatus, chatId, date,
|
||||||
} = tabState.globalSearch;
|
} = tabState.globalSearch;
|
||||||
const {
|
const {
|
||||||
currentUserId, connectionState, isSyncing, archiveSettings,
|
currentUserId, connectionState, isSyncing, archiveSettings, isFetchingDifference,
|
||||||
} = global;
|
} = global;
|
||||||
const { isConnectionStatusMinimized, animationLevel } = global.settings.byKey;
|
const { isConnectionStatusMinimized, animationLevel } = global.settings.byKey;
|
||||||
|
|
||||||
@ -499,6 +505,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
animationLevel,
|
animationLevel,
|
||||||
connectionState,
|
connectionState,
|
||||||
isSyncing,
|
isSyncing,
|
||||||
|
isFetchingDifference,
|
||||||
isMessageListOpen: Boolean(selectCurrentMessageList(global)),
|
isMessageListOpen: Boolean(selectCurrentMessageList(global)),
|
||||||
isConnectionStatusMinimized,
|
isConnectionStatusMinimized,
|
||||||
isCurrentUserPremium: selectIsCurrentUserPremium(global),
|
isCurrentUserPremium: selectIsCurrentUserPremium(global),
|
||||||
|
|||||||
@ -105,7 +105,8 @@ type StateProps = {
|
|||||||
shouldSkipHistoryAnimations?: boolean;
|
shouldSkipHistoryAnimations?: boolean;
|
||||||
currentTransitionKey: number;
|
currentTransitionKey: number;
|
||||||
connectionState?: GlobalState['connectionState'];
|
connectionState?: GlobalState['connectionState'];
|
||||||
isSyncing?: GlobalState['isSyncing'];
|
isSyncing?: boolean;
|
||||||
|
isFetchingDifference?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const MiddleHeader: FC<OwnProps & StateProps> = ({
|
const MiddleHeader: FC<OwnProps & StateProps> = ({
|
||||||
@ -132,6 +133,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
|
|||||||
currentTransitionKey,
|
currentTransitionKey,
|
||||||
connectionState,
|
connectionState,
|
||||||
isSyncing,
|
isSyncing,
|
||||||
|
isFetchingDifference,
|
||||||
getCurrentPinnedIndexes,
|
getCurrentPinnedIndexes,
|
||||||
getLoadingPinnedId,
|
getLoadingPinnedId,
|
||||||
onFocusPinnedMessage,
|
onFocusPinnedMessage,
|
||||||
@ -319,7 +321,7 @@ const MiddleHeader: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [shouldUseStackedToolsClass, canRevealTools, canToolsCollideWithChatInfo, isRightColumnShown]);
|
}, [shouldUseStackedToolsClass, canRevealTools, canToolsCollideWithChatInfo, isRightColumnShown]);
|
||||||
|
|
||||||
const { connectionStatusText } = useConnectionStatus(lang, connectionState, isSyncing, true);
|
const { connectionStatusText } = useConnectionStatus(lang, connectionState, isSyncing || isFetchingDifference, true);
|
||||||
|
|
||||||
function renderInfo() {
|
function renderInfo() {
|
||||||
if (messageListType === 'thread') {
|
if (messageListType === 'thread') {
|
||||||
@ -524,6 +526,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
currentTransitionKey: Math.max(0, messageLists.length - 1),
|
currentTransitionKey: Math.max(0, messageLists.length - 1),
|
||||||
connectionState: global.connectionState,
|
connectionState: global.connectionState,
|
||||||
isSyncing: global.isSyncing,
|
isSyncing: global.isSyncing,
|
||||||
|
isFetchingDifference: global.isFetchingDifference,
|
||||||
hasButtonInHeader: canStartBot || canRestartBot || canSubscribe || shouldSendJoinRequest,
|
hasButtonInHeader: canStartBot || canRestartBot || canSubscribe || shouldSendJoinRequest,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -179,6 +179,12 @@ addActionHandler('signOut', async (global, actions, payload): Promise<void> => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addActionHandler('requestChannelDifference', (global, actions, payload): ActionReturnType => {
|
||||||
|
const { chatId } = payload;
|
||||||
|
|
||||||
|
void callApi('requestChannelDifference', chatId);
|
||||||
|
});
|
||||||
|
|
||||||
addActionHandler('reset', (global, actions): ActionReturnType => {
|
addActionHandler('reset', (global, actions): ActionReturnType => {
|
||||||
clearStoredSession();
|
clearStoredSession();
|
||||||
clearEncryptedSession();
|
clearEncryptedSession();
|
||||||
|
|||||||
@ -23,6 +23,8 @@ import { clearWebTokenAuth } from '../../../util/routing';
|
|||||||
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
import { getCurrentTabId } from '../../../util/establishMultitabRole';
|
||||||
import { updateTabState } from '../../reducers/tabs';
|
import { updateTabState } from '../../reducers/tabs';
|
||||||
import { setServerTimeOffset } from '../../../util/serverTime';
|
import { setServerTimeOffset } from '../../../util/serverTime';
|
||||||
|
import { isChatChannel, isChatSuperGroup } from '../../helpers';
|
||||||
|
import { unique } from '../../../util/iteratees';
|
||||||
|
|
||||||
addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
||||||
switch (update['@type']) {
|
switch (update['@type']) {
|
||||||
@ -59,7 +61,6 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'requestReconnectApi':
|
case 'requestReconnectApi':
|
||||||
global = getGlobal();
|
|
||||||
global = { ...global, isSynced: false };
|
global = { ...global, isSynced: false };
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
@ -74,6 +75,11 @@ addActionHandler('apiUpdate', (global, actions, update): ActionReturnType => {
|
|||||||
actions.sync();
|
actions.sync();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'updateFetchingDifference':
|
||||||
|
global = { ...global, isFetchingDifference: update.isFetching };
|
||||||
|
setGlobal(global);
|
||||||
|
break;
|
||||||
|
|
||||||
case 'error': {
|
case 'error': {
|
||||||
Object.values(global.byTabId).forEach(({ id: tabId }) => {
|
Object.values(global.byTabId).forEach(({ id: tabId }) => {
|
||||||
const paymentShippingError = getShippingError(update.error);
|
const paymentShippingError = getShippingError(update.error);
|
||||||
@ -216,6 +222,19 @@ function onUpdateConnectionState<T extends GlobalState>(
|
|||||||
};
|
};
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
|
const channelStackIds = Object.values(global.byTabId)
|
||||||
|
.flatMap((tab) => tab.messageLists)
|
||||||
|
.map((messageList) => messageList.chatId)
|
||||||
|
.filter((chatId) => {
|
||||||
|
const chat = global.chats.byId[chatId];
|
||||||
|
return isChatChannel(chat) || isChatSuperGroup(chat);
|
||||||
|
});
|
||||||
|
if (connectionState === 'connectionStateReady' && channelStackIds.length) {
|
||||||
|
unique(channelStackIds).forEach((chatId) => {
|
||||||
|
actions.requestChannelDifference({ chatId });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (connectionState === 'connectionStateBroken') {
|
if (connectionState === 'connectionStateBroken') {
|
||||||
actions.signOut({ forceInitApi: true });
|
actions.signOut({ forceInitApi: true });
|
||||||
}
|
}
|
||||||
|
|||||||
@ -590,6 +590,7 @@ export type GlobalState = {
|
|||||||
isSyncing?: boolean;
|
isSyncing?: boolean;
|
||||||
isUpdateAvailable?: boolean;
|
isUpdateAvailable?: boolean;
|
||||||
isSynced?: boolean;
|
isSynced?: boolean;
|
||||||
|
isFetchingDifference?: boolean;
|
||||||
leftColumnWidth?: number;
|
leftColumnWidth?: number;
|
||||||
lastIsChatInfoShown?: boolean;
|
lastIsChatInfoShown?: boolean;
|
||||||
initialUnreadNotifications?: number;
|
initialUnreadNotifications?: number;
|
||||||
@ -1592,6 +1593,9 @@ export interface ActionPayloads {
|
|||||||
|
|
||||||
// Initial
|
// Initial
|
||||||
signOut: { forceInitApi?: boolean } | undefined;
|
signOut: { forceInitApi?: boolean } | undefined;
|
||||||
|
requestChannelDifference: {
|
||||||
|
chatId: string;
|
||||||
|
};
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
setInstallPrompt: { canInstall: boolean } & WithTabId;
|
setInstallPrompt: { canInstall: boolean } & WithTabId;
|
||||||
|
|||||||
@ -18,7 +18,7 @@ type ConnectionStatusPosition =
|
|||||||
export default function useConnectionStatus(
|
export default function useConnectionStatus(
|
||||||
lang: LangFn,
|
lang: LangFn,
|
||||||
connectionState: GlobalState['connectionState'],
|
connectionState: GlobalState['connectionState'],
|
||||||
isSyncing: GlobalState['isSyncing'],
|
isSyncing: boolean | undefined,
|
||||||
hasMiddleHeader: boolean,
|
hasMiddleHeader: boolean,
|
||||||
isMinimized?: boolean,
|
isMinimized?: boolean,
|
||||||
isDisabled?: boolean,
|
isDisabled?: boolean,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user