Context Menu Hint: Fix hint showing up on page reload (#2916)

This commit is contained in:
Alexander Zinchuk 2023-04-06 08:20:17 +02:00
parent e7d70ccda6
commit 52b3e0f1a4
4 changed files with 11 additions and 13 deletions

View File

@ -637,8 +637,8 @@ addActionHandler('toggleMessageSelection', (global, actions, payload): ActionRet
setGlobal(global);
if (selectTabState(global, tabId).shouldShowContextMenuHint) {
actions.disableContextMenuHint({ tabId });
if (global.shouldShowContextMenuHint) {
actions.disableContextMenuHint();
actions.showNotification({
// eslint-disable-next-line max-len
message: `To **edit** or **reply**, close this menu. Then ${IS_TOUCH_ENV ? 'long tap' : 'right click'} on a message.`,
@ -647,16 +647,15 @@ addActionHandler('toggleMessageSelection', (global, actions, payload): ActionRet
}
});
addActionHandler('disableContextMenuHint', (global, actions, payload): ActionReturnType => {
const { tabId = getCurrentTabId() } = payload || {};
if (!selectTabState(global, tabId).shouldShowContextMenuHint) {
addActionHandler('disableContextMenuHint', (global): ActionReturnType => {
if (!global.shouldShowContextMenuHint) {
return undefined;
}
return updateTabState(global, {
return {
...global,
shouldShowContextMenuHint: false,
}, tabId);
};
});
addActionHandler('exitMessageSelectMode', (global, actions, payload): ActionReturnType => {

View File

@ -342,6 +342,7 @@ export function serializeGlobal<T extends GlobalState>(global: T) {
'archiveSettings',
'mediaViewer',
'audioPlayer',
'shouldShowContextMenuHint',
]),
customEmojis: reduceCustomEmojis(global),
users: reduceUsers(global),

View File

@ -15,6 +15,7 @@ export const INITIAL_GLOBAL_STATE: GlobalState = {
passcode: {},
twoFaSettings: {},
isUpdateAvailable: false,
shouldShowContextMenuHint: true,
audioPlayer: {
lastPlaybackRate: DEFAULT_PLAYBACK_RATE,
@ -260,8 +261,6 @@ export const INITIAL_TAB_STATE: TabState = {
activeReactions: {},
shouldShowContextMenuHint: true,
activeDownloads: {
byChatId: {},
},

View File

@ -421,8 +421,6 @@ export type TabState = {
byChatId: Record<string, number[]>;
};
shouldShowContextMenuHint?: boolean;
statistics: {
byChatId: Record<string, ApiChannelStatistics | ApiGroupStatistics>;
currentMessage?: ApiMessageStatistics;
@ -558,6 +556,7 @@ export type GlobalState = {
leftColumnWidth?: number;
lastIsChatInfoShown?: boolean;
initialUnreadNotifications?: number;
shouldShowContextMenuHint?: boolean;
audioPlayer: {
lastPlaybackRate: number;
@ -1393,7 +1392,7 @@ export interface ActionPayloads {
selectedAt?: number;
} & WithTabId;
closeHistoryCalendar: WithTabId | undefined;
disableContextMenuHint: WithTabId | undefined;
disableContextMenuHint: undefined;
focusNextReply: WithTabId | undefined;
openMessageLanguageModal: {