Skip to content
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

Merged
merged 20 commits into from
Mar 13, 2023

Conversation

V-Gira
Copy link
Contributor

@V-Gira V-Gira commented Feb 27, 2023

Sub-taskFS-1571 [web] implement retry mechanism for messages that have completely failed to send

Feature

  • implement an option to retry sending a message if sending failed
  • implementation with this PR only works with text messages, asset messages display a discard button instead
    Peek 2023-03-07 12-18

@V-Gira V-Gira marked this pull request as ready for review March 7, 2023 11:26
@V-Gira V-Gira requested review from a team and otto-the-bot as code owners March 7, 2023 11:26
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Copy link
Contributor Author

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

@V-Gira V-Gira marked this pull request as draft March 9, 2023 14:50
@codecov
Copy link

codecov bot commented Mar 11, 2023

Codecov Report

Merging #14757 (c2852d5) into dev (0267539) will decrease coverage by 0.10%.
The diff coverage is 29.85%.

@@            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     

@V-Gira V-Gira marked this pull request as ready for review March 11, 2023 16:00
Copy link
Contributor

@atomrc atomrc left a 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

Comment on lines 203 to 230
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);
};

Copy link
Contributor

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

src/script/conversation/MessageRepository.ts Show resolved Hide resolved
Comment on lines 251 to 253
onDiscard={() => {
onDiscard();
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onDiscard={() => {
onDiscard();
}}
onDiscard={onDiscard}

WDYT?

Comment on lines 254 to 256
onRetry={() => {
onRetry(message);
}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onRetry={() => {
onRetry(message);
}}
onRetry={() => onRetry(message)}

WDYT?

Copy link
Contributor Author

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

Copy link
Contributor

@atomrc atomrc left a 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 👏

@V-Gira V-Gira merged commit 23d0231 into dev Mar 13, 2023
@V-Gira V-Gira deleted the virgile/generic-failure-to-send branch March 13, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants