telegram-tt
telegram-tt copied to clipboard
fix: pinned chats are toggled as selected when editing folder
there is currently a bug
- create a folder
- add some chats
- pin some of added chats inside that folder
- open edit folder screen -> included chats Expected: Pinned chats are marked as selected as well as unpinned Current: Pinned chats are marked as unselected and can be "added" to the folder
proposed changes in this PR address that by modifying 'selectChatFilters' selector and 'editChatFolders' action handler
side-note: i understand that pinned chat ids are not stored as a subset of included chat ids during initial API fetches for the purposes of ordering during render
Unfortunately, there is a bug in the implementation. Try opening the folder edit screen -> Included Chats -> click Add Chats and try removing the locked chats from the list above the search bar.
https://github.com/Ajaxy/telegram-tt/assets/285244/3f28dcef-6fa5-4416-b486-ac7ce35d47de
@korenskoy thank you for pointing this out. i followed your guide and reproduced the behavior
i did a quick research and discovered the root of the issue:
- when removing chats by clicking above the search bar a new list of selected ids is constructed either by splicing or appending the old one
- this new array of selected ids is directed into the folder reducer, where all concatted ids are assigned to the "includedChatIds" field, which is not correct because they also contain "pinnedChatIds" (which remain the same)
what i did is:
- when updating included chats i "deconstruct" new passed selected ids into 2 separate arrays: new included ids and new pinned ids
this fixes the behavior you showed in the video, but i do not particularly like what i'm doing here - this solution is an attempt to keep up with the separation of folder chats into included and pinned