-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[HOLD for payment 2024-04-03] [$500] In-app sounds play in the background and message received sounds play while not viewing the chat #37098
Comments
Job added to Upwork: https://www.upwork.com/jobs/~011ab7662a4d0687c6 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @abdulrahuman5196 ( |
Triggered auto assignment to @zanyrenney ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.In-app sounds play in the background and message received sounds play while not viewing the chat What is the root cause of that problem?Currently, there is no check to determine whether the app is visible or whether we are viewing the chat before triggering the sound. What changes do you think we should make in order to solve the problem?To address this problem, we should add a conditions before playing in-app sounds.
we should add an early return at the beginning of the function when the app is not visible, here in Line 60 in a868c1a
and here in Line 490 in a868c1a
if (!Visibility.isVisible()) {
// Don't play sounds if the app is not visible
return;
} While adding the condition in
we should change the logic of the Line 490 in a868c1a
function playSoundForMessageType(pushJSON: OnyxServerUpdate[]) {
if (!Visibility.isVisible()) {
// Don't play sounds if the app is not visible
return;
}
const reportActionsOnly = pushJSON.filter((update) => update.key.includes('reportActions_'));
const activeRoute = Navigation.getActiveRoute();
// Use filter to get the report actions of the visible report
const visibleReportActions = reportActionsOnly.filter((value) => {
const reportID = value.key.split('_')[1];
return activeRoute.includes(ROUTES.REPORT_WITH_ID.getRoute(reportID));
});
if (!visibleReportActions.length) {
// No matching reportID found, we are not viewing the updated report
return;
}
// Extract the reportID from the first visible report action
const reportID = visibleReportActions[0].key.split('_')[1];
Promise.all([isChannelMuted(reportID)])
.then(([isMuted]) => {
if (isMuted) {
return;
}
})
.then((isSoundMuted) => {
if (isSoundMuted) {
return;
}
try {
const flatten = visibleReportActions.flatMap((update) => {
// Rest of the code remains unchanged... What alternative solutions did you explore? (Optional)We can use Navigation.getTopmostReportId() to determine whether we should play the sound, but in this way, we will play the sound even if the user is not viewing the chat (in settings pages...) (Ex: when we are in single pane homepage) |
Hmm actually on second look, I don't think this is a bug. The messaging sounds are about playing sounds each time a message is received. The notification preference is related to push notifications or email notifications about when emails are received. Curious if you agree @Julesssss @kirillzyusko |
Reached a better understanding here:
So to fix this we should just mute our in-app sounds (like the message sent/received sounds) while the app is in the background. We should be able to check that with Visibility.isVisible() |
Proposal |
This comment was marked as outdated.
This comment was marked as outdated.
@shawnborton I think you are right. @Julesssss curious about your opinion 👀 |
Yeah, I agree with this. Currently, it feels very weird on iOS/Android, but we are in the process of removing the in-app sound for mobile and moving the sound to the push notification. |
Also just wanted to note here, I do think that while you are actively viewing a chat message, it makes sense to play the chat sounds even if you have notifications set to Weekly. I think there is a difference between in-app sounds vs when you are notified about new chats. |
ProposalPlease re-state the problem that we are trying to solve in this issue.
What is the root cause of that problem?
What changes do you think we should make in order to solve the problem?
function playSoundForMessageType(pushJSON: OnyxServerUpdate[]) {
const reportActionsOnly = pushJSON.filter((update) => update.key.includes('reportActions_'));
// "reportActions_5134363522480668" -> "5134363522480668"
const reportIDs = reportActionsOnly
+ .map((value) => value.key.split('_')[1])
+ .filter((reportID) => {
+ return reportID === Navigation.getTopmostReportId() && Visibility.isVisible() && Visibility.hasFocus();
+ });
Promise.all(reportIDs.map((reportID) => isChannelMuted(reportID)))
.then((muted) => muted.every((isMuted) => isMuted))
.then((isSoundMuted) => {
- if (isSoundMuted) {
- return;
- }
What alternative solutions did you explore? (Optional)
|
Reviewing now |
@dukenv0307 I dont see this in the expectation mentioned above (although I see some discussions on slack related to same)
@arosiclair Could you kindly confirm if below is the only expectation to solve? As mentioned by you here - #37098 (comment)
|
|
Yeah sorry for the moving target. We had some more discussion in this thread and came to this conclusion:
I'll update the title and description |
📣 @abdulrahuman5196 🎉 An offer has been automatically sent to your Upwork account for the Reviewer role 🎉 Thanks for contributing to the Expensify app! |
📣 @dukenv0307 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
The draft PR is created, I am testing all the related cases |
|
Ah good spot. I agree, but we'll need to check that isVisible works and if not maybe handle this differently for Android/iOS, as they aren't going to see the message... We might also need to consider mWeb users |
Yeah this is a good point. Looking at the profile page is fairly rare though so maybe we can ignore that use case? If a user is looking at it and they're hearing message received sounds below it, they should understand what's happening. |
@arosiclair do you recall the push notification logic? If we have to modify both to support profile page I agree it's probably unnecessary for now |
Push notifications are currently hidden on web and mobile when viewing the profile page (because the report is under it). |
Let's leave it then. |
@abdulrahuman5196 PR #37872 is ready to review |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.56-8 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-04-03. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Not a regression
I think in the last sound related GH i saw the mention, that we are going to create common test case for sounds handling. So I don't think we need here separately. |
Yeah, I haven't done this yet but I agree. |
Yep, makes sense to me! |
payment summary @abdulrahuman5196 requires payment automatic offer (Reviewer) paid $500 via Upwork |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 1.4.43-12
Reproducible in staging?: y
**Reproducible in production?:**y
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @arosiclair
Slack conversation: https://expensify.slack.com/archives/C049HHMV9SM/p1708621869934919
Action Performed:
Expected Result:
No sounds play for the message
Actual Result:
The message received sound plays
Workaround:
unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
View all open jobs on GitHub
Upwork Automation - Do Not Edit
The text was updated successfully, but these errors were encountered: