-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement retry option on message failure to send [FS-1571] #14757
Conversation
… non functional discard button for assets
quote: quoteEntity, | ||
messageId: messageId ? messageId : createRandomUuid(), // We set the id explicitely in order to be able to override the message if we generate a link preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
messageId: messageId ? messageId : createRandomUuid(), // We set the id explicitely in order to be able to override the message if we generate a link preview | |
messageId: messageId ?? createRandomUuid(), // We set the id explicitely in order to be able to override the message if we generate a link preview |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried to put a more appropriate comment too
Codecov Report
@@ Coverage Diff @@
## dev #14757 +/- ##
==========================================
- Coverage 42.85% 42.76% -0.10%
==========================================
Files 621 622 +1
Lines 21212 21265 +53
Branches 4868 4882 +14
==========================================
+ Hits 9090 9093 +3
- Misses 10965 11011 +46
- Partials 1157 1161 +4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super solid PR, Just one thing that is slightly misplace but overall great job @V-Gira
const mainViewModel = useMainViewModel(); | ||
const {content: contentViewModel} = mainViewModel; | ||
const {messageRepository} = contentViewModel; | ||
|
||
const handleRetrySending = async () => { | ||
const firstAsset = message.getFirstAsset(); | ||
|
||
if (firstAsset instanceof Text) { | ||
const messageId = message.id; | ||
const messageText = message.getFirstAsset().text; | ||
const mentions: MentionEntity[] = firstAsset.mentions() && firstAsset.mentions(); | ||
const incomingQuote = message.quote(); | ||
|
||
const isOutgoingQuote = (quoteEntity: QuoteEntity): quoteEntity is OutgoingQuote => { | ||
return quoteEntity.hash !== undefined; | ||
}; | ||
|
||
const quote: OutgoingQuote | undefined = | ||
incomingQuote && isOutgoingQuote(incomingQuote) ? (incomingQuote as OutgoingQuote) : undefined; | ||
|
||
await messageRepository.sendTextWithLinkPreview(conversation, messageText, mentions, quote, messageId); | ||
} | ||
}; | ||
|
||
const handleDiscard = async () => { | ||
await messageRepository.deleteMessageById(conversation, message.id); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic doesn't really belong there.
The fact that you needed to inject the messageRepository
in this component is an indicator that the logic might not be in the correct layer of the app.
If you look at the codebase, you will see that the MessageWrapper
already has access to the MessageRepository
, so it should be to one implementing retry
and discard
.
This component should have 2 callbacks as props onRetry
and onDiscard
and this logic should live in the MessageWrapper
onDiscard={() => { | ||
onDiscard(); | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onDiscard={() => { | |
onDiscard(); | |
}} | |
onDiscard={onDiscard} |
WDYT?
onRetry={() => { | ||
onRetry(message); | ||
}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onRetry={() => { | |
onRetry(message); | |
}} | |
onRetry={() => onRetry(message)} |
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgot to remove dem curly braces, good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😎 Looking great. Good job man 👏
Feature