mirror of
https://github.com/lux-tel/session-desktop.git
synced 2026-10-30 20:33:24 +00:00
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { getAppDispatch } from '../../state/dispatch';
|
|
import { useIsHidden, useIsMe } from '../../hooks/useParamSelector';
|
|
import { ConvoHub } from '../../session/conversations';
|
|
import { updateConfirmModal } from '../../state/ducks/modalDialog';
|
|
import { SessionButtonColor } from '../basic/SessionButton';
|
|
import { tr } from '../../localization/localeTools';
|
|
|
|
function useShowNoteToSelf({ conversationId }: { conversationId: string }) {
|
|
const isMe = useIsMe(conversationId);
|
|
const isHidden = useIsHidden(conversationId);
|
|
|
|
return isMe && isHidden;
|
|
}
|
|
|
|
export function useShowNoteToSelfCb({ conversationId }: { conversationId: string }) {
|
|
const showNTS = useShowNoteToSelf({ conversationId });
|
|
const dispatch = getAppDispatch();
|
|
|
|
const onClickClose = () => {
|
|
dispatch(updateConfirmModal(null));
|
|
};
|
|
|
|
const showConfirmationModal = () => {
|
|
dispatch(
|
|
updateConfirmModal({
|
|
title: tr('showNoteToSelf'),
|
|
i18nMessage: { token: 'showNoteToSelfDescription' },
|
|
onClickClose,
|
|
closeTheme: SessionButtonColor.TextPrimary,
|
|
onClickOk: async () => {
|
|
const convo = ConvoHub.use().get(conversationId);
|
|
await convo.unhideIfNeeded(true);
|
|
// Note: We don't want to close the modal for the show NTS action.
|
|
},
|
|
okText: tr('show'),
|
|
})
|
|
);
|
|
};
|
|
|
|
if (!showNTS) {
|
|
return null;
|
|
}
|
|
|
|
return showConfirmationModal;
|
|
}
|