Fetch history action

This commit is contained in:
Andrea Maria Piana 2018-12-12 09:55:59 +01:00
parent 9afd76c7a8
commit 6e5d54b5aa
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 30 additions and 0 deletions

View File

@ -609,6 +609,11 @@
:confirm-button-text (i18n/label :t/clear-history-action)
:on-accept #(re-frame/dispatch [:chat.ui/clear-history])}}))
(handlers/register-handler-fx
:chat.ui/fetch-history-pressed
(fn [cofx [_ chat-id]]
(mailserver/fetch-history cofx chat-id)))
(handlers/register-handler-fx
:chat.ui/remove-chat-pressed
(fn [_ [_ chat-id]]

View File

@ -7,6 +7,7 @@
[status-im.native-module.core :as status]
[status-im.transport.utils :as transport.utils]
[status-im.utils.fx :as fx]
[status-im.constants :as constants]
[status-im.utils.utils :as utils]
[taoensso.timbre :as log]
[status-im.transport.db :as transport.db]
@ -481,6 +482,20 @@
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
{:topic topic
:mailserver-topic mailserver-topic})]}))))
(fx/defn fetch-history
[{:keys [db] :as cofx} chat-id]
(let [topic (or (get-in db [:transport/chats chat-id :topic])
(transport.utils/get-topic constants/contact-discovery))
{:keys [chat-ids last-request] :as current-mailserver-topic}
(get-in db [:mailserver/topics topic] {:chat-ids #{}})]
(let [mailserver-topic (-> current-mailserver-topic
(assoc :last-request 1))]
(fx/merge cofx
{:db (assoc-in db [:mailserver/topics topic] mailserver-topic)
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
{:topic topic
:mailserver-topic mailserver-topic})]}
(process-next-messages-request)))))
(fx/defn resend-request
[{:keys [db] :as cofx} {:keys [request-id]}]

View File

@ -19,6 +19,8 @@
:on-select #(re-frame/dispatch [:show-group-chat-profile])})
{:text (i18n/label :t/clear-history)
:on-select #(re-frame/dispatch [:chat.ui/clear-history-pressed])}
{:text (i18n/label :t/fetch-history)
:on-select #(re-frame/dispatch [:chat.ui/fetch-history-pressed chat-id])}
{:text (i18n/label :t/delete-chat)
:on-select #(re-frame/dispatch [(if (and group-chat (not public?))
:group-chats.ui/remove-chat-pressed

View File

@ -26,6 +26,10 @@
{:label (i18n/label :t/clear-history)
:action #(re-frame/dispatch [:chat.ui/clear-history-pressed])})
(defn fetch-history [chat-id]
{:label (i18n/label :t/fetch-history)
:action #(re-frame/dispatch [:chat.ui/fetch-history-pressed chat-id])})
(defn- delete-chat [chat-id group?]
{:label (i18n/label :t/delete-chat)
:action #(re-frame/dispatch [(if group?
@ -37,18 +41,21 @@
[view-my-wallet
(view-profile chat-id)
(clear-history)
(fetch-history chat-id)
(delete-chat chat-id false)])
(defn- group-chat-actions [chat-id]
[view-my-wallet
(group-info chat-id)
(clear-history)
(fetch-history chat-id)
(delete-chat chat-id true)])
(defn- public-chat-actions [chat-id]
[view-my-wallet
(share-chat chat-id)
(clear-history)
(fetch-history chat-id)
(delete-chat chat-id false)])
(defn actions [group-chat? chat-id public?]

View File

@ -526,6 +526,7 @@
"and-you": "and you",
"wallets": "Wallets",
"clear-history": "Clear history",
"fetch-history": "Fetch last 24 hours",
"currency-display-name-sgd": "Singapore Dollar",
"wallet-manage-assets": "Manage Assets",
"wallet-choose-from-contacts": "Choose from Contacts",