Message: Show context menu hint when selecting
This commit is contained in:
parent
ba10af9da1
commit
b6abe0ee7c
@ -24,7 +24,7 @@ const Notifications: FC<StateProps & DispatchProps> = ({ notifications, dismissN
|
|||||||
<div id="Notifications">
|
<div id="Notifications">
|
||||||
{notifications.map(({ message }) => (
|
{notifications.map(({ message }) => (
|
||||||
<Notification
|
<Notification
|
||||||
message={renderText(message, ['emoji', 'br', 'links'])}
|
message={renderText(message, ['emoji', 'br', 'links', 'simple_markdown'])}
|
||||||
onDismiss={dismissNotification}
|
onDismiss={dismissNotification}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -148,7 +148,7 @@ type DispatchProps = Pick<GlobalActions, (
|
|||||||
'openUserInfo' | 'openChat' |
|
'openUserInfo' | 'openChat' |
|
||||||
'cancelSendingMessage' | 'markMessagesRead' |
|
'cancelSendingMessage' | 'markMessagesRead' |
|
||||||
'sendPollVote' | 'toggleMessageSelection' | 'setReplyingToId' | 'openForwardMenu' |
|
'sendPollVote' | 'toggleMessageSelection' | 'setReplyingToId' | 'openForwardMenu' |
|
||||||
'clickInlineButton'
|
'clickInlineButton' | 'disableContextMenuHint'
|
||||||
)>;
|
)>;
|
||||||
|
|
||||||
const NBSP = '\u00A0';
|
const NBSP = '\u00A0';
|
||||||
@ -215,6 +215,7 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
setReplyingToId,
|
setReplyingToId,
|
||||||
openForwardMenu,
|
openForwardMenu,
|
||||||
clickInlineButton,
|
clickInlineButton,
|
||||||
|
disableContextMenuHint,
|
||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const ref = useRef<HTMLDivElement>(null);
|
const ref = useRef<HTMLDivElement>(null);
|
||||||
@ -233,6 +234,12 @@ const Message: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
handleContextMenuClose, handleContextMenuHide,
|
handleContextMenuClose, handleContextMenuHide,
|
||||||
} = useContextMenuHandlers(ref, false, true);
|
} = useContextMenuHandlers(ref, false, true);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isContextMenuOpen) {
|
||||||
|
disableContextMenuHint();
|
||||||
|
}
|
||||||
|
}, [isContextMenuOpen, disableContextMenuHint]);
|
||||||
|
|
||||||
const noAppearanceAnimation = appearanceOrder <= 0;
|
const noAppearanceAnimation = appearanceOrder <= 0;
|
||||||
const [isShown, markShown] = useFlag(noAppearanceAnimation);
|
const [isShown, markShown] = useFlag(noAppearanceAnimation);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -931,5 +938,6 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
'setReplyingToId',
|
'setReplyingToId',
|
||||||
'openForwardMenu',
|
'openForwardMenu',
|
||||||
'clickInlineButton',
|
'clickInlineButton',
|
||||||
|
'disableContextMenuHint',
|
||||||
]),
|
]),
|
||||||
)(Message));
|
)(Message));
|
||||||
|
|||||||
@ -118,6 +118,7 @@ function updateCache() {
|
|||||||
'recentEmojis',
|
'recentEmojis',
|
||||||
'emojiKeywords',
|
'emojiKeywords',
|
||||||
'push',
|
'push',
|
||||||
|
'shouldShowContextMenuHint',
|
||||||
]),
|
]),
|
||||||
isChatInfoShown: reduceShowChatInfo(global),
|
isChatInfoShown: reduceShowChatInfo(global),
|
||||||
users: reduceUsers(global),
|
users: reduceUsers(global),
|
||||||
|
|||||||
@ -133,4 +133,6 @@ export const INITIAL_STATE: GlobalState = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
twoFaSettings: {},
|
twoFaSettings: {},
|
||||||
|
|
||||||
|
shouldShowContextMenuHint: true,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -390,6 +390,9 @@ export type GlobalState = {
|
|||||||
|
|
||||||
safeLinkModalUrl?: string;
|
safeLinkModalUrl?: string;
|
||||||
historyCalendarSelectedAt?: number;
|
historyCalendarSelectedAt?: number;
|
||||||
|
|
||||||
|
// TODO To be removed in August 2021
|
||||||
|
shouldShowContextMenuHint?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ActionTypes = (
|
export type ActionTypes = (
|
||||||
@ -398,7 +401,7 @@ export type ActionTypes = (
|
|||||||
'showNotification' | 'dismissNotification' | 'showError' | 'dismissError' |
|
'showNotification' | 'dismissNotification' | 'showError' | 'dismissError' |
|
||||||
// ui
|
// ui
|
||||||
'toggleChatInfo' | 'setIsUiReady' | 'addRecentEmoji' | 'addRecentSticker' | 'toggleLeftColumn' |
|
'toggleChatInfo' | 'setIsUiReady' | 'addRecentEmoji' | 'addRecentSticker' | 'toggleLeftColumn' |
|
||||||
'toggleSafeLinkModal' | 'openHistoryCalendar' | 'closeHistoryCalendar' |
|
'toggleSafeLinkModal' | 'openHistoryCalendar' | 'closeHistoryCalendar' | 'disableContextMenuHint' |
|
||||||
// auth
|
// auth
|
||||||
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
'setAuthPhoneNumber' | 'setAuthCode' | 'setAuthPassword' | 'signUp' | 'returnToAuthPhoneNumber' | 'signOut' |
|
||||||
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
'setAuthRememberMe' | 'clearAuthError' | 'uploadProfilePhoto' | 'goToAuthQrCode' | 'clearCache' |
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import {
|
|||||||
selectForwardedMessageIdsByGroupId, selectIsViewportNewest, selectReplyingToId,
|
selectForwardedMessageIdsByGroupId, selectIsViewportNewest, selectReplyingToId,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { findLast } from '../../../util/iteratees';
|
import { findLast } from '../../../util/iteratees';
|
||||||
|
import { IS_TOUCH_ENV } from '../../../util/environment';
|
||||||
|
|
||||||
const FOCUS_DURATION = 2000;
|
const FOCUS_DURATION = 2000;
|
||||||
const POLL_RESULT_OPEN_DELAY_MS = 450;
|
const POLL_RESULT_OPEN_DELAY_MS = 450;
|
||||||
@ -371,16 +372,36 @@ addReducer('toggleMessageSelection', (global, actions, payload) => {
|
|||||||
} = payload!;
|
} = payload!;
|
||||||
const currentMessageList = selectCurrentMessageList(global);
|
const currentMessageList = selectCurrentMessageList(global);
|
||||||
if (!currentMessageList) {
|
if (!currentMessageList) {
|
||||||
return undefined;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { chatId, threadId, type: messageListType } = currentMessageList;
|
const { chatId, threadId, type: messageListType } = currentMessageList;
|
||||||
|
|
||||||
return toggleMessageSelection(
|
global = toggleMessageSelection(
|
||||||
global, chatId, threadId, messageListType, messageId, groupedId, childMessageIds, withShift,
|
global, chatId, threadId, messageListType, messageId, groupedId, childMessageIds, withShift,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setGlobal(global);
|
||||||
|
|
||||||
|
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.`,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
addReducer('disableContextMenuHint', (global) => {
|
||||||
|
if (!global.shouldShowContextMenuHint) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...global,
|
||||||
|
shouldShowContextMenuHint: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
addReducer('exitMessageSelectMode', exitMessageSelectMode);
|
addReducer('exitMessageSelectMode', exitMessageSelectMode);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user