From f6601922b80ab339484b8c6cf3ad8f9814c1a092 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sat, 27 May 2023 02:08:00 -0700 Subject: [PATCH] Fix android sound notifications --- .gitignore | 4 +++- frontend/src/components/Notifications/index.tsx | 12 ++++++++---- frontend/webpack.config.ts | 4 ++++ mobile/App.tsx | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index d298ae9f..0db3c80f 100755 --- a/.gitignore +++ b/.gitignore @@ -649,5 +649,7 @@ docs/.jekyll-cache* docs/_site* node -# mobile frontend js +# mobile frontend statics mobile/html/Web.bundle/js* +mobile/html/Web.bundle/css* +mobile/html/Web.bundle/assets* diff --git a/frontend/src/components/Notifications/index.tsx b/frontend/src/components/Notifications/index.tsx index 01cdcab5..0f1c3465 100644 --- a/frontend/src/components/Notifications/index.tsx +++ b/frontend/src/components/Notifications/index.tsx @@ -31,11 +31,15 @@ interface NotificationMessage { pageTitle: string; } +const path = + window.NativeRobosats === undefined + ? '/static/assets/sounds' + : 'file:///android_asset/Web.bundle/assets/sounds'; const audio = { - chat: new Audio(`/static/assets/sounds/chat-open.mp3`), - takerFound: new Audio(`/static/assets/sounds/taker-found.mp3`), - ding: new Audio(`/static/assets/sounds/locked-invoice.mp3`), - successful: new Audio(`/static/assets/sounds/successful.mp3`), + chat: new Audio(`${path}/chat-open.mp3`), + takerFound: new Audio(`${path}/taker-found.mp3`), + ding: new Audio(`${path}/locked-invoice.mp3`), + successful: new Audio(`${path}/successful.mp3`), }; const emptyNotificationMessage: NotificationMessage = { diff --git a/frontend/webpack.config.ts b/frontend/webpack.config.ts index b18fecd8..6d939c09 100644 --- a/frontend/webpack.config.ts +++ b/frontend/webpack.config.ts @@ -67,6 +67,10 @@ const configMobile: Configuration = { from: path.resolve(__dirname, 'static/css'), to: path.resolve(__dirname, '../mobile/html/Web.bundle/css'), }, + { + from: path.resolve(__dirname, 'static/assets/sounds'), + to: path.resolve(__dirname, '../mobile/html/Web.bundle/assets/sounds'), + }, ], }), ], diff --git a/mobile/App.tsx b/mobile/App.tsx index 5291875f..53255130 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -176,7 +176,7 @@ const App = () => { allowingReadAccessToURL={uri} allowFileAccess={true} allowsBackForwardNavigationGestures={true} - mediaPlaybackRequiresUserAction={false} + mediaPlaybackRequiresUserAction={false} // Allow autoplay allowsLinkPreview={false} renderLoading={() => } onError={(syntheticEvent) => {syntheticEvent.type}}