getTotalUnreadForConversation: Add missing isGroup parameter
This commit is contained in:
parent
075b968cbc
commit
00f770c3c4
|
@ -4672,7 +4672,8 @@ export class ConversationModel extends window.Backbone
|
||||||
await markConversationRead(this.attributes, newestUnreadAt, options);
|
await markConversationRead(this.attributes, newestUnreadAt, options);
|
||||||
|
|
||||||
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
|
const unreadCount = await window.Signal.Data.getTotalUnreadForConversation(
|
||||||
this.id
|
this.id,
|
||||||
|
{ storyId: undefined, isGroup: isGroup(this.attributes) }
|
||||||
);
|
);
|
||||||
|
|
||||||
const prevUnreadCount = this.get('unreadCount');
|
const prevUnreadCount = this.get('unreadCount');
|
||||||
|
|
|
@ -1170,9 +1170,12 @@ async function getMessageBySender({
|
||||||
|
|
||||||
async function getTotalUnreadForConversation(
|
async function getTotalUnreadForConversation(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
storyId?: UUIDStringType
|
options: {
|
||||||
|
storyId: UUIDStringType | undefined;
|
||||||
|
isGroup: boolean;
|
||||||
|
}
|
||||||
) {
|
) {
|
||||||
return channels.getTotalUnreadForConversation(conversationId, storyId);
|
return channels.getTotalUnreadForConversation(conversationId, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUnreadByConversationAndMarkRead(options: {
|
async function getUnreadByConversationAndMarkRead(options: {
|
||||||
|
|
|
@ -384,7 +384,10 @@ export type DataInterface = {
|
||||||
removeMessages: (ids: Array<string>) => Promise<void>;
|
removeMessages: (ids: Array<string>) => Promise<void>;
|
||||||
getTotalUnreadForConversation: (
|
getTotalUnreadForConversation: (
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
storyId?: UUIDStringType
|
options: {
|
||||||
|
storyId: UUIDStringType | undefined;
|
||||||
|
isGroup: boolean;
|
||||||
|
}
|
||||||
) => Promise<number>;
|
) => Promise<number>;
|
||||||
getUnreadByConversationAndMarkRead: (options: {
|
getUnreadByConversationAndMarkRead: (options: {
|
||||||
conversationId: string;
|
conversationId: string;
|
||||||
|
|
|
@ -2676,14 +2676,22 @@ function getOldestUnreadMessageForConversation(
|
||||||
|
|
||||||
async function getTotalUnreadForConversation(
|
async function getTotalUnreadForConversation(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
storyId?: UUIDStringType
|
options: {
|
||||||
|
storyId: UUIDStringType | undefined;
|
||||||
|
isGroup: boolean;
|
||||||
|
}
|
||||||
): Promise<number> {
|
): Promise<number> {
|
||||||
return getTotalUnreadForConversationSync(conversationId, storyId);
|
return getTotalUnreadForConversationSync(conversationId, options);
|
||||||
}
|
}
|
||||||
function getTotalUnreadForConversationSync(
|
function getTotalUnreadForConversationSync(
|
||||||
conversationId: string,
|
conversationId: string,
|
||||||
storyId?: UUIDStringType,
|
{
|
||||||
isGroup?: boolean
|
storyId,
|
||||||
|
isGroup,
|
||||||
|
}: {
|
||||||
|
storyId: UUIDStringType | undefined;
|
||||||
|
isGroup: boolean;
|
||||||
|
}
|
||||||
): number {
|
): number {
|
||||||
const db = getInstance();
|
const db = getInstance();
|
||||||
const row = db
|
const row = db
|
||||||
|
@ -2737,11 +2745,10 @@ function getMessageMetricsForConversationSync(
|
||||||
storyId,
|
storyId,
|
||||||
isGroup
|
isGroup
|
||||||
);
|
);
|
||||||
const totalUnread = getTotalUnreadForConversationSync(
|
const totalUnread = getTotalUnreadForConversationSync(conversationId, {
|
||||||
conversationId,
|
|
||||||
storyId,
|
storyId,
|
||||||
isGroup
|
isGroup: Boolean(isGroup),
|
||||||
);
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
oldest: oldest ? pick(oldest, ['received_at', 'sent_at', 'id']) : undefined,
|
oldest: oldest ? pick(oldest, ['received_at', 'sent_at', 'id']) : undefined,
|
||||||
|
|
|
@ -124,7 +124,10 @@ describe('sql/markRead', () => {
|
||||||
|
|
||||||
assert.lengthOf(await _getAllMessages(), 7);
|
assert.lengthOf(await _getAllMessages(), 7);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
await getTotalUnreadForConversation(conversationId),
|
await getTotalUnreadForConversation(conversationId, {
|
||||||
|
storyId: undefined,
|
||||||
|
isGroup: false,
|
||||||
|
}),
|
||||||
4,
|
4,
|
||||||
'unread count'
|
'unread count'
|
||||||
);
|
);
|
||||||
|
@ -137,7 +140,10 @@ describe('sql/markRead', () => {
|
||||||
|
|
||||||
assert.lengthOf(markedRead, 2, 'two messages marked read');
|
assert.lengthOf(markedRead, 2, 'two messages marked read');
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
await getTotalUnreadForConversation(conversationId),
|
await getTotalUnreadForConversation(conversationId, {
|
||||||
|
storyId: undefined,
|
||||||
|
isGroup: false,
|
||||||
|
}),
|
||||||
2,
|
2,
|
||||||
'unread count'
|
'unread count'
|
||||||
);
|
);
|
||||||
|
@ -164,7 +170,10 @@ describe('sql/markRead', () => {
|
||||||
assert.strictEqual(markedRead2[0].id, message7.id, 'should be message7');
|
assert.strictEqual(markedRead2[0].id, message7.id, 'should be message7');
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
await getTotalUnreadForConversation(conversationId),
|
await getTotalUnreadForConversation(conversationId, {
|
||||||
|
storyId: undefined,
|
||||||
|
isGroup: false,
|
||||||
|
}),
|
||||||
0,
|
0,
|
||||||
'unread count'
|
'unread count'
|
||||||
);
|
);
|
||||||
|
@ -365,7 +374,10 @@ describe('sql/markRead', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
await getTotalUnreadForConversation(conversationId),
|
await getTotalUnreadForConversation(conversationId, {
|
||||||
|
storyId: undefined,
|
||||||
|
isGroup: false,
|
||||||
|
}),
|
||||||
2,
|
2,
|
||||||
'unread count'
|
'unread count'
|
||||||
);
|
);
|
||||||
|
@ -384,7 +396,10 @@ describe('sql/markRead', () => {
|
||||||
'first should be message4'
|
'first should be message4'
|
||||||
);
|
);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
await getTotalUnreadForConversation(conversationId),
|
await getTotalUnreadForConversation(conversationId, {
|
||||||
|
storyId: undefined,
|
||||||
|
isGroup: false,
|
||||||
|
}),
|
||||||
1,
|
1,
|
||||||
'unread count'
|
'unread count'
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue