Skip to content

Commit

Permalink
[#13116] Load audio messages from http server
Browse files Browse the repository at this point in the history
Signed-off-by: andrey <motor4ik@gmail.com>
  • Loading branch information
flexsurfer committed Mar 1, 2022
1 parent 5fd7e35 commit a2497c8
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 87 deletions.
28 changes: 20 additions & 8 deletions ios/Podfile.lock
Expand Up @@ -2,7 +2,7 @@ PODS:
- boost-for-react-native (1.63.0)
- BVLinearGradient (2.5.6):
- React
- CryptoSwift (1.4.2)
- CryptoSwift (1.4.3)
- DoubleConversion (1.1.6)
- FBLazyVector (0.63.4)
- FBReactNativeSpec (0.63.4):
Expand Down Expand Up @@ -206,6 +206,8 @@ PODS:
- React-jsinspector (0.63.4)
- react-native-background-timer (2.2.0):
- React
- react-native-blob-util (0.13.18):
- React-Core
- react-native-camera-kit (8.0.4):
- React
- react-native-cameraroll (4.0.4):
Expand All @@ -220,6 +222,8 @@ PODS:
- React-Core
- react-native-netinfo (4.7.0):
- React
- react-native-notifications (4.1.3):
- React-Core
- react-native-safe-area-context (2.0.0):
- React
- react-native-shake (3.4.0):
Expand All @@ -233,7 +237,7 @@ PODS:
- react-native-status-keycard (2.5.37):
- Keycard
- React
- react-native-webview (11.3.0):
- react-native-webview (11.16.0):
- React-Core
- React-RCTActionSheet (0.63.4):
- React-Core/RCTActionSheetHeaders (= 0.63.4)
Expand Down Expand Up @@ -388,8 +392,8 @@ PODS:
- SQLCipher/common (3.4.2)
- SQLCipher/standard (3.4.2):
- SQLCipher/common
- SSZipArchive (2.4.2)
- TOCropViewController (2.6.0)
- SSZipArchive (2.4.3)
- TOCropViewController (2.6.1)
- TouchID (4.4.1):
- React
- Yoga (1.14.0)
Expand Down Expand Up @@ -417,12 +421,14 @@ DEPENDENCIES:
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector`)
- react-native-background-timer (from `../node_modules/react-native-background-timer`)
- react-native-blob-util (from `../node_modules/react-native-blob-util`)
- react-native-camera-kit (from `../node_modules/react-native-camera-kit`)
- "react-native-cameraroll (from `../node_modules/@react-native-community/cameraroll`)"
- react-native-config (from `../node_modules/react-native-config`)
- react-native-image-resizer (from `../node_modules/react-native-image-resizer`)
- react-native-mail (from `../node_modules/react-native-mail`)
- "react-native-netinfo (from `../node_modules/@react-native-community/netinfo`)"
- react-native-notifications (from `../node_modules/react-native-notifications`)
- react-native-safe-area-context (from `../node_modules/react-native-safe-area-context`)
- react-native-shake (from `../node_modules/react-native-shake`)
- "react-native-slider (from `../node_modules/@react-native-community/slider`)"
Expand Down Expand Up @@ -517,6 +523,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsinspector"
react-native-background-timer:
:path: "../node_modules/react-native-background-timer"
react-native-blob-util:
:path: "../node_modules/react-native-blob-util"
react-native-camera-kit:
:path: "../node_modules/react-native-camera-kit"
react-native-cameraroll:
Expand All @@ -529,6 +537,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-mail"
react-native-netinfo:
:path: "../node_modules/@react-native-community/netinfo"
react-native-notifications:
:path: "../node_modules/react-native-notifications"
react-native-safe-area-context:
:path: "../node_modules/react-native-safe-area-context"
react-native-shake:
Expand Down Expand Up @@ -621,7 +631,7 @@ CHECKOUT OPTIONS:
SPEC CHECKSUMS:
boost-for-react-native: 39c7adb57c4e60d6c5479dd8623128eb5b3f0f2c
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
CryptoSwift: a532e74ed010f8c95f611d00b8bbae42e9fe7c17
CryptoSwift: a0799ee936271bd2253a006f1e4523df21845000
DoubleConversion: cde416483dac037923206447da6e1454df403714
FBLazyVector: 3bb422f41b18121b71783a905c10e58606f7dc3e
FBReactNativeSpec: f2c97f2529dd79c083355182cc158c9f98f4bd6e
Expand All @@ -642,19 +652,21 @@ SPEC CHECKSUMS:
React-jsiexecutor: 93bd528844ad21dc07aab1c67cb10abae6df6949
React-jsinspector: 58aef7155bc9a9683f5b60b35eccea8722a4f53a
react-native-background-timer: 1f7d560647b40e6a60b01c452ba29c54bf581fc4
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
react-native-camera-kit: 498a6d111a904834e0824e9073cfadef7303235f
react-native-cameraroll: 88f4e62d9ecd0e1f253abe4f685474f2ea14bfa2
react-native-config: c98128a72bc2c3a1ca72caec0b021f0fa944aa29
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
react-native-mail: 8fdcd3aef007c33a6877a18eb4cf7447a1d4ce4a
react-native-netinfo: ddaca8bbb9e6e914b1a23787ccb879bc642931c9
react-native-notifications: 805108822ceff3440644d5701944f0cda35f5b4b
react-native-safe-area-context: 60f654e00b6cc416573f6d5dbfce3839958eb57a
react-native-shake: de052eaa3eadc4a326b8ddd7ac80c06e8d84528c
react-native-slider: 12bd76d3d568c9c5500825db54123d44b48e4ad4
react-native-splash-screen: 200d11d188e2e78cea3ad319964f6142b6384865
react-native-status: 45dbf1302ce3c258b459dfab137cd1c2c68c295d
react-native-status-keycard: 961d01ca190889ddf220206822fd752f8f4f3f7a
react-native-webview: af9990b21a9aeafa8e8347746eb4116c0de086af
react-native-webview: 28a8636d97ee641f2ee8f20492d7a6c269c1d703
React-RCTActionSheet: 89a0ca9f4a06c1f93c26067af074ccdce0f40336
React-RCTAnimation: 1bde3ecc0c104c55df246eda516e0deb03c4e49b
React-RCTBlob: a97d378b527740cc667e03ebfa183a75231ab0f0
Expand Down Expand Up @@ -688,8 +700,8 @@ SPEC CHECKSUMS:
SDWebImageWebPCoder: f93010f3f6c031e2f8fb3081ca4ee6966c539815
secp256k1: f61d67e6fdcb85fd727acf1bf35ace6036db540c
SQLCipher: f9fcf29b2e59ced7defc2a2bdd0ebe79b40d4990
SSZipArchive: e7b4f3d9e780c2acc1764cd88fbf2de28f26e5b2
TOCropViewController: 3105367e808b7d3d886a74ff59bf4804e7d3ab38
SSZipArchive: fe6a26b2a54d5a0890f2567b5cc6de5caa600aef
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
TouchID: ba4c656d849cceabc2e4eef722dea5e55959ecf4
Yoga: 4bd86afe9883422a7c4028c00e34790f560923d6

Expand Down
68 changes: 13 additions & 55 deletions nix/deps/gradle/deps.json
Expand Up @@ -7324,16 +7324,16 @@
},

{
"path": "com/squareup/okhttp3/okhttp/5.0.0-alpha.4/okhttp-5.0.0-alpha.4",
"path": "com/squareup/okhttp3/okhttp/5.0.0-alpha.5/okhttp-5.0.0-alpha.5",
"host": "https://repo.maven.apache.org/maven2",
"type": "jar",
"pom": {
"sha1": "928427ff8d8c2326263733462bc5f8ea1021b5cb",
"sha256": "11iwhxf9ndkd6qmnb3iim97hm9h20v3fkvr8hnav5ypy44mgxilk"
"sha1": "71c72a769bb69cdac5c01b1baf3d3cea94633c8e",
"sha256": "1als0653nwccdzcmxikdmlqx2i3072p6bqv65w67nj695n5r0bjj"
},
"jar": {
"sha1": "bca0daab030b78fbc74e97e45dd01c6826cf4959",
"sha256": "0s305pbn9rc8y37grz2gmzgmzpi4zdhg9r0sm4fknnimyzdk6j5x"
"sha1": "bb262550c729996d20d3df9f66affc383901a123",
"sha256": "1qpyvqmwrz6zh4q492wflqsr12g1jivikl6qf8paw0zcc3d392xb"
}
},

Expand Down Expand Up @@ -7709,34 +7709,6 @@
}
},

{
"path": "com/willowtreeapps/assertk/assertk/0.25/assertk-0.25",
"host": "https://repo.maven.apache.org/maven2",
"type": "jar",
"pom": {
"sha1": "557170cd696a66845f2f97c36b20b372739dff34",
"sha256": "0d6lqsv2j6z9bjzag72bffyswnbbgrz1qcaydm7i2kc34wxz5hjs"
},
"jar": {
"sha1": "c20894404c38109ed837f6f6d254987777a06b0c",
"sha256": "0341gbcpz37abbk61xyfxmj5gjxggpvwpq5s16zrjkkrgx7v1sfi"
}
},

{
"path": "com/willowtreeapps/opentest4k/opentest4k/1.2.2/opentest4k-1.2.2",
"host": "https://repo.maven.apache.org/maven2",
"type": "jar",
"pom": {
"sha1": "e5c64dc093a91d1e2f591d0742798bb8f325b0ea",
"sha256": "1wn81995g9qdnxfgbscrm4a07m565dmk7mnycrw575w6vjjl0sca"
},
"jar": {
"sha1": "cc1388f1517c5fb7b83009abbc2f0eb2883739ef",
"sha256": "0g31fw5nvd09nc3pkgzpiwmbvizbxw2wv0vz76m2xbpy8wh8n9jg"
}
},

{
"path": "de/undercouch/gradle-download-task/3.4.3/gradle-download-task-3.4.3",
"host": "https://repo.maven.apache.org/maven2",
Expand Down Expand Up @@ -7794,26 +7766,26 @@
},

{
"path": "jakarta/xml/bind/jakarta.xml.bind-api-parent/4.0.0-RC2/jakarta.xml.bind-api-parent-4.0.0-RC2",
"path": "jakarta/xml/bind/jakarta.xml.bind-api-parent/4.0.0-RC3/jakarta.xml.bind-api-parent-4.0.0-RC3",
"host": "https://repo.maven.apache.org/maven2",
"type": "pom",
"pom": {
"sha1": "89412e0394f9e398e13416fde8da8b3a80fa0fec",
"sha256": "0bpclrb04qff6adkn37rk4zp5y8ky0vjnp5cxyzv8zc8182fhmr1"
"sha1": "a19c03e97865c73e090c628f140bf989c39ca58c",
"sha256": "1h2kffzcpsivg9ash0qn22gfyrv9dzhzymafsnl3rv70rmx571cx"
}
},

{
"path": "jakarta/xml/bind/jakarta.xml.bind-api/4.0.0-RC2/jakarta.xml.bind-api-4.0.0-RC2",
"path": "jakarta/xml/bind/jakarta.xml.bind-api/4.0.0-RC3/jakarta.xml.bind-api-4.0.0-RC3",
"host": "https://repo.maven.apache.org/maven2",
"type": "jar",
"pom": {
"sha1": "894741e8eca308287531b49bd3045e247cd43515",
"sha256": "15qcygb76b7khpgsq94azpfqkfxp50fn0yypmdy3p3rm8bnpbypc"
"sha1": "92e21745056f04ee7fcba97d4560e7844b6ef588",
"sha256": "0cbhwfj5v7hfyx1vpl0hq40100k7yl98i6lnlalh718wmw9rq5fz"
},
"jar": {
"sha1": "79f7ab7d98c0b95bef12d0b33b9b34af415ce222",
"sha256": "18dwxaillwc1bssp0wypjhgg9vygk0p5wcr9j6dh63xk0zd6pkqd"
"sha1": "ecec3b5ac3aaef841a10d83b5546c285d9914028",
"sha256": "0mcij5xnqkq8swvc6fdijjjxbrvp74z23f5jpf9nbqgxbvskjchm"
}
},

Expand Down Expand Up @@ -12045,20 +12017,6 @@
}
},

{
"path": "org/jetbrains/kotlin/kotlin-stdlib-common/1.5.30/kotlin-stdlib-common-1.5.30",
"host": "https://repo.maven.apache.org/maven2",
"type": "jar",
"pom": {
"sha1": "850c3ca345e0afacbfaf203f5259e3e1be59df9e",
"sha256": "1g74j6k1lbnljsy2dif47mmc3hrwqch6j6zi1mdp4mh11r812w6d"
},
"jar": {
"sha1": "649ffab7767038323fec0cc41e2d7b0a8f65a378",
"sha256": "1f346x78anwcxyj1lbywjz4vwa66la5sgfyhz3h2514p199srcwf"
}
},

{
"path": "org/jetbrains/kotlin/kotlin-stdlib-common/1.5.31/kotlin-stdlib-common-1.5.31",
"host": "https://repo.maven.apache.org/maven2",
Expand Down
9 changes: 3 additions & 6 deletions nix/deps/gradle/deps.urls
Expand Up @@ -530,7 +530,7 @@ https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp-urlconnection/3
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp/3.9.1/okhttp-3.9.1.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp/3.12.1/okhttp-3.12.1.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp/3.12.12/okhttp-3.12.12.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp/5.0.0-alpha.4/okhttp-5.0.0-alpha.4.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/okhttp/5.0.0-alpha.5/okhttp-5.0.0-alpha.5.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/parent/3.9.1/parent-3.9.1.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/parent/3.12.1/parent-3.12.1.pom
https://repo.maven.apache.org/maven2/com/squareup/okhttp3/parent/3.12.12/parent-3.12.12.pom
Expand Down Expand Up @@ -563,14 +563,12 @@ https://repo.maven.apache.org/maven2/com/tunnelvisionlabs/antlr4-master/4.9.0/an
https://repo.maven.apache.org/maven2/com/tunnelvisionlabs/antlr4-runtime/4.5/antlr4-runtime-4.5.pom
https://repo.maven.apache.org/maven2/com/tunnelvisionlabs/antlr4-runtime/4.9.0/antlr4-runtime-4.9.0.pom
https://repo.maven.apache.org/maven2/com/tunnelvisionlabs/antlr4/4.5/antlr4-4.5.pom
https://repo.maven.apache.org/maven2/com/willowtreeapps/assertk/assertk/0.25/assertk-0.25.pom
https://repo.maven.apache.org/maven2/com/willowtreeapps/opentest4k/opentest4k/1.2.2/opentest4k-1.2.2.pom
https://repo.maven.apache.org/maven2/de/undercouch/gradle-download-task/3.4.3/gradle-download-task-3.4.3.pom
https://repo.maven.apache.org/maven2/de/undercouch/gradle-download-task/4.0.2/gradle-download-task-4.0.2.pom
https://repo.maven.apache.org/maven2/it/unimi/dsi/fastutil/7.2.0/fastutil-7.2.0.pom
https://repo.maven.apache.org/maven2/jakarta/activation/jakarta.activation-api/2.1.0/jakarta.activation-api-2.1.0.pom
https://repo.maven.apache.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api-parent/4.0.0-RC2/jakarta.xml.bind-api-parent-4.0.0-RC2.pom
https://repo.maven.apache.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0-RC2/jakarta.xml.bind-api-4.0.0-RC2.pom
https://repo.maven.apache.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api-parent/4.0.0-RC3/jakarta.xml.bind-api-parent-4.0.0-RC3.pom
https://repo.maven.apache.org/maven2/jakarta/xml/bind/jakarta.xml.bind-api/4.0.0-RC3/jakarta.xml.bind-api-4.0.0-RC3.pom
https://repo.maven.apache.org/maven2/javax/activation/activation/1.1/activation-1.1.pom
https://repo.maven.apache.org/maven2/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.pom
https://repo.maven.apache.org/maven2/javax/annotation/javax.annotation-api/1.2/javax.annotation-api-1.2.pom
Expand Down Expand Up @@ -907,7 +905,6 @@ https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.10/kotlin-stdlib-common-1.4.10.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.30/kotlin-stdlib-common-1.4.30.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.4.31/kotlin-stdlib-common-1.4.31.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.30/kotlin-stdlib-common-1.5.30.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.31/kotlin-stdlib-common-1.5.31.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.6.10/kotlin-stdlib-common-1.6.10.pom
https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.2.71/kotlin-stdlib-jdk7-1.2.71.pom
Expand Down
40 changes: 26 additions & 14 deletions src/status_im/ui/screens/chat/message/audio.cljs
Expand Up @@ -10,7 +10,10 @@
[quo.design-system.colors :as colors]
[status-im.ui.components.icons.icons :as icons]
[status-im.ui.components.react :as react]
[status-im.ui.components.slider :as slider]))
[status-im.ui.components.slider :as slider]
["react-native-blob-util" :default ReactNativeBlobUtil]
[status-im.utils.platform :as platform]
[taoensso.timbre :as log]))

(defonce player-ref (atom nil))
(defonce current-player-message-id (atom nil))
Expand Down Expand Up @@ -110,25 +113,34 @@
#(update-state (merge params {:error (:message %)}))))))
(update-state (merge params {:seek-to-ms value})))

(defn reload-player [{:keys [message-id state-ref] :as params} base64-data on-success]
(defn download-audio-http [base64-uri on-success]
(-> (.config ReactNativeBlobUtil (clj->js {:trusty platform/ios?}))
(.fetch "GET" (str base64-uri))
(.then #(on-success (.base64 ^js %)))
(.catch #(log/error "could not fetch audio"))))

(defn reload-player [{:keys [message-id state-ref] :as params} audio-url on-success]
;; to avoid reloading player while is initializing,
;; we go ahead only if there is no player or
;; if it is already prepared
(when (or (nil? @player-ref) (audio/can-play? @player-ref))
(when @player-ref
(destroy-player (merge params {:reloading? true})))
(reset! player-ref (audio/new-player
base64-data
{:autoDestroy false
:continuesToPlayInBackground false}
#(seek params 0 true nil)))
(audio/prepare-player
@player-ref
#(when on-success (on-success))
#(update-state (merge params {:error (:message %)})))
(reset! current-player-message-id message-id)
(reset! current-active-state-ref-ref state-ref)
(update-state params)))
(download-audio-http
audio-url
(fn [base64-data]
(reset! player-ref (audio/new-player
(str "data:audio/acc;base64," base64-data)
{:autoDestroy false
:continuesToPlayInBackground false}
#(seek params 0 true nil)))
(audio/prepare-player
@player-ref
#(when on-success (on-success))
#(update-state (merge params {:error (:message %)})))
(reset! current-player-message-id message-id)
(reset! current-active-state-ref-ref state-ref)
(update-state params)))))

(defn play-pause [{:keys [message-id state-ref] :as params} audio]
(if (not= message-id @current-player-message-id)
Expand Down
8 changes: 4 additions & 4 deletions status-go-version.json
Expand Up @@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im",
"repo": "status-go",
"version": "v0.94.9",
"commit-sha1": "38a16b355458e51489326e797dadb7c586f937f3",
"src-sha256": "02rz686j85rrb721bwjr7s2392apw1f47lvc2ms83z17xykcd5p5"
}
"version": "v0.94.10",
"commit-sha1": "598b83757cc8b27e3374e50de02187eacf0d4280",
"src-sha256": "0ncywjmpng7zdx707j45yxzj0m06c24mi0lgk3d2yzbp7gx3cygz"
}

0 comments on commit a2497c8

Please sign in to comment.