This commit is contained in:
Anurag Shivarathri
2023-01-04 03:30:23 +05:30
committed by GitHub
parent 5ff22953ab
commit ed69eacbe7
6 changed files with 7 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ export default class MyChannelModel extends Model implements MyChannelModelInter
static associations: Associations = {
[CHANNEL]: {type: 'belongs_to', key: 'id'},
[CATEGORY_CHANNEL]: {type: 'has_many', foreignKey: 'channel_id'},
[MY_CHANNEL_SETTINGS]: {type: 'has_many', foreignKey: 'id'},
};
/** last_post_at : The timestamp for any last post on this channel */

View File

@@ -465,6 +465,7 @@ export function observeMyChannelMentionCount(database: Database, teamId?: string
Q.on(CHANNEL, Q.and(
...conditions,
)),
Q.on(MY_CHANNEL_SETTINGS, Q.where('notify_props', Q.notLike('%"mark_unread":"mention"%'))),
).
observeWithColumns(columns).
pipe(

View File

@@ -63,7 +63,7 @@ const Servers = React.forwardRef<ServersRef>((props, ref) => {
let unread = Boolean(threadUnreads);
for (const myChannel of myChannels) {
const isMuted = settings?.[myChannel.id]?.mark_unread === 'mention';
mentions += myChannel.mentionsCount;
mentions += isMuted ? 0 : myChannel.mentionsCount;
unread = unread || (myChannel.isUnread && !isMuted);
}

View File

@@ -171,7 +171,7 @@ const ServerItem = ({
let isUnread = Boolean(threadUnreads);
for (const myChannel of myChannels) {
const isMuted = settings?.[myChannel.id]?.mark_unread === 'mention';
mentions += myChannel.mentionsCount;
mentions += isMuted ? 0 : myChannel.mentionsCount;
isUnread = isUnread || (myChannel.isUnread && !isMuted);
}
mentions += threadMentionCount;

View File

@@ -71,7 +71,7 @@ const Home = ({isFocused, theme}: Props) => {
let unread = false;
for (const myChannel of myChannels) {
const isMuted = settings?.[myChannel.id]?.mark_unread === 'mention';
mentions += myChannel.mentionsCount;
mentions += isMuted ? 0 : myChannel.mentionsCount;
unread = unread || (myChannel.isUnread && !isMuted);
}

View File

@@ -38,8 +38,9 @@ extension Database {
let stmtString = """
SELECT SUM(my.mentions_count) \
FROM MyChannel my \
INNER JOIN MyChannelSettings mys ON mys.id=my.id \
INNER JOIN Channel c ON c.id=my.id \
WHERE c.delete_at = 0
WHERE c.delete_at = 0 AND mys.notify_props NOT LIKE '%"mark_unread":"mention"%'
"""
let mentions = try? db.prepare(stmtString).scalar() as? Double
return Int(mentions ?? 0)