-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1125 from dm3-org/msg-lib-indicators
Msg indicators
- Loading branch information
Showing
15 changed files
with
393 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/messenger-widget/src/hooks/messages/renderer/messageTypes/renderReadOpened.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MessageIndicator, MessageModel } from '../../useMessage'; | ||
|
||
export const renderReadOpened = (messages: MessageModel[]) => { | ||
//We filter out all messages that are of type READ_OPENED | ||
const readOpenedMsgs = messages.filter( | ||
(message) => message.envelop.message.metadata.type === 'READ_OPENED', | ||
); | ||
|
||
const msgsWithoutReadType = messages.filter( | ||
(data) => data.envelop.message.metadata.type !== 'READ_OPENED', | ||
); | ||
|
||
//update indicator to the messages | ||
return msgsWithoutReadType.map((message) => { | ||
const openedMsg = readOpenedMsgs.find( | ||
(m) => | ||
m.envelop.message.metadata.referenceMessageHash === | ||
message.envelop.metadata?.encryptedMessageHash, | ||
); | ||
return { | ||
...message, | ||
indicator: openedMsg ? MessageIndicator.READED : message.indicator, | ||
}; | ||
}); | ||
}; |
27 changes: 27 additions & 0 deletions
27
packages/messenger-widget/src/hooks/messages/renderer/messageTypes/renderReadReceived.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { MessageIndicator, MessageModel } from '../../useMessage'; | ||
|
||
export const renderReadReceived = (messages: MessageModel[]) => { | ||
//We filter out all messages that are of type READ_RECEIVED | ||
const readReceivedMsgs = messages.filter( | ||
(message) => message.envelop.message.metadata.type === 'READ_RECEIVED', | ||
); | ||
|
||
const msgsWithoutReadType = messages.filter( | ||
(data) => data.envelop.message.metadata.type !== 'READ_RECEIVED', | ||
); | ||
|
||
//update indicator to the messages | ||
return msgsWithoutReadType.map((message) => { | ||
const receivedMsg = readReceivedMsgs.find( | ||
(m) => | ||
m.envelop.message.metadata.referenceMessageHash === | ||
message.envelop.metadata?.encryptedMessageHash, | ||
); | ||
return { | ||
...message, | ||
indicator: receivedMsg | ||
? MessageIndicator.RECEIVED | ||
: MessageIndicator.SENT, | ||
}; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.