Add mark all read

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
Andrea Maria Piana 2020-02-18 20:23:02 +01:00
parent c9d1adbc27
commit 21ef5a68b8
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
23 changed files with 87 additions and 132 deletions

View File

@ -118,6 +118,18 @@
[{:keys [db] :as cofx} chat-id]
(chats-store/save-chat cofx (get-in db [:chats chat-id])))
(fx/defn handle-mark-all-read-successful
{:events [::mark-all-read-successful]}
[{:keys [db] :as cofx} chat-id]
{:db (assoc-in db [:chats chat-id :unviewed-messages-count] 0)})
(fx/defn handle-mark-all-read
{:events [:chat.ui/mark-all-read-pressed]}
[{:keys [db] :as cofx} chat-id]
{::json-rpc/call [{:method (json-rpc/call-ext-method "markAllRead")
:params [chat-id]
:on-success #(re-frame/dispatch [::mark-all-read-successful chat-id])}]})
(fx/defn add-public-chat
"Adds new public group chat to db"
[cofx topic]

View File

@ -209,9 +209,7 @@
(fx/defn resend-message
[{:keys [db] :as cofx} chat-id message-id]
(fx/merge cofx
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_reSendChatMessage"
"shhext_reSendChatMessage")
{::json-rpc/call [{:method (json-rpc/call-ext-method "reSendChatMessage")
:params [message-id]
:on-success #(log/debug "re-sent message successfully")
:on-error #(log/error "failed to re-send message" %)}]}

View File

@ -24,26 +24,20 @@
{:events [::accept-request-address-for-transaction]}
[{:keys [db]} message-id address]
{:db (dissoc db :commands/select-account)
::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_acceptRequestAddressForTransaction"
"shhext_acceptRequestAddressForTransaction")
::json-rpc/call [{:method (json-rpc/call-ext-method "acceptRequestAddressForTransaction")
:params [message-id address]
:on-success #(re-frame/dispatch [:transport/message-sent % 1])}]})
(fx/defn handle-decline-request-address-for-transaction
{:events [::decline-request-address-for-transaction]}
[cofx message-id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_declineRequestAddressForTransaction"
"shhext_declineRequestAddressForTransaction")
{::json-rpc/call [{:method (json-rpc/call-ext-method "declineRequestAddressForTransaction")
:params [message-id]
:on-success #(re-frame/dispatch [:transport/message-sent % 1])}]})
(fx/defn handle-decline-request-transaction
{:events [::decline-request-transaction]}
[cofx message-id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_declineRequestTransaction"
"shhext_declineRequestTransaction")
{::json-rpc/call [{:method (json-rpc/call-ext-method "declineRequestTransaction")
:params [message-id]
:on-success #(re-frame/dispatch [:transport/message-sent % 1])}]})

View File

@ -86,9 +86,7 @@
(fx/defn send-contact-request
[{:keys [db] :as cofx} {:keys [public-key] :as contact}]
(let [{:keys [name profile-image]} (own-info db)]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_sendContactUpdate"
"shhext_sendContactUpdate")
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactUpdate")
:params [public-key name profile-image]
:on-success #(log/debug "contact request sent" public-key)}]}))

View File

@ -114,17 +114,13 @@
(dissoc :chatType :members)))
(fx/defn save-chat [cofx {:keys [chat-id] :as chat}]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_saveChat"
"shhext_saveChat")
{::json-rpc/call [{:method (json-rpc/call-ext-method "saveChat")
:params [(->rpc chat)]
:on-success #(log/debug "saved chat" chat-id "successfuly")
:on-failure #(log/error "failed to save chat" chat-id %)}]})
(fx/defn fetch-chats-rpc [cofx {:keys [on-success]}]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_chats"
"shhext_chats")
{::json-rpc/call [{:method (json-rpc/call-ext-method "chats")
:params []
:on-success #(on-success (map <-rpc %))
:on-failure #(log/error "failed to fetch chats" 0 -1 %)}]})

View File

@ -46,26 +46,20 @@
(fx/defn fetch-contacts-rpc
[cofx on-success]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_contacts"
"shhext_contacts")
{::json-rpc/call [{:method (json-rpc/call-ext-method "contacts")
:params []
:on-success #(on-success (map <-rpc %))
:on-failure #(log/error "failed to fetch contacts" %)}]})
(fx/defn save-contact
[cofx {:keys [public-key] :as contact}]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_saveContact"
"shhext_saveContact")
{::json-rpc/call [{:method (json-rpc/call-ext-method "saveContact")
:params [(->rpc contact)]
:on-success #(log/debug "saved contact" public-key "successfuly")
:on-failure #(log/error "failed to save contact" public-key %)}]})
(fx/defn block [cofx contact on-success]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_blockContact"
"shhext_blockContact")
{::json-rpc/call [{:method (json-rpc/call-ext-method "blockContact")
:params [(->rpc contact)]
:on-success on-success
:on-failure #(log/error "failed to block contact" % contact)}]})

View File

@ -47,17 +47,13 @@
(dissoc :ensName :chatId :text :rtl :responseTo :sticker :lineCount :parsedText)))
(defn update-outgoing-status-rpc [message-id status]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_updateMessageOutgoingStatus"
"shhext_updateMessageOutgoingStatus")
{::json-rpc/call [{:method (json-rpc/call-ext-method "updateMessageOutgoingStatus")
:params [message-id status]
:on-success #(log/debug "updated message outgoing stauts" message-id status)
:on-failure #(log/error "failed to update message outgoing status" message-id status %)}]})
(defn save-system-messages-rpc [messages]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_addSystemMessages"
"shhext_addSystemMessages")
(json-rpc/call {:method (json-rpc/call-ext-method "addSystemMessages")
:params [(map ->rpc messages)]
:on-success #(re-frame/dispatch [:messages/system-messages-saved (map <-rpc %)])
:on-failure #(log/error "failed to save messages" %)}))
@ -67,42 +63,32 @@
limit
on-success
on-failure]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_chatMessages"
"shhext_chatMessages")
{::json-rpc/call [{:method (json-rpc/call-ext-method "chatMessages")
:params [chat-id cursor limit]
:on-success (fn [result]
(on-success (update result :messages #(map <-rpc %))))
:on-failure on-failure}]})
(defn mark-seen-rpc [chat-id ids]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_markMessagesSeen"
"shhext_markMessagesSeen")
{::json-rpc/call [{:method (json-rpc/call-ext-method "markMessagesSeen")
:params [chat-id ids]
:on-success #(log/debug "successfully marked as seen")
:on-failure #(log/error "failed to get messages" %)}]})
(defn delete-message-rpc [id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_deleteMessage"
"shhext_deleteMessage")
{::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessage")
:params [id]
:on-success #(log/debug "successfully deleted message" id)
:on-failure #(log/error "failed to delete message" % id)}]})
(defn delete-messages-from-rpc [author]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_deleteMessagesFrom"
"shhext_deleteMessagesFrom")
{::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessagesFrom")
:params [author]
:on-success #(log/debug "successfully deleted messages from" author)
:on-failure #(log/error "failed to delete messages from" % author)}]})
(defn delete-messages-by-chat-id-rpc [chat-id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_deleteMessagesByChatID"
"shhext_deleteMessagesByChatID")
{::json-rpc/call [{:method (json-rpc/call-ext-method "deleteMessagesByChatID")
:params [chat-id]
:on-success #(log/debug "successfully deleted messages by chat-id" chat-id)
:on-failure #(log/error "failed to delete messages by chat-id" % chat-id)}]})

View File

@ -293,9 +293,7 @@
(navigation/navigate-to-cofx :ens-search {})))
(defn verify-names [names]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_verifyENSNames"
"shhext_verifyENSNames")
(json-rpc/call {:method (json-rpc/call-ext-method "verifyENSNames")
:params [names]
:on-success #(re-frame/dispatch [:contacts/ens-names-verified %])
:on-failure #(log/error "failed to resolve ens names" % names)}))

View File

@ -2,6 +2,7 @@
(:require [clojure.string :as string]
[re-frame.core :as re-frame]
[status-im.ethereum.abi-spec :as abi-spec]
[status-im.utils.config :as config]
[status-im.ethereum.decode :as decode]
[status-im.native-module.core :as status]
[status-im.utils.money :as money]
@ -64,6 +65,7 @@
"shhext_deleteMessagesByChatID" {}
"shhext_deleteMessage" {}
"shhext_markMessagesSeen" {}
"shhext_markAllRead" {}
"shhext_confirmMessagesProcessedByID" {}
"shhext_updateMessageOutgoingStatus" {}
"shhext_chatMessages" {}
@ -114,6 +116,7 @@
"wakuext_deleteMessagesByChatID" {}
"wakuext_deleteMessage" {}
"wakuext_markMessagesSeen" {}
"wakuext_markAllRead" {}
"wakuext_confirmMessagesProcessedByID" {}
"wakuext_updateMessageOutgoingStatus" {}
"wakuext_chatMessages" {}
@ -175,6 +178,11 @@
(call-method (update arg :number-of-retries dec)))
on-error))
(defn call-ext-method [method]
(if config/waku-enabled?
(str "wakuext_" method)
(str "shhext_" method)))
(defn call
[{:keys [method params on-success] :as arg}]
(if-let [method-options (json-rpc-api method)]

View File

@ -31,9 +31,7 @@
(fx/defn remove-member
"Format group update message and sign membership"
[{:keys [db] :as cofx} chat-id member]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_removeMemberFromGroupChat"
"shhext_removeMemberFromGroupChat")
{::json-rpc/call [{:method (json-rpc/call-ext-method "removeMemberFromGroupChat")
:params [nil chat-id member]
:on-success #(re-frame/dispatch [::chat-updated %])}]})
@ -76,43 +74,33 @@
(fx/defn join-chat
[cofx chat-id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_confirmJoiningGroup"
"shhext_confirmJoiningGroup")
{::json-rpc/call [{:method (json-rpc/call-ext-method "confirmJoiningGroup")
:params [chat-id]
:on-success #(re-frame/dispatch [::chat-updated %])}]})
(fx/defn create
[{:keys [db] :as cofx} group-name]
(let [selected-contacts (:group/selected-contacts db)]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_createGroupChatWithMembers"
"shhext_createGroupChatWithMembers")
{::json-rpc/call [{:method (json-rpc/call-ext-method "createGroupChatWithMembers")
:params [nil group-name (into [] selected-contacts)]
:on-success #(re-frame/dispatch [::chat-updated %])}]}))
(fx/defn make-admin
[{:keys [db] :as cofx} chat-id member]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_addAdminsToGroupChat"
"shhext_addAdminsToGroupChat")
{::json-rpc/call [{:method (json-rpc/call-ext-method "addAdminsToGroupChat")
:params [nil chat-id [member]]
:on-success #(re-frame/dispatch [::chat-updated %])}]})
(fx/defn add-members
"Add members to a group chat"
[{{:keys [current-chat-id selected-participants]} :db :as cofx}]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_addMembersToGroupChat"
"shhext_addMembersToGroupChat")
{::json-rpc/call [{:method (json-rpc/call-ext-method "addMembersToGroupChat")
:params [nil current-chat-id selected-participants]
:on-success #(re-frame/dispatch [::chat-updated %])}]})
(fx/defn remove
"Remove & leave chat"
[{:keys [db] :as cofx} chat-id]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_leaveGroupChat"
"shhext_leaveGroupChat")
{::json-rpc/call [{:method (json-rpc/call-ext-method "leaveGroupChat")
:params [nil chat-id]
:on-success #(re-frame/dispatch [::chat-updated %])}]})
@ -135,9 +123,7 @@
(let [new-name (get-in cofx [:db :group-chat-profile/profile :name])
current-chat-id (:current-chat-id db)]
(when (valid-name? new-name)
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_changeGroupChatName"
"shhext_changeGroupChatName")
{::json-rpc/call [{:method (json-rpc/call-ext-method "changeGroupChatName")
:params [nil current-chat-id new-name]
:on-success #(re-frame/dispatch [::chat-updated %])}]})))

View File

@ -89,9 +89,7 @@
;; as sent.
(defn update-mailservers! [enodes]
(json-rpc/call
{:method (if config/waku-enabled?
"wakuext_updateMailservers"
"shhext_updateMailservers")
{:method (json-rpc/call-ext-method "updateMailservers")
:params [enodes]
:on-success #(log/debug "mailserver: update-mailservers success" %)
:on-error #(log/error "mailserver: update-mailservers error" %)}))
@ -363,9 +361,7 @@
" cursor " cursor
" limit " actual-limit)
(json-rpc/call
{:method (if config/waku-enabled?
"wakuext_requestMessages"
"shhext_requestMessages")
{:method (json-rpc/call-ext-method "requestMessages")
:params [(cond-> {:topics topics
:mailServerPeer address
:symKeyID sym-key-id

View File

@ -10,9 +10,7 @@
(fx/defn send-multiaccount-update [{:keys [db]}]
(let [multiaccount (:multiaccount db)
{:keys [name preferred-name photo-path address]} multiaccount]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_sendContactUpdates"
"shhext_sendContactUpdates")
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendContactUpdates")
:params [(or preferred-name name) photo-path]
:on-success #(log/debug "sent contact update")}]}))

View File

@ -25,9 +25,7 @@
{:keys [name preferred-name photo-path address]} multiaccount]
(log/debug "sending contact updates")
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_sendContactUpdates"
"shhext_sendContactUpdates")
(json-rpc/call {:method (json-rpc/call-ext-method "sendContactUpdates")
:params [(or preferred-name name) photo-path]
:on-failure #(do
(log/warn "failed to send contact updates")

View File

@ -19,33 +19,25 @@
[status-im.utils.types :as types]))
(defn enable-installation-rpc [installation-id on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_enableInstallation"
"shhext_enableInstallation")
(json-rpc/call {:method (json-rpc/call-ext-method "enableInstallation")
:params [installation-id]
:on-success on-success
:on-failure on-failure}))
(defn disable-installation-rpc [installation-id on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_disableInstallation"
"shhext_disableInstallation")
(json-rpc/call {:method (json-rpc/call-ext-method "disableInstallation")
:params [installation-id]
:on-success on-success
:on-failure on-failure}))
(defn set-installation-metadata-rpc [installation-id metadata on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_setInstallationMetadata"
"shhext_setInstallationMetadata")
(json-rpc/call {:method (json-rpc/call-ext-method "setInstallationMetadata")
:params [installation-id metadata]
:on-success on-success
:on-failure on-failure}))
(defn get-our-installations-rpc [on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_getOurInstallations"
"shhext_getOurInstallations")
(json-rpc/call {:method (json-rpc/call-ext-method "getOurInstallations")
:params []
:on-success on-success
:on-failure on-failure}))
@ -73,9 +65,7 @@
(defn send-pair-installation
[cofx]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_sendPairInstallation"
"shhext_sendPairInstallation")
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendPairInstallation")
:params []
:on-success #(log/info "sent pair installation message")}]})
@ -199,9 +189,7 @@
(defn send-installation-messages [{:keys [db]}]
(let [multiaccount (:multiaccount db)
{:keys [name preferred-name photo-path]} multiaccount]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_syncDevices"
"shhext_syncDevices")
{::json-rpc/call [{:method (json-rpc/call-ext-method "syncDevices")
:params [(or preferred-name name) photo-path]
:on-success #(log/debug "successfully synced devices")}]}))

View File

@ -212,9 +212,7 @@
(fx/defn send-transaction-message
{:events [::send-transaction-message]}
[cofx chat-id value contract transaction-hash signature]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_sendTransaction"
"shhext_sendTransaction")
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendTransaction")
:params [chat-id value contract transaction-hash
(:result (types/json->clj signature))]
:on-success
@ -223,9 +221,7 @@
(fx/defn send-accept-request-transaction-message
{:events [::send-accept-transaction-message]}
[cofx message-id transaction-hash signature]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_acceptRequestTransaction"
"shhext_acceptRequestTransaction")
{::json-rpc/call [{:method (json-rpc/call-ext-method "acceptRequestTransaction")
:params [transaction-hash message-id
(:result (types/json->clj signature))]
:on-success

View File

@ -40,9 +40,7 @@
initializiation is completed, otherwise we might receive messages/topics
when the state has not been properly initialized."
[cofx]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_startMessenger"
"shhext_startMessenger")
{::json-rpc/call [{:method (json-rpc/call-ext-method "startMessenger")
:on-success #(do
(log/debug "messenger initialized")
(re-frame/dispatch [::init-whisper]))

View File

@ -18,17 +18,13 @@
(string/starts-with? k "0x"))
(defn load-filters-rpc [chats on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_loadFilters"
"shhext_loadFilters")
(json-rpc/call {:method (json-rpc/call-ext-method "loadFilters")
:params [chats]
:on-success on-success
:on-failure on-failure}))
(defn remove-filters-rpc [chats on-success on-failure]
(json-rpc/call {:method (if config/waku-enabled?
"wakuext_removeFilters"
"shhext_removeFilters")
(json-rpc/call {:method (json-rpc/call-ext-method "removeFilters")
:params [chats]
:on-success on-success
:on-failure on-failure}))

View File

@ -14,9 +14,7 @@
sticker
content-type]
:as message}]
{::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_sendChatMessage"
"shhext_sendChatMessage")
{::json-rpc/call [{:method (json-rpc/call-ext-method "sendChatMessage")
:params [{:chatId chat-id
:text text
:responseTo response-to

View File

@ -20,6 +20,8 @@
(when (and group-chat (not public?))
{:text (i18n/label :t/group-info)
:on-select #(re-frame/dispatch [:show-group-chat-profile])})
{:text (i18n/label :t/mark-all-read)
:on-select #(re-frame/dispatch [:chat.ui/mark-all-read-pressed chat-id])}
{:text (i18n/label :t/clear-history)
:on-select #(re-frame/dispatch [:chat.ui/clear-history-pressed chat-id])}
{:text (i18n/label :t/fetch-history)

View File

@ -37,6 +37,12 @@
:accessibility-label :view-chat-details-button
:accessories [:chevron]
:on-press #(hide-sheet-and-dispatch [:chat.ui/show-profile chat-id])}]
[list-item/list-item
{:theme :action
:title :t/mark-all-read
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]
[list-item/list-item
{:theme :action
:title :t/clear-history
@ -69,6 +75,12 @@
:on-press (fn []
(re-frame/dispatch [:bottom-sheet/hide-sheet])
(list-selection/open-share {:message message}))}])
[list-item/list-item
{:theme :action
:title :t/mark-all-read
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]
[list-item/list-item
{:theme :action
:title :t/clear-history
@ -99,6 +111,12 @@
contact group-chat chat-name color online]
:accessories [:chevron]
:on-press #(hide-sheet-and-dispatch [:show-group-chat-profile chat-id])}]
[list-item/list-item
{:theme :action
:title :t/mark-all-read
:accessibility-label :mark-all-read-button
:icon :main-icons/check
:on-press #(hide-sheet-and-dispatch [:chat.ui/mark-all-read-pressed chat-id])}]
[list-item/list-item
{:theme :action
:title :t/clear-history

View File

@ -407,9 +407,7 @@
[to-norm amount-hex])})}))
{:db db
::json-rpc/call
[{:method (if config/waku-enabled?
"wakuext_requestAddressForTransaction"
"shhext_requestAddressForTransaction")
[{:method (json-rpc/call-ext-method "requestAddressForTransaction")
:params [(:current-chat-id db)
from-address
amount
@ -428,9 +426,7 @@
{:db (-> db
(update-in [:chat-ui-props identity] dissoc :input-bottom-sheet)
(dissoc db :wallet/prepare-transaction))
::json-rpc/call [{:method (if config/waku-enabled?
"wakuext_requestTransaction"
"shhext_requestTransaction")
::json-rpc/call [{:method (json-rpc/call-ext-method "requestTransaction")
:params [(:public-key to)
amount
(when-not (= symbol :ETH)

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im",
"repo": "status-go",
"version": "v0.45.1",
"commit-sha1": "9c2c08d44c839895f7e98a0c8f652d094d53cb2f",
"src-sha256": "0b03q4znblj737bgdbxi7qqpxqamii5ja8hw8rk1br0lll4i1jcr"
"version": "v0.47.0",
"commit-sha1": "5cc60de80b315c12c8a0583705be8d5c35b073f2",
"src-sha256": "1zqbadpwg4iizfwzfmw38hf98hj3zf99a3svyj22bbwqnqaxpbh4"
}

View File

@ -655,6 +655,7 @@
"mainnet-text": "Youre on the Mainnet. Real ETH will be sent",
"maintain-card-to-phone-contact": "Maintain card-to-phone contact during process.",
"make-admin": "Make admin",
"mark-all-read": "Mark all read",
"maybe-later": "Maybe later",
"members": {
"one": "1 member",