Premium Limit Reached Modal: Fix description for cloud folders (#3322)
This commit is contained in:
parent
e616f82639
commit
a136a66e61
@ -45,6 +45,7 @@ type StateProps = {
|
|||||||
currentUserId?: string;
|
currentUserId?: string;
|
||||||
shouldSkipHistoryAnimations?: boolean;
|
shouldSkipHistoryAnimations?: boolean;
|
||||||
maxFolders: number;
|
maxFolders: number;
|
||||||
|
maxChatLists: number;
|
||||||
maxFolderInvites: number;
|
maxFolderInvites: number;
|
||||||
hasArchivedChats?: boolean;
|
hasArchivedChats?: boolean;
|
||||||
archiveSettings: GlobalState['archiveSettings'];
|
archiveSettings: GlobalState['archiveSettings'];
|
||||||
@ -64,6 +65,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
isForumPanelOpen,
|
isForumPanelOpen,
|
||||||
shouldSkipHistoryAnimations,
|
shouldSkipHistoryAnimations,
|
||||||
maxFolders,
|
maxFolders,
|
||||||
|
maxChatLists,
|
||||||
shouldHideFolderTabs,
|
shouldHideFolderTabs,
|
||||||
folderInvitesById,
|
folderInvitesById,
|
||||||
maxFolderInvites,
|
maxFolderInvites,
|
||||||
@ -134,16 +136,25 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
title: lang('ChatList.ContextMenuShare'),
|
title: lang('ChatList.ContextMenuShare'),
|
||||||
icon: 'link',
|
icon: 'link',
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
const chatListCount = Object.values(chatFoldersById).reduce((acc, el) => acc + (el.isChatList ? 1 : 0), 0);
|
||||||
|
if (chatListCount >= maxChatLists && !folder.isChatList) {
|
||||||
|
openLimitReachedModal({
|
||||||
|
limit: 'chatlistJoined',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Greater amount can be after premium downgrade
|
// Greater amount can be after premium downgrade
|
||||||
if (folderInvitesById[id]?.length >= maxFolderInvites) {
|
if (folderInvitesById[id]?.length >= maxFolderInvites) {
|
||||||
openLimitReachedModal({
|
openLimitReachedModal({
|
||||||
limit: 'chatlistInvites',
|
limit: 'chatlistInvites',
|
||||||
});
|
});
|
||||||
} else {
|
return;
|
||||||
openShareChatFolderModal({
|
|
||||||
folderId: id,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openShareChatFolderModal({
|
||||||
|
folderId: id,
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -176,7 +187,10 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
contextActions: contextActions?.length ? contextActions : undefined,
|
contextActions: contextActions?.length ? contextActions : undefined,
|
||||||
} satisfies TabWithProperties;
|
} satisfies TabWithProperties;
|
||||||
});
|
});
|
||||||
}, [displayedFolders, folderCountersById, lang, maxFolders, folderInvitesById, maxFolderInvites]);
|
}, [
|
||||||
|
displayedFolders, maxFolders, folderCountersById, lang, chatFoldersById, maxChatLists, folderInvitesById,
|
||||||
|
maxFolderInvites,
|
||||||
|
]);
|
||||||
|
|
||||||
const handleSwitchTab = useLastCallback((index: number) => {
|
const handleSwitchTab = useLastCallback((index: number) => {
|
||||||
setActiveChatFolder({ activeChatFolder: index }, { forceOnHeavyAnimation: true });
|
setActiveChatFolder({ activeChatFolder: index }, { forceOnHeavyAnimation: true });
|
||||||
@ -340,6 +354,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
hasArchivedChats: Boolean(archived?.length),
|
hasArchivedChats: Boolean(archived?.length),
|
||||||
maxFolders: selectCurrentLimit(global, 'dialogFilters'),
|
maxFolders: selectCurrentLimit(global, 'dialogFilters'),
|
||||||
maxFolderInvites: selectCurrentLimit(global, 'chatlistInvites'),
|
maxFolderInvites: selectCurrentLimit(global, 'chatlistInvites'),
|
||||||
|
maxChatLists: selectCurrentLimit(global, 'chatlistJoined'),
|
||||||
archiveSettings,
|
archiveSettings,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -54,6 +54,8 @@ type StateProps = {
|
|||||||
invites?: ApiChatlistExportedInvite[];
|
invites?: ApiChatlistExportedInvite[];
|
||||||
isRemoved?: boolean;
|
isRemoved?: boolean;
|
||||||
maxInviteLinks: number;
|
maxInviteLinks: number;
|
||||||
|
maxChatLists: number;
|
||||||
|
chatListCount: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SUBMIT_TIMEOUT = 500;
|
const SUBMIT_TIMEOUT = 500;
|
||||||
@ -79,6 +81,8 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
|
|||||||
loadedArchivedChatIds,
|
loadedArchivedChatIds,
|
||||||
invites,
|
invites,
|
||||||
maxInviteLinks,
|
maxInviteLinks,
|
||||||
|
maxChatLists,
|
||||||
|
chatListCount,
|
||||||
onSaveFolder,
|
onSaveFolder,
|
||||||
}) => {
|
}) => {
|
||||||
const {
|
const {
|
||||||
@ -178,19 +182,28 @@ const SettingsFoldersEdit: FC<OwnProps & StateProps> = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (chatListCount >= maxChatLists && !state.folder.isChatList) {
|
||||||
|
openLimitReachedModal({
|
||||||
|
limit: 'chatlistJoined',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (invites.length < maxInviteLinks) {
|
if (invites.length < maxInviteLinks) {
|
||||||
if (state.isTouched) {
|
if (state.isTouched) {
|
||||||
onSaveFolder(onShareFolder);
|
onSaveFolder(onShareFolder);
|
||||||
} else {
|
} else {
|
||||||
onShareFolder();
|
onShareFolder();
|
||||||
}
|
}
|
||||||
} else {
|
return;
|
||||||
openLimitReachedModal({
|
|
||||||
limit: 'chatlistInvites',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openLimitReachedModal({
|
||||||
|
limit: 'chatlistInvites',
|
||||||
|
});
|
||||||
}, [
|
}, [
|
||||||
invites, state.folderId, state.isTouched, maxInviteLinks, isCreating, onSaveFolder, onShareFolder, lang,
|
invites, state.folderId, state.isTouched, chatListCount, maxInviteLinks, isCreating, onSaveFolder,
|
||||||
|
onShareFolder, lang, maxChatLists, state.folder.isChatList,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const handleEditInviteClick = useCallback((e: React.MouseEvent<HTMLElement>, url: string) => {
|
const handleEditInviteClick = useCallback((e: React.MouseEvent<HTMLElement>, url: string) => {
|
||||||
@ -378,6 +391,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
(global, { state }): StateProps => {
|
(global, { state }): StateProps => {
|
||||||
const { listIds } = global.chats;
|
const { listIds } = global.chats;
|
||||||
const { byId, invites } = global.chatFolders;
|
const { byId, invites } = global.chatFolders;
|
||||||
|
const chatListCount = Object.values(byId).reduce((acc, el) => acc + (el.isChatList ? 1 : 0), 0);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
loadedActiveChatIds: listIds.active,
|
loadedActiveChatIds: listIds.active,
|
||||||
@ -385,6 +399,8 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
invites: state.folderId ? (invites[state.folderId] || MEMO_EMPTY_ARRAY) : undefined,
|
invites: state.folderId ? (invites[state.folderId] || MEMO_EMPTY_ARRAY) : undefined,
|
||||||
isRemoved: state.folderId !== undefined && !byId[state.folderId],
|
isRemoved: state.folderId !== undefined && !byId[state.folderId],
|
||||||
maxInviteLinks: selectCurrentLimit(global, 'chatlistInvites'),
|
maxInviteLinks: selectCurrentLimit(global, 'chatlistInvites'),
|
||||||
|
maxChatLists: selectCurrentLimit(global, 'chatlistJoined'),
|
||||||
|
chatListCount,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
)(SettingsFoldersEdit));
|
)(SettingsFoldersEdit));
|
||||||
|
|||||||
@ -201,7 +201,6 @@ const PremiumLimitReachedModal: FC<OwnProps & StateProps> = ({
|
|||||||
color="primary"
|
color="primary"
|
||||||
>
|
>
|
||||||
{lang('IncreaseLimit')}
|
{lang('IncreaseLimit')}
|
||||||
<i className={buildClassName(styles.buttonIcon, 'icon', 'icon-double-badge')} />
|
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user