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: app sounds #31055

Conversation

lauridskern
Copy link
Contributor

@lauridskern lauridskern commented Nov 8, 2023

Details

This PR implements sounds playing when message gets received (only when app is in foreground, i. e. not sounds for push notifications).

To play a sound I used react-native-sound ( and react-native-web-sound for web, underhood it uses howler.js). Initially I wanted to use expo-sound but was getting ridiculous errors and couldn't resolve them (on iOS and web).

Fixed Issues

$ #29835
PROPOSAL: N/A

Tests

  1. Open app on two devices
  2. Send message from one device to another
  • Done sound -> when user sends a message/emoji/attachment/assigning task/sends money/request money (i. e. if user sends any content to another user we play done sound);
  • Success sound -> when someone completes task/someone completes money request/someone sends money to you (regardless of who marks the task as done, i. e. sender or receiver);
  • Attention sound -> someone mentioned you/someone request money from you/someone assigns a task to you (@here also should produce the sound);
  • Received sound -> when message (excluding success/attention cases from above) received
  1. go to setting and mute all sounds
  2. verify step 2 but be sure there is no audio actually played
  3. unmute sounds in app setting
  4. go to a particular channel -> open settings of this channel -> open "Notify me about new messages" -> set it to "Mute"
  5. verify step 2 but be sure there is no audio actually played (excluding "done" case - "done" sound should be played in any case).
  6. set "Daily" mode and repeat step 2 - be sure that all sounds are playable
  7. set "Immediately" mode and repeat step 2 - be sure that all sounds are playable
  8. mute sound in app settings and for channel - be sure that step 2 will not play any sound at all
  • Verify that no errors appear in the JS console

Offline tests

QA Steps

  1. Open app on two devices
  2. Send message from one device to another
  • Done sound -> when user sends a message/emoji/attachment/assigning task/sends money/request money (i. e. if user sends any content to another user we play done sound);
  • Success sound -> when someone completes task/someone completes money request/someone sends money to you (regardless of who marks the task as done, i. e. sender or receiver);
  • Attention sound -> someone mentioned you/someone request money from you/someone assigns a task to you (@here also should produce the sound);
  • Received sound -> when message (excluding success/attention cases from above) received
  1. go to setting and mute all sounds
  2. verify step 2 but be sure there is no audio actually played
  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
    • MacOS: Desktop
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that the left part of a conditional rendering a React component is a boolean and NOT a string, e.g. myBool && <MyComponent />.
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I verified the translation was requested/reviewed in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is approved by marketing by adding the Waiting for Copy label for a copy review on the original GH to get the correct copy.
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.js or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label so the design team can review the changes.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android-demo-sound-truncated.mp4
Android: mWeb Chrome
iOS: Native
iOS-sound-demo.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web-sound-demo.mov
MacOS: Desktop
desktop-demo-sounds.mov

Copy link
Contributor

github-actions bot commented Nov 8, 2023

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@mountiny
Copy link
Contributor

@lauridskern can you please comment signing the CLA as instructed? i will try to rerun the job

@lauridskern
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@lauridskern
Copy link
Contributor Author

recheck

@mountiny
Copy link
Contributor

mountiny commented Dec 1, 2023

@lauridskern CLA passing now, thanks!

@lauridskern
Copy link
Contributor Author

Awesome! Thanks for your assistance

@lauridskern lauridskern force-pushed the origin/feat/update-loading-screen-to-play-animation-and-sound branch from c4c87c3 to 594d0c8 Compare December 6, 2023 14:57
@lauridskern lauridskern marked this pull request as ready for review December 6, 2023 20:24
@lauridskern lauridskern requested a review from a team as a code owner December 6, 2023 20:24
@melvin-bot melvin-bot bot requested review from aimane-chnaif and shawnborton and removed request for a team December 6, 2023 20:24
Copy link

melvin-bot bot commented Dec 6, 2023

@shawnborton @aimane-chnaif One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@aimane-chnaif
Copy link
Contributor

Hmm, QR build seems to be failed

@lauridskern please fix conflict

@shawnborton shawnborton requested a review from a team December 22, 2023 14:09
@melvin-bot melvin-bot bot removed the request for review from a team December 22, 2023 14:09
Copy link

melvin-bot bot commented Dec 22, 2023

@shawnborton @thesahindia @ One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@shawnborton
Copy link
Contributor

@aimane-chnaif can you please review this?

I added puller bear and it also assigned @thesahindia - whoever can prioritize this, please help us get this merged. Thanks!

@aimane-chnaif
Copy link
Contributor

aimane-chnaif commented Dec 22, 2023

