better handling of remote disconnection
This commit is contained in:
parent
a6ab80ac1e
commit
cf0100d105
2 changed files with 9 additions and 9 deletions
|
|
@ -414,7 +414,7 @@ const processChats = debounce(() => {
|
|||
/** @type {Chat} */
|
||||
const chat = {
|
||||
recipientPublicKey: out.with,
|
||||
didDisconnect: incoming === null,
|
||||
didDisconnect: pubToFeed[out.with] === 'disconnected',
|
||||
id: out.with + outID,
|
||||
messages: msgs,
|
||||
recipientAvatar: pubToAvatar[out.with] || null,
|
||||
|
|
@ -424,11 +424,11 @@ const processChats = debounce(() => {
|
|||
newChats.push(chat)
|
||||
}
|
||||
|
||||
currentChats = newChats.filter(
|
||||
c =>
|
||||
currentChats = newChats
|
||||
// initial state, means non connected
|
||||
typeof pubToFeed[c.recipientPublicKey] !== 'undefined'
|
||||
)
|
||||
.filter(c => typeof pubToFeed[c.recipientPublicKey] !== 'undefined')
|
||||
// disconnected from this side
|
||||
.filter(c => pubToFeed[c.recipientPublicKey] !== null)
|
||||
|
||||
notifyChatsListeners()
|
||||
}, 750)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const Utils = require('../utils')
|
|||
const PubToIncoming = require('./pubToIncoming')
|
||||
|
||||
/**
|
||||
* @typedef {Record<string, Message[]|null|undefined>} Feeds
|
||||
* @typedef {Record<string, Message[]|null|undefined|'disconnected'>} Feeds
|
||||
* @typedef {(feeds: Feeds) => void} FeedsListener
|
||||
*/
|
||||
|
||||
|
|
@ -88,14 +88,14 @@ const onOpenForPubFeedPair = ([pub, feed]) =>
|
|||
// detect remote disconnection
|
||||
setPubToFeed({
|
||||
...getPubToFeed(),
|
||||
[pub]: null
|
||||
[pub]: /** @type {'disconnected'} */ ('disconnected')
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const incoming = /** @type {Schema.Outgoing} */ (data)
|
||||
|
||||
// incomplete data
|
||||
// incomplete data, let's not assume anything
|
||||
if (
|
||||
typeof incoming.with !== 'string' ||
|
||||
typeof incoming.messages !== 'object'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue