chats now have ids

This commit is contained in:
Daniel Lugo 2020-01-28 16:57:02 -04:00
parent 9a9185f560
commit e0fe2e96ba
2 changed files with 10 additions and 2 deletions

View file

@ -586,7 +586,8 @@ const onChats = (cb, gun, user, SEA) => {
recipientAvatar: '',
recipientDisplayName: Utils.defaultName(recipientPK),
recipientPublicKey: recipientPK,
didDisconnect
didDisconnect,
id: recipientPK + incomingID
}
}
@ -625,7 +626,8 @@ const onChats = (cb, gun, user, SEA) => {
recipientAvatar: '',
recipientDisplayName: Utils.defaultName(recipientPK),
recipientPublicKey: recipientPK,
didDisconnect
didDisconnect,
id: recipientPK + incomingFeedID
}
}

View file

@ -65,6 +65,8 @@ exports.isChatMessage = item => {
* outgoing/incoming feed paradigm. It combines both the outgoing and incoming
* messages into one data structure plus metada about the chat.
* @typedef {object} Chat
* @prop {string} id Chats now have IDs because of disconnect.
* RecipientPublicKey will no longer be unique.
* @prop {string|null} recipientAvatar Base64 encoded image.
* @prop {string} recipientPublicKey A way to uniquely identify each chat.
* @prop {ChatMessage[]} messages Sorted from most recent to least recent.
@ -107,6 +109,10 @@ exports.isChat = item => {
return false
}
if (typeof obj.id !== 'string') {
return false
}
return obj.messages.every(msg => exports.isChatMessage(msg))
}