yes, was waiting for conflict to be fixed. 4.7k commits are behind

@shawnborton
Copy link
Contributor

Hi there, can we please try to move this one forward?

@aimane-chnaif
Copy link
Contributor

@lauridskern bump for fixing conflict

@cristipaval
Copy link
Contributor

cristipaval commented Feb 12, 2024

Also, question for @shawnborton: Shouldn't we also save the muted settings from Preferences as an account NVP in the backend? Do we want this to be a device specific setting?

I went through the conversation on the issue, and it seems that we are testing different sounds for now, so I think it makes sense to let this one a device-specific setting with no BE changes, at least for now.

@kirillzyusko
Copy link
Contributor

I went through the conversation on the #29835, and it seems that we are testing different sounds for now, so I think it makes sense to let this one a device-specific setting with no BE changes, at least for now.

@cristipaval yes, you are right - for now I think we want this feature to keep it as simple as possible, so we didn't involve BE yet

One mention though: Is there a reason why you didn't create connstants for 'done', 'success' and the other sounds?

Yes, sure, I can create constants - I'll push a new commit soon 👍

@hannojg
Copy link
Contributor

hannojg commented Feb 12, 2024

Yes, all resolved 😊

@shawnborton
Copy link
Contributor

Shouldn't we also save the muted settings from Preferences as an account NVP in the backend? Do we want this to be a device specific setting?

Agree that this particular preference wouldn't be device specific, given that when you mute a channel you mute it everywhere and not just your local device.

@cristipaval
Copy link
Contributor

Shouldn't we also save the muted settings from Preferences as an account NVP in the backend? Do we want this to be a device specific setting?

Agree that this particular preference wouldn't be device specific, given that when you mute a channel you mute it everywhere and not just your local device.

@shawnborton this PR persists the settings locally on the device only. We need backend support to persist the setting for the account accros different devices. We can merge this one as it is and open a follow-up PR to save the setting on the backend, given that it's been open for a while already. What do you think?

@shawnborton
Copy link
Contributor

Ah, I was mostly thinking that we already save a user's preference for muting rooms across devices, right? So we could just use that to inform whether or not sounds should play if the user has sounds enabled but the room is muted.

Otherwise I think it's fine that we use local preferences for sound given that you might want sound on your desktop app but not mobile for instance.

@cristipaval
Copy link
Contributor

Ah, I was mostly thinking that we already save a user's preference for muting rooms across devices, right? So we could just use that to inform whether or not sounds should play if the user has sounds enabled but the room is muted.

yes, this is already in place.

Otherwise I think it's fine that we use local preferences for sound given that you might want sound on your desktop app but not mobile for instance.

alright, yes, it makes sense 👍

Thanks!

@cristipaval
Copy link
Contributor

One mention though: Is there a reason why you didn't create connstants for 'done', 'success' and the other sounds?

Yes, sure, I can create constants - I'll push a new commit soon 👍

Ok, so this is good to merge once you create constants @kirillzyusko

@kirillzyusko
Copy link
Contributor

@cristipaval done 👍

cristipaval
cristipaval previously approved these changes Feb 12, 2024
Copy link
Contributor

@cristipaval cristipaval left a comment

Choose a reason for hiding this comment

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

Thanks!

@cristipaval
Copy link
Contributor

DANG! it has conflicts. Could you please resolve them, @kirillzyusko 🙏

@kirillzyusko
Copy link
Contributor

kirillzyusko commented Feb 12, 2024

@cristipaval sure, I'm on it 👀

@kirillzyusko
Copy link
Contributor

kirillzyusko commented Feb 12, 2024

@cristipaval merged upstream 👍

@shawnborton
Copy link
Contributor

I think you mean @cristipaval :)

@cristipaval cristipaval merged commit 9c8d7d2 into Expensify:main Feb 12, 2024
18 checks passed
@kirillzyusko
Copy link
Contributor

@shawnborton you are absolutely right, @christianwen sorry for disturbing you 😅

@cristipaval can we merge this PR? 👀

@cristipaval
Copy link
Contributor

Merged 🚀

Thanks for the work here! 🙏

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/thienlnam in version: 1.4.41-12 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 failure ❌
🕸 web 🕸 success ✅

});

function playSoundForMessageType(pushJSON: OnyxServerUpdate[]) {
const reportActionsOnly = pushJSON.filter((update) => update.key.includes('reportActions_'));
Copy link
Contributor

Choose a reason for hiding this comment

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

There's case of key not existing in update, which lead to #36632.
i.e. CloseAccount pusher event

@rayane-djouah
Copy link
Contributor

FYI, We need to use browser caching to resolve offline sound playback. Issue: #47148

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.