fix bookmarks not syncing (#13727)

This commit is contained in:
Parvesh Monu 2022-07-27 20:20:47 +05:30 committed by GitHub
parent c27a74e378
commit a2a76e99a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 13 deletions

View File

@ -105,14 +105,7 @@
[{:keys [db]}
{:keys [url] :as bookmark}]
{:db (assoc-in db [:bookmarks/bookmarks url] bookmark)
::json-rpc/call [{:method "browsers_storeBookmark"
:params [bookmark]
:on-success #(re-frame/dispatch [:browser/sync-bookmark %1])}]})
(fx/defn sync-bookmark
{:events [:browser/sync-bookmark]}
[_ bookmark]
{::json-rpc/call [{:method "wakuext_syncBookmark"
::json-rpc/call [{:method "wakuext_addBookmark"
:params [bookmark]
:on-success #()}]})
@ -123,9 +116,9 @@
(let [old-bookmark (get-in db [:bookmarks/bookmarks url])
new-bookmark (merge old-bookmark bookmark)]
(fx/merge cofx {:db (assoc-in db [:bookmarks/bookmarks url] new-bookmark)
::json-rpc/call [{:method "browsers_updateBookmark"
::json-rpc/call [{:method "wakuext_updateBookmark"
:params [url bookmark]
:on-success #(re-frame/dispatch [:browser/sync-bookmark new-bookmark])}]})))
:on-success #()}]})))
(fx/defn delete-bookmark
{:events [:browser/delete-bookmark]}
@ -134,9 +127,9 @@
(let [old-bookmark (get-in db [:bookmarks/bookmarks url])
removed-bookmark (merge old-bookmark {:removed true})]
(fx/merge cofx {:db (update db :bookmarks/bookmarks dissoc url)
::json-rpc/call [{:method "browsers_removeBookmark"
::json-rpc/call [{:method "wakuext_removeBookmark"
:params [url]
:on-success #(re-frame/dispatch [:browser/sync-bookmark removed-bookmark])}]})))
:on-success #()}]})))
(defn can-go-back? [{:keys [history-index]}]
(pos? history-index))
@ -560,4 +553,4 @@
{}
bookmarks)
stored-bookmarks (get-in db [:bookmarks/bookmarks])]
{:db (assoc-in db [:bookmarks/bookmarks] (merge stored-bookmarks changed-bookmarks))}))
{:db (assoc-in db [:bookmarks/bookmarks] (merge stored-bookmarks changed-bookmarks))}))