Fix duplicated folders; Hide redundant "Add to folder" item (#1596)
This commit is contained in:
parent
8ca0f72060
commit
4fe0aeb446
@ -63,8 +63,8 @@ const ChatFolderModal: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}, [folderOrderedIds, foldersById]);
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
const idsToRemove = initialSelectedFolderIds.filter((id) => !selectedFolderIds.includes(id));
|
||||
const idsToAdd = selectedFolderIds.filter((id) => !initialSelectedFolderIds.includes(id));
|
||||
const idsToRemove = initialSelectedFolderIds.filter((id) => !selectedFolderIds.includes(id)).map(Number);
|
||||
const idsToAdd = selectedFolderIds.filter((id) => !initialSelectedFolderIds.includes(id)).map(Number);
|
||||
|
||||
editChatFolders({ chatId, idsToRemove, idsToAdd });
|
||||
onClose();
|
||||
|
||||
@ -79,6 +79,7 @@ type StateProps = {
|
||||
animationLevel?: number;
|
||||
isSelected?: boolean;
|
||||
canScrollDown?: boolean;
|
||||
canChangeFolder?: boolean;
|
||||
lastSyncTime?: number;
|
||||
};
|
||||
|
||||
@ -107,6 +108,7 @@ const Chat: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
animationLevel,
|
||||
isSelected,
|
||||
canScrollDown,
|
||||
canChangeFolder,
|
||||
lastSyncTime,
|
||||
openChat,
|
||||
focusLastMessage,
|
||||
@ -204,6 +206,7 @@ const Chat: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
folderId,
|
||||
isPinned,
|
||||
isMuted,
|
||||
canChangeFolder,
|
||||
});
|
||||
|
||||
const lang = useLang();
|
||||
@ -377,6 +380,7 @@ export default memo(withGlobal<OwnProps>(
|
||||
animationLevel: global.settings.byKey.animationLevel,
|
||||
isSelected,
|
||||
canScrollDown: isSelected && messageListType === 'thread',
|
||||
canChangeFolder: Boolean(global.chatFolders.orderedIds),
|
||||
lastSyncTime: global.lastSyncTime,
|
||||
...(isOutgoing && { lastMessageOutgoingStatus: selectOutgoingStatus(global, chat.lastMessage) }),
|
||||
...(privateChatUserId && {
|
||||
|
||||
@ -17,6 +17,7 @@ export default ({
|
||||
folderId,
|
||||
isPinned,
|
||||
isMuted,
|
||||
canChangeFolder,
|
||||
}: {
|
||||
chat: ApiChat | undefined;
|
||||
user: ApiUser | undefined;
|
||||
@ -25,6 +26,7 @@ export default ({
|
||||
folderId?: number;
|
||||
isPinned?: boolean;
|
||||
isMuted?: boolean;
|
||||
canChangeFolder?: boolean;
|
||||
}, isInSearch = false) => {
|
||||
const lang = useLang();
|
||||
|
||||
@ -42,11 +44,11 @@ export default ({
|
||||
toggleChatUnread,
|
||||
} = getDispatch();
|
||||
|
||||
const actionAddToFolder = {
|
||||
const actionAddToFolder = canChangeFolder ? {
|
||||
title: lang('ChatList.Filter.AddToFolder'),
|
||||
icon: 'folder',
|
||||
handler: handleChatFolderChange,
|
||||
};
|
||||
} : undefined;
|
||||
|
||||
const actionPin = isPinned
|
||||
? {
|
||||
@ -57,7 +59,7 @@ export default ({
|
||||
: { title: lang('PinToTop'), icon: 'pin', handler: () => toggleChatPinned({ id: chat.id, folderId }) };
|
||||
|
||||
if (isInSearch) {
|
||||
return [actionPin, actionAddToFolder];
|
||||
return compact([actionPin, actionAddToFolder]);
|
||||
}
|
||||
|
||||
const actionUnreadMark = chat.unreadCount || chat.hasUnreadMark
|
||||
@ -101,5 +103,7 @@ export default ({
|
||||
!isSelf && !isInFolder && actionArchive,
|
||||
actionDelete,
|
||||
]);
|
||||
}, [chat, lang, handleChatFolderChange, isPinned, isInSearch, isMuted, handleDelete, folderId, isSelf]);
|
||||
}, [
|
||||
chat, canChangeFolder, lang, handleChatFolderChange, isPinned, isInSearch, isMuted, handleDelete, folderId, isSelf,
|
||||
]);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user