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

fix: self-deleting msg in doze mode on ConversationScreen [WPB-5894] #2642

Merged
merged 5 commits into from
Jan 31, 2024

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Jan 30, 2024

BugWPB-5894 [Android] Self deleting messages timer stops when device is in doze mode


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

When the user receives a self-deleting message, leaves the app on ConversationScreen and the app is put into background, then the message is not removed after given time when app is opened again, only when the user closes the ConversationScreen and opens it again. When the given time is not fully passed, the message counter is not properly updated, it stays on the value it had when the app was put into background. Sometimes this counter doesn't get updated for the next interval, for instance it starts with "4 minutes left" and after a minute passes it's still "4 minutes left" but then after another minute it suddenly goes down to "2 minutes left".

Causes (Optional)

Previous solution was implemented to check and remove all expired messages when the user opens the ConversationScreen so it's not working when the user is still on that screen. For the counter, there's another delay which also doesn't work well when in doze mode and the counter composable isn't recomposed because the value is not being passed as a state. Also, the amount of time to be delayed is not calculated properly - it takes only one unit into account, so for instance if the time left for the message is equal to 1:59.900 left (1 minute 59 seconds and 900ms) then it will delay for 59 seconds, omitting the milliseconds value and resulting in next calculation being done when the time left is 1:00.900, so still over a minute, that's why it can give the result of "1 minute left" for 2 minutes.

Solutions

Implement a global observer to execute deleteEphemeralMessageEndDate each time the app is back in the foreground.
Refactor the SelfDeletionTimerHelper to take "end time" when handling self-deleting expiration and recalculate the time again each time the delay ends by comparing "current time" and "end time" instead of just subtracting the "delay time" - thanks to that it has more accurate time left in each iteration.
Fix the updateInterval function to return the full remaining time to the next given duration unit (for instance if we want to get time remaining to the next full minute and now the time is 1:59.900 then it should return 59.900)
Provide timeLeftFormatted as a state so that the composable that's showing it gets recomposed each time it's updated.
Implement another LaunchedEffect to recalculate the time left and restart the delay when the app is back in the foreground.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

Receive a self-deleting message and put the app in the background while still being on the ConversationScreen, turn off the screen so that it can enter doze mode and open the app again before or after the time for the self-deleting message passes.


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

Copy link
Contributor

github-actions bot commented Jan 30, 2024

Test Results

758 tests   758 ✅  13m 49s ⏱️
106 suites    0 💤
106 files      0 ❌

Results for commit 186fc4b.

♻️ This comment has been updated with latest results.

@AndroidBob
Copy link
Collaborator

Build 2796 failed.

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@saleniuk saleniuk requested review from alexandreferris, a team, borichellow, vitorhugods, mchenani and ohassine and removed request for a team January 30, 2024 12:02
@AndroidBob
Copy link
Collaborator

Build 2798 failed.

Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@AndroidBob
Copy link
Collaborator

Build 2800 succeeded.

The build produced the following APK's:

@yamilmedina yamilmedina enabled auto-merge (squash) January 31, 2024 14:59
@yamilmedina yamilmedina merged commit 0c41348 into release/candidate Jan 31, 2024
9 of 10 checks passed
@yamilmedina yamilmedina deleted the fix/self-deleting-msgs-in-doze-mode branch January 31, 2024 15:21
Copy link
Contributor

APKs built during tests are available here. Scroll down to Artifacts!

@AndroidBob
Copy link
Collaborator

Build 2817 failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants