-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix: self-deleting msg in doze mode on ConversationScreen [WPB-5894] #2642
Conversation
Test Results758 tests 758 ✅ 13m 49s ⏱️ Results for commit 186fc4b. ♻️ This comment has been updated with latest results. |
Build 2796 failed. |
APKs built during tests are available here. Scroll down to Artifacts! |
Build 2798 failed. |
APKs built during tests are available here. Scroll down to Artifacts! |
Build 2800 succeeded. The build produced the following APK's: |
APKs built during tests are available here. Scroll down to Artifacts! |
Build 2817 failed. |
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
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 theConversationScreen
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 anotherdelay
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 to1: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 is1: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 is1:59.900
then it should return59.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)
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)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.