Ajaxy / telegram-tt

Telegram Web A, GPL v3
https://web.telegram.org/a
GNU General Public License v3.0
2.2k stars 462 forks source link

fix: pinned chats are toggled as selected when editing folder #322

Open evgenii-minkov opened 7 months ago

evgenii-minkov commented 7 months ago

there is currently a bug

  1. create a folder
  2. add some chats
  3. pin some of added chats inside that folder
  4. 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

korenskoy commented 6 months ago

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

evgenii-minkov commented 6 months ago

@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:

  1. 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
  2. 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:

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