Fix hidden channels triggering the unread box

This commit is contained in:
Nuckyz 2023-10-26 20:59:48 -03:00
parent 8692109bc5
commit 1676956f61
No known key found for this signature in database
GPG Key ID: 440BF8296E1C4AD9

View File

@ -195,13 +195,29 @@ export default definePlugin({
]
},
{
// Hide New unreads box for hidden channels
// Hide the new version of unreads box for hidden channels
find: '.displayName="ChannelListUnreadsStore"',
replacement: {
match: /(?<=if\(null==(\i))(?=.{0,160}?hasRelevantUnread\(\i\))/g, // Global because Discord has multiple methods like that in the same module
replace: (_, channel) => `||$self.isHiddenChannel(${channel})`
}
},
{
// Make the old version of unreads box not visible for hidden channels
find: "renderBottomUnread(){",
replacement: {
match: /(?=&&\i\.\i\.hasRelevantUnread\((\i\.record)\))/,
replace: "&&!$self.isHiddenChannel($1)"
}
},
{
// Make the state of the old version of unreads box not include hidden channels
find: ".useFlattenedChannelIdListWithThreads)",
replacement: {
match: /(?=&&\i\.\i\.hasRelevantUnread\((\i)\))/,
replace: "&&!$self.isHiddenChannel($1)"
}
},
// Only render the channel header and buttons that work when transitioning to a hidden channel
{
find: "Missing channel in Channel.renderHeaderToolbar",