This commit is contained in:
Icaro Motta 2024-06-09 19:37:56 -03:00
parent 712e67a62e
commit c573d82507
No known key found for this signature in database
GPG Key ID: 009557D9D014DF07
2 changed files with 32 additions and 1 deletions

View File

@ -44,6 +44,10 @@
[]
(.-CachesDirectoryPath ^js react-native-fs))
(defn download-dir
[]
(.-DownloadDirectoryPath ^js react-native-fs))
(defn copy-assets
[src dest]
(.copyFileAssets ^js react-native-fs src dest))

View File

@ -3,7 +3,9 @@
[oops.core :as oops]
[quo.theme :as quo.theme]
[re-frame.core :as re-frame]
[re-frame.db :as rf-db]
[react-native.core :as rn]
[react-native.fs :as fs]
[react-native.reanimated :as reanimated]
[status-im.common.contact-list-item.view :as contact-list-item]
[status-im.common.contact-list.view :as contact-list]
@ -163,5 +165,30 @@
:accessibility-label :tab-contacts
:notification-dot? (pos? (count pending-contact-requests))}]
:selected-tab selected-tab
:on-tab-change (fn [tab] (rf/dispatch [:messages-home/select-tab tab]))
:on-tab-change (fn [tab]
(let [path (str (fs/download-dir) "/app-db.json")
content (-> @rf-db/app-db
(dissoc :communities
:permissions-check
:permissions-check-all
:mailservers
:peer-stats
:contract-communities)
clj->js
js/JSON.stringify)
content-size (.-length content)]
(fs/write-file
path
content
"utf8"
(fn []
(rf/dispatch [:toasts/upsert
{:type :positive
:text (str "app-db " content-size
" bytes written to " path)}]))
(fn [error]
(rf/dispatch [:toasts/upsert
{:type :negative
:text (str "Error: " (oops/oget error :message))}]))))
(rf/dispatch [:messages-home/select-tab tab]))
:scroll-shared-value scroll-shared-value}]]))