UserStatus: Add button to change privacy or buy premium to see user status (#4346)
This commit is contained in:
parent
c96d05bd9f
commit
70dfa2e160
BIN
src/assets/tgs/LastSeen.tgs
Normal file
BIN
src/assets/tgs/LastSeen.tgs
Normal file
Binary file not shown.
@ -30,7 +30,7 @@ export { default as PinMessageModal } from '../components/common/PinMessageModal
|
|||||||
export { default as UnpinAllMessagesModal } from '../components/common/UnpinAllMessagesModal';
|
export { default as UnpinAllMessagesModal } from '../components/common/UnpinAllMessagesModal';
|
||||||
export { default as MessageSelectToolbar } from '../components/middle/MessageSelectToolbar';
|
export { default as MessageSelectToolbar } from '../components/middle/MessageSelectToolbar';
|
||||||
export { default as SeenByModal } from '../components/common/SeenByModal';
|
export { default as SeenByModal } from '../components/common/SeenByModal';
|
||||||
export { default as ReadTimeModal } from '../components/common/ReadDateModal';
|
export { default as PrivacySettingsNoticeModal } from '../components/common/PrivacySettingsNoticeModal';
|
||||||
export { default as ReactorListModal } from '../components/middle/ReactorListModal';
|
export { default as ReactorListModal } from '../components/middle/ReactorListModal';
|
||||||
export { default as EmojiInteractionAnimation } from '../components/middle/EmojiInteractionAnimation';
|
export { default as EmojiInteractionAnimation } from '../components/middle/EmojiInteractionAnimation';
|
||||||
export { default as ChatLanguageModal } from '../components/middle/ChatLanguageModal';
|
export { default as ChatLanguageModal } from '../components/middle/ChatLanguageModal';
|
||||||
|
|||||||
18
src/components/common/PrivacySettingsNoticeModal.async.tsx
Normal file
18
src/components/common/PrivacySettingsNoticeModal.async.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import type { FC } from '../../lib/teact/teact';
|
||||||
|
import React from '../../lib/teact/teact';
|
||||||
|
|
||||||
|
import type { OwnProps } from './PrivacySettingsNoticeModal';
|
||||||
|
|
||||||
|
import { Bundles } from '../../util/moduleLoader';
|
||||||
|
|
||||||
|
import useModuleLoader from '../../hooks/useModuleLoader';
|
||||||
|
|
||||||
|
const PrivacySettingsNoticeModalAsync: FC<OwnProps> = (props) => {
|
||||||
|
const { isOpen } = props;
|
||||||
|
const PrivacySettingsNoticeModal = useModuleLoader(Bundles.Extra, 'PrivacySettingsNoticeModal', !isOpen);
|
||||||
|
|
||||||
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
||||||
|
return PrivacySettingsNoticeModal ? <PrivacySettingsNoticeModal {...props} /> : undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default PrivacySettingsNoticeModalAsync;
|
||||||
@ -18,7 +18,7 @@ import Separator from '../ui/Separator';
|
|||||||
import AnimatedIconWithPreview from './AnimatedIconWithPreview';
|
import AnimatedIconWithPreview from './AnimatedIconWithPreview';
|
||||||
import Icon from './Icon';
|
import Icon from './Icon';
|
||||||
|
|
||||||
import styles from './ReadDateModal.module.scss';
|
import styles from './PrivacySettingsNoticeModal.module.scss';
|
||||||
|
|
||||||
export type OwnProps = {
|
export type OwnProps = {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
@ -26,28 +26,47 @@ export type OwnProps = {
|
|||||||
|
|
||||||
type StateProps = {
|
type StateProps = {
|
||||||
user?: ApiUser;
|
user?: ApiUser;
|
||||||
|
isReadDate?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CLOSE_ANIMATION_DURATION = ANIMATION_DURATION + ANIMATION_END_DELAY;
|
const CLOSE_ANIMATION_DURATION = ANIMATION_DURATION + ANIMATION_END_DELAY;
|
||||||
|
|
||||||
const ReadDateModal = ({ isOpen, user }: OwnProps & StateProps) => {
|
const PrivacySettingsNoticeModal = ({ isOpen, isReadDate, user }: OwnProps & StateProps) => {
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const {
|
const {
|
||||||
updateGlobalPrivacySettings, openPremiumModal, closeGetReadDateModal, showNotification,
|
updateGlobalPrivacySettings,
|
||||||
|
openPremiumModal,
|
||||||
|
closePrivacySettingsNoticeModal,
|
||||||
|
showNotification,
|
||||||
|
setPrivacyVisibility,
|
||||||
|
loadUser,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
const userName = getUserFirstOrLastName(user);
|
const userName = getUserFirstOrLastName(user);
|
||||||
|
|
||||||
const handleShowReadTime = useLastCallback(() => {
|
const handleShowReadTime = useLastCallback(() => {
|
||||||
updateGlobalPrivacySettings({ shouldHideReadMarks: false });
|
updateGlobalPrivacySettings({ shouldHideReadMarks: false });
|
||||||
closeGetReadDateModal();
|
closePrivacySettingsNoticeModal();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
showNotification({ message: lang('PremiumReadSet') });
|
showNotification({ message: lang('PremiumReadSet') });
|
||||||
}, CLOSE_ANIMATION_DURATION);
|
}, CLOSE_ANIMATION_DURATION);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleShowLastSeen = useLastCallback(() => {
|
||||||
|
setPrivacyVisibility({
|
||||||
|
privacyKey: 'lastSeen',
|
||||||
|
visibility: 'everybody',
|
||||||
|
onSuccess: () => loadUser({ userId: user!.id }),
|
||||||
|
});
|
||||||
|
closePrivacySettingsNoticeModal();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
showNotification({ message: lang('PremiumLastSeenSet') });
|
||||||
|
}, CLOSE_ANIMATION_DURATION);
|
||||||
|
});
|
||||||
|
|
||||||
const handleOpenPremium = useLastCallback(() => {
|
const handleOpenPremium = useLastCallback(() => {
|
||||||
closeGetReadDateModal();
|
closePrivacySettingsNoticeModal();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
openPremiumModal();
|
openPremiumModal();
|
||||||
@ -55,7 +74,7 @@ const ReadDateModal = ({ isOpen, user }: OwnProps & StateProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const handleClose = useLastCallback(() => {
|
const handleClose = useLastCallback(() => {
|
||||||
closeGetReadDateModal();
|
closePrivacySettingsNoticeModal();
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -72,25 +91,45 @@ const ReadDateModal = ({ isOpen, user }: OwnProps & StateProps) => {
|
|||||||
<Icon name="close" />
|
<Icon name="close" />
|
||||||
</Button>
|
</Button>
|
||||||
<AnimatedIconWithPreview
|
<AnimatedIconWithPreview
|
||||||
tgsUrl={LOCAL_TGS_URLS.ReadTime}
|
tgsUrl={isReadDate ? LOCAL_TGS_URLS.ReadTime : LOCAL_TGS_URLS.LastSeen}
|
||||||
size={84}
|
size={84}
|
||||||
className={styles.icon}
|
className={styles.icon}
|
||||||
nonInteractive
|
nonInteractive
|
||||||
noLoop
|
noLoop
|
||||||
/>
|
/>
|
||||||
<h2 className={styles.header}>{lang('PremiumReadHeader1')}</h2>
|
<h2 className={styles.header}>
|
||||||
<p className={styles.desc}>{renderText(lang('PremiumReadText1', userName), ['simple_markdown'])}</p>
|
{lang(isReadDate ? 'PremiumReadHeader1' : 'PremiumLastSeenHeader1')}
|
||||||
|
</h2>
|
||||||
|
<p className={styles.desc}>
|
||||||
|
{renderText(
|
||||||
|
lang(
|
||||||
|
isReadDate ? 'PremiumReadText1' : 'PremiumLastSeenText1Locked',
|
||||||
|
userName,
|
||||||
|
),
|
||||||
|
['simple_markdown'],
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
<Button
|
<Button
|
||||||
size="smaller"
|
size="smaller"
|
||||||
onClick={handleShowReadTime}
|
onClick={isReadDate ? handleShowReadTime : handleShowLastSeen}
|
||||||
className={styles.button}
|
className={styles.button}
|
||||||
>
|
>
|
||||||
{lang('PremiumReadButton1')}
|
{lang(isReadDate ? 'PremiumReadButton1' : 'PremiumLastSeenButton1')}
|
||||||
</Button>
|
</Button>
|
||||||
<Separator className={styles.separator}>{lang('PremiumOr')}</Separator>
|
<Separator className={styles.separator}>{lang('PremiumOr')}</Separator>
|
||||||
<h2 className={styles.header}>{lang('PremiumReadHeader2')}</h2>
|
<h2 className={styles.header}>{lang('PremiumReadHeader2')}</h2>
|
||||||
<p className={styles.desc}>{renderText(lang('PremiumReadText2', userName), ['simple_markdown'])}</p>
|
<p className={styles.desc}>
|
||||||
<Button withPremiumGradient size="smaller" onClick={handleOpenPremium} className={styles.button}>
|
{renderText(
|
||||||
|
lang(isReadDate ? 'PremiumReadText2' : 'PremiumLastSeenText2', userName),
|
||||||
|
['simple_markdown'],
|
||||||
|
)}
|
||||||
|
</p>
|
||||||
|
<Button
|
||||||
|
withPremiumGradient
|
||||||
|
size="smaller"
|
||||||
|
onClick={handleOpenPremium}
|
||||||
|
className={styles.button}
|
||||||
|
>
|
||||||
{lang('PremiumLastSeenButton2')}
|
{lang('PremiumLastSeenButton2')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@ -98,11 +137,11 @@ const ReadDateModal = ({ isOpen, user }: OwnProps & StateProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default memo(withGlobal<OwnProps>(
|
export default memo(
|
||||||
(global): StateProps => {
|
withGlobal<OwnProps>((global): StateProps => {
|
||||||
const { chatId } = selectTabState(global).readDateModal || {};
|
const { chatId, isReadDate } = selectTabState(global).privacySettingsNoticeModal || {};
|
||||||
const user = chatId ? selectUser(global, chatId) : undefined;
|
const user = chatId ? selectUser(global, chatId) : undefined;
|
||||||
|
|
||||||
return { user };
|
return { user, isReadDate };
|
||||||
},
|
})(PrivacySettingsNoticeModal),
|
||||||
)(ReadDateModal));
|
);
|
||||||
@ -48,4 +48,14 @@
|
|||||||
pointer-events: auto;
|
pointer-events: auto;
|
||||||
cursor: var(--custom-cursor, pointer);
|
cursor: var(--custom-cursor, pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.get-status {
|
||||||
|
cursor: var(--custom-cursor, pointer);
|
||||||
|
margin-left: 0.375rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.125rem 0.375rem;
|
||||||
|
background: var(--color-background-menu-separator);
|
||||||
|
pointer-events: all;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -90,6 +90,7 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
openMediaViewer,
|
openMediaViewer,
|
||||||
openPremiumModal,
|
openPremiumModal,
|
||||||
openStickerSet,
|
openStickerSet,
|
||||||
|
openPrivacySettingsNoticeModal,
|
||||||
} = getActions();
|
} = getActions();
|
||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
@ -173,6 +174,10 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
setCurrentPhotoIndex(currentPhotoIndex + 1);
|
setCurrentPhotoIndex(currentPhotoIndex + 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const handleOpenGetReadDateModal = useLastCallback(() => {
|
||||||
|
openPrivacySettingsNoticeModal({ chatId: chat!.id, isReadDate: false });
|
||||||
|
});
|
||||||
|
|
||||||
function handleSelectFallbackPhoto() {
|
function handleSelectFallbackPhoto() {
|
||||||
if (!isFirst) return;
|
if (!isFirst) return;
|
||||||
setHasSlideAnimation(true);
|
setHasSlideAnimation(true);
|
||||||
@ -264,8 +269,21 @@ const ProfileInfo: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
if (user) {
|
if (user) {
|
||||||
return (
|
return (
|
||||||
<div className={buildClassName(styles.status, 'status', isUserOnline(user, userStatus) && 'online')}>
|
<div
|
||||||
<span className="user-status" dir="auto">{getUserStatus(lang, user, userStatus)}</span>
|
className={buildClassName(
|
||||||
|
styles.status,
|
||||||
|
'status',
|
||||||
|
isUserOnline(user, userStatus) && 'online',
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<span className="user-status" dir="auto">
|
||||||
|
{getUserStatus(lang, user, userStatus)}
|
||||||
|
</span>
|
||||||
|
{userStatus?.isReadDateRestrictedByMe && (
|
||||||
|
<span className="get-status" onClick={handleOpenGetReadDateModal}>
|
||||||
|
{lang('StatusHiddenShow')}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +0,0 @@
|
|||||||
import type { FC } from '../../lib/teact/teact';
|
|
||||||
import React from '../../lib/teact/teact';
|
|
||||||
|
|
||||||
import type { OwnProps } from './ReadDateModal';
|
|
||||||
|
|
||||||
import { Bundles } from '../../util/moduleLoader';
|
|
||||||
|
|
||||||
import useModuleLoader from '../../hooks/useModuleLoader';
|
|
||||||
|
|
||||||
const ReadTimeModalAsync: FC<OwnProps> = (props) => {
|
|
||||||
const { isOpen } = props;
|
|
||||||
const ReadTimeModal = useModuleLoader(Bundles.Extra, 'ReadTimeModal', !isOpen);
|
|
||||||
|
|
||||||
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
||||||
return ReadTimeModal ? <ReadTimeModal {...props} /> : undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default ReadTimeModalAsync;
|
|
||||||
@ -11,6 +11,7 @@ import Flame from '../../../assets/tgs/general/Flame.tgs';
|
|||||||
import PartyPopper from '../../../assets/tgs/general/PartyPopper.tgs';
|
import PartyPopper from '../../../assets/tgs/general/PartyPopper.tgs';
|
||||||
import Invite from '../../../assets/tgs/invites/Invite.tgs';
|
import Invite from '../../../assets/tgs/invites/Invite.tgs';
|
||||||
import JoinRequest from '../../../assets/tgs/invites/Requests.tgs';
|
import JoinRequest from '../../../assets/tgs/invites/Requests.tgs';
|
||||||
|
import LastSeen from '../../../assets/tgs/LastSeen.tgs';
|
||||||
import MonkeyClose from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyClose.tgs';
|
import MonkeyClose from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyClose.tgs';
|
||||||
import MonkeyIdle from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyIdle.tgs';
|
import MonkeyIdle from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyIdle.tgs';
|
||||||
import MonkeyPeek from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyPeek.tgs';
|
import MonkeyPeek from '../../../assets/tgs/monkeys/TwoFactorSetupMonkeyPeek.tgs';
|
||||||
@ -52,4 +53,5 @@ export const LOCAL_TGS_URLS = {
|
|||||||
Flame,
|
Flame,
|
||||||
ReadTime,
|
ReadTime,
|
||||||
Unlock,
|
Unlock,
|
||||||
|
LastSeen,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -79,7 +79,7 @@ import useWindowSize from '../../hooks/window/useWindowSize';
|
|||||||
import usePinnedMessage from './hooks/usePinnedMessage';
|
import usePinnedMessage from './hooks/usePinnedMessage';
|
||||||
|
|
||||||
import Composer from '../common/Composer';
|
import Composer from '../common/Composer';
|
||||||
import ReadTimeModal from '../common/ReadTimeModal.async';
|
import PrivacySettingsNoticeModal from '../common/PrivacySettingsNoticeModal.async';
|
||||||
import SeenByModal from '../common/SeenByModal.async';
|
import SeenByModal from '../common/SeenByModal.async';
|
||||||
import UnpinAllMessagesModal from '../common/UnpinAllMessagesModal.async';
|
import UnpinAllMessagesModal from '../common/UnpinAllMessagesModal.async';
|
||||||
import GiftPremiumModal from '../main/premium/GiftPremiumModal.async';
|
import GiftPremiumModal from '../main/premium/GiftPremiumModal.async';
|
||||||
@ -131,7 +131,7 @@ type StateProps = {
|
|||||||
hasCurrentTextSearch?: boolean;
|
hasCurrentTextSearch?: boolean;
|
||||||
isSelectModeActive?: boolean;
|
isSelectModeActive?: boolean;
|
||||||
isSeenByModalOpen: boolean;
|
isSeenByModalOpen: boolean;
|
||||||
isReadDateModalOpen: boolean;
|
isPrivacySettingsNoticeModalOpen: boolean;
|
||||||
isReactorListModalOpen: boolean;
|
isReactorListModalOpen: boolean;
|
||||||
isGiftPremiumModalOpen?: boolean;
|
isGiftPremiumModalOpen?: boolean;
|
||||||
isChatLanguageModalOpen?: boolean;
|
isChatLanguageModalOpen?: boolean;
|
||||||
@ -191,7 +191,7 @@ function MiddleColumn({
|
|||||||
hasCurrentTextSearch,
|
hasCurrentTextSearch,
|
||||||
isSelectModeActive,
|
isSelectModeActive,
|
||||||
isSeenByModalOpen,
|
isSeenByModalOpen,
|
||||||
isReadDateModalOpen,
|
isPrivacySettingsNoticeModalOpen,
|
||||||
isReactorListModalOpen,
|
isReactorListModalOpen,
|
||||||
isGiftPremiumModalOpen,
|
isGiftPremiumModalOpen,
|
||||||
isChatLanguageModalOpen,
|
isChatLanguageModalOpen,
|
||||||
@ -686,7 +686,7 @@ function MiddleColumn({
|
|||||||
canPost={renderingCanPost}
|
canPost={renderingCanPost}
|
||||||
/>
|
/>
|
||||||
<SeenByModal isOpen={isSeenByModalOpen} />
|
<SeenByModal isOpen={isSeenByModalOpen} />
|
||||||
<ReadTimeModal isOpen={isReadDateModalOpen} />
|
<PrivacySettingsNoticeModal isOpen={isPrivacySettingsNoticeModalOpen} />
|
||||||
<ReactorListModal isOpen={isReactorListModalOpen} />
|
<ReactorListModal isOpen={isReactorListModalOpen} />
|
||||||
{IS_TRANSLATION_SUPPORTED && <ChatLanguageModal isOpen={isChatLanguageModalOpen} />}
|
{IS_TRANSLATION_SUPPORTED && <ChatLanguageModal isOpen={isChatLanguageModalOpen} />}
|
||||||
</div>
|
</div>
|
||||||
@ -734,7 +734,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
const {
|
const {
|
||||||
messageLists, isLeftColumnShown, activeEmojiInteractions,
|
messageLists, isLeftColumnShown, activeEmojiInteractions,
|
||||||
seenByModal, giftPremiumModal, reactorModal, audioPlayer, shouldSkipHistoryAnimations,
|
seenByModal, giftPremiumModal, reactorModal, audioPlayer, shouldSkipHistoryAnimations,
|
||||||
chatLanguageModal, readDateModal,
|
chatLanguageModal, privacySettingsNoticeModal,
|
||||||
} = selectTabState(global);
|
} = selectTabState(global);
|
||||||
const currentMessageList = selectCurrentMessageList(global);
|
const currentMessageList = selectCurrentMessageList(global);
|
||||||
const { leftColumnWidth } = global;
|
const { leftColumnWidth } = global;
|
||||||
@ -750,7 +750,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
hasCurrentTextSearch: Boolean(selectCurrentTextSearch(global)),
|
hasCurrentTextSearch: Boolean(selectCurrentTextSearch(global)),
|
||||||
isSelectModeActive: selectIsInSelectMode(global),
|
isSelectModeActive: selectIsInSelectMode(global),
|
||||||
isSeenByModalOpen: Boolean(seenByModal),
|
isSeenByModalOpen: Boolean(seenByModal),
|
||||||
isReadDateModalOpen: Boolean(readDateModal),
|
isPrivacySettingsNoticeModalOpen: Boolean(privacySettingsNoticeModal),
|
||||||
isReactorListModalOpen: Boolean(reactorModal),
|
isReactorListModalOpen: Boolean(reactorModal),
|
||||||
isGiftPremiumModalOpen: giftPremiumModal?.isOpen,
|
isGiftPremiumModalOpen: giftPremiumModal?.isOpen,
|
||||||
isChatLanguageModalOpen: Boolean(chatLanguageModal),
|
isChatLanguageModalOpen: Boolean(chatLanguageModal),
|
||||||
|
|||||||
@ -25,14 +25,14 @@ type OwnProps = {
|
|||||||
function ReadTimeMenuItem({
|
function ReadTimeMenuItem({
|
||||||
message, shouldRenderShowWhen, canLoadReadDate, closeContextMenu, menuSeparatorSize,
|
message, shouldRenderShowWhen, canLoadReadDate, closeContextMenu, menuSeparatorSize,
|
||||||
}: OwnProps) {
|
}: OwnProps) {
|
||||||
const { openGetReadDateModal } = getActions();
|
const { openPrivacySettingsNoticeModal } = getActions();
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
const { readDate } = message;
|
const { readDate } = message;
|
||||||
const shouldRenderSkeleton = canLoadReadDate && !readDate && !shouldRenderShowWhen;
|
const shouldRenderSkeleton = canLoadReadDate && !readDate && !shouldRenderShowWhen;
|
||||||
|
|
||||||
const handleOpenModal = () => {
|
const handleOpenModal = () => {
|
||||||
closeContextMenu();
|
closeContextMenu();
|
||||||
openGetReadDateModal({ chatId: message.chatId, messageId: message.id });
|
openPrivacySettingsNoticeModal({ chatId: message.chatId, isReadDate: true });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -470,7 +470,28 @@ addActionHandler('loadPrivacySettings', async (global): Promise<void> => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('setPrivacyVisibility', async (global, actions, payload): Promise<void> => {
|
addActionHandler('setPrivacyVisibility', async (global, actions, payload): Promise<void> => {
|
||||||
const { privacyKey, visibility } = payload!;
|
const { privacyKey, visibility, onSuccess } = payload!;
|
||||||
|
|
||||||
|
if (!global.settings.privacy[privacyKey]) {
|
||||||
|
const result = await callApi('fetchPrivacySettings', privacyKey);
|
||||||
|
if (!result) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
global = getGlobal();
|
||||||
|
global = addUsers(global, buildCollectionByKey(result.users, 'id'));
|
||||||
|
global = {
|
||||||
|
...global,
|
||||||
|
settings: {
|
||||||
|
...global.settings,
|
||||||
|
privacy: {
|
||||||
|
...global.settings.privacy,
|
||||||
|
[privacyKey]: result.rules,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
setGlobal(global);
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
privacy: { [privacyKey]: settings },
|
privacy: { [privacyKey]: settings },
|
||||||
@ -491,6 +512,8 @@ addActionHandler('setPrivacyVisibility', async (global, actions, payload): Promi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSuccess?.();
|
||||||
|
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = addUsers(global, buildCollectionByKey(result.users, 'id'));
|
global = addUsers(global, buildCollectionByKey(result.users, 'id'));
|
||||||
global = {
|
global = {
|
||||||
|
|||||||
@ -781,19 +781,19 @@ addActionHandler('closeSeenByModal', (global, actions, payload): ActionReturnTyp
|
|||||||
}, tabId);
|
}, tabId);
|
||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('openGetReadDateModal', (global, actions, payload): ActionReturnType => {
|
addActionHandler('openPrivacySettingsNoticeModal', (global, actions, payload): ActionReturnType => {
|
||||||
const { chatId, messageId, tabId = getCurrentTabId() } = payload;
|
const { chatId, isReadDate, tabId = getCurrentTabId() } = payload;
|
||||||
|
|
||||||
return updateTabState(global, {
|
return updateTabState(global, {
|
||||||
readDateModal: { chatId, messageId },
|
privacySettingsNoticeModal: { chatId, isReadDate },
|
||||||
}, tabId);
|
}, tabId);
|
||||||
});
|
});
|
||||||
|
|
||||||
addActionHandler('closeGetReadDateModal', (global, actions, payload): ActionReturnType => {
|
addActionHandler('closePrivacySettingsNoticeModal', (global, actions, payload): ActionReturnType => {
|
||||||
const { tabId = getCurrentTabId() } = payload || {};
|
const { tabId = getCurrentTabId() } = payload || {};
|
||||||
|
|
||||||
return updateTabState(global, {
|
return updateTabState(global, {
|
||||||
readDateModal: undefined,
|
privacySettingsNoticeModal: undefined,
|
||||||
}, tabId);
|
}, tabId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -292,9 +292,9 @@ export type TabState = {
|
|||||||
messageId: number;
|
messageId: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
readDateModal?: {
|
privacySettingsNoticeModal?: {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
messageId: number;
|
isReadDate: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
reactorModal?: {
|
reactorModal?: {
|
||||||
@ -1170,6 +1170,7 @@ export interface ActionPayloads {
|
|||||||
setPrivacyVisibility: {
|
setPrivacyVisibility: {
|
||||||
privacyKey: ApiPrivacyKey;
|
privacyKey: ApiPrivacyKey;
|
||||||
visibility: PrivacyVisibility;
|
visibility: PrivacyVisibility;
|
||||||
|
onSuccess?: VoidFunction;
|
||||||
};
|
};
|
||||||
|
|
||||||
setPrivacySettings: {
|
setPrivacySettings: {
|
||||||
@ -1632,11 +1633,11 @@ export interface ActionPayloads {
|
|||||||
messageId: number;
|
messageId: number;
|
||||||
} & WithTabId;
|
} & WithTabId;
|
||||||
closeSeenByModal: WithTabId | undefined;
|
closeSeenByModal: WithTabId | undefined;
|
||||||
openGetReadDateModal: {
|
openPrivacySettingsNoticeModal: {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
messageId: number;
|
isReadDate: boolean;
|
||||||
} & WithTabId;
|
} & WithTabId;
|
||||||
closeGetReadDateModal: WithTabId | undefined;
|
closePrivacySettingsNoticeModal: WithTabId | undefined;
|
||||||
closeReactorListModal: WithTabId | undefined;
|
closeReactorListModal: WithTabId | undefined;
|
||||||
openReactorListModal: {
|
openReactorListModal: {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user