增加私聊置顶和按设备统计未读
This commit is contained in:
1 parent
7e165ba9b4
commit
ec2679b991
19 files changed
+312
-52
No files matched your search
@@ -42,6 +42,7 @@ interface ChatState {
|
||||
engine: string
|
||||
cursor: string
|
||||
pending: Incoming[]
|
||||
received?: Record<string, string>
|
||||
outbox: Outgoing[]
|
||||
lines: ChatLine[]
|
||||
pinned: Record<string, string>
|
||||
@@ -331,6 +332,7 @@ export function setReadReceipts(identity: ChatIdentity, enabled: boolean) {
|
||||
|
||||
export function synchronize(identity: ChatIdentity, user: string, call: Call) {
|
||||
return update(identity, async (state, save, factory) => {
|
||||
const received = state.received ??= {}
|
||||
const peers = await directory(call, user)
|
||||
const peerIDs = new Set(peers.map((peer) => peer.id))
|
||||
let backfilled = false
|
||||
@@ -385,6 +387,7 @@ export function synchronize(identity: ChatIdentity, user: string, call: Call) {
|
||||
} finally {
|
||||
engine.free()
|
||||
}
|
||||
received[peer.id] = item.sequence
|
||||
state.pending = state.pending.filter((pending) => pending.sequence !== item.sequence)
|
||||
await save(state)
|
||||
}
|
||||
@@ -405,7 +408,7 @@ export function synchronize(identity: ChatIdentity, user: string, call: Call) {
|
||||
engine.free()
|
||||
}
|
||||
}
|
||||
return { lines: state.lines, pinned: state.pinned, peers, rejected: state.rejected, deliveryError, shareRead: state.shareRead === true,
|
||||
return { lines: state.lines, pinned: state.pinned, peers, rejected: state.rejected, deliveryError, received, shareRead: state.shareRead === true,
|
||||
unsent: state.outbox.map((item) => item.mutationTarget ?? item.messageId) }
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user