Fetch history action
This commit is contained in:
parent
9afd76c7a8
commit
6e5d54b5aa
|
@ -609,6 +609,11 @@
|
||||||
:confirm-button-text (i18n/label :t/clear-history-action)
|
:confirm-button-text (i18n/label :t/clear-history-action)
|
||||||
:on-accept #(re-frame/dispatch [:chat.ui/clear-history])}}))
|
: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
|
(handlers/register-handler-fx
|
||||||
:chat.ui/remove-chat-pressed
|
:chat.ui/remove-chat-pressed
|
||||||
(fn [_ [_ chat-id]]
|
(fn [_ [_ chat-id]]
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
[status-im.native-module.core :as status]
|
[status-im.native-module.core :as status]
|
||||||
[status-im.transport.utils :as transport.utils]
|
[status-im.transport.utils :as transport.utils]
|
||||||
[status-im.utils.fx :as fx]
|
[status-im.utils.fx :as fx]
|
||||||
|
[status-im.constants :as constants]
|
||||||
[status-im.utils.utils :as utils]
|
[status-im.utils.utils :as utils]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[status-im.transport.db :as transport.db]
|
[status-im.transport.db :as transport.db]
|
||||||
|
@ -481,6 +482,20 @@
|
||||||
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
|
:data-store/tx [(data-store.mailservers/save-mailserver-topic-tx
|
||||||
{:topic topic
|
{:topic topic
|
||||||
:mailserver-topic mailserver-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
|
(fx/defn resend-request
|
||||||
[{:keys [db] :as cofx} {:keys [request-id]}]
|
[{:keys [db] :as cofx} {:keys [request-id]}]
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
:on-select #(re-frame/dispatch [:show-group-chat-profile])})
|
:on-select #(re-frame/dispatch [:show-group-chat-profile])})
|
||||||
{:text (i18n/label :t/clear-history)
|
{:text (i18n/label :t/clear-history)
|
||||||
:on-select #(re-frame/dispatch [:chat.ui/clear-history-pressed])}
|
: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)
|
{:text (i18n/label :t/delete-chat)
|
||||||
:on-select #(re-frame/dispatch [(if (and group-chat (not public?))
|
:on-select #(re-frame/dispatch [(if (and group-chat (not public?))
|
||||||
:group-chats.ui/remove-chat-pressed
|
:group-chats.ui/remove-chat-pressed
|
||||||
|
|
|
@ -26,6 +26,10 @@
|
||||||
{:label (i18n/label :t/clear-history)
|
{:label (i18n/label :t/clear-history)
|
||||||
:action #(re-frame/dispatch [:chat.ui/clear-history-pressed])})
|
: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?]
|
(defn- delete-chat [chat-id group?]
|
||||||
{:label (i18n/label :t/delete-chat)
|
{:label (i18n/label :t/delete-chat)
|
||||||
:action #(re-frame/dispatch [(if group?
|
:action #(re-frame/dispatch [(if group?
|
||||||
|
@ -37,18 +41,21 @@
|
||||||
[view-my-wallet
|
[view-my-wallet
|
||||||
(view-profile chat-id)
|
(view-profile chat-id)
|
||||||
(clear-history)
|
(clear-history)
|
||||||
|
(fetch-history chat-id)
|
||||||
(delete-chat chat-id false)])
|
(delete-chat chat-id false)])
|
||||||
|
|
||||||
(defn- group-chat-actions [chat-id]
|
(defn- group-chat-actions [chat-id]
|
||||||
[view-my-wallet
|
[view-my-wallet
|
||||||
(group-info chat-id)
|
(group-info chat-id)
|
||||||
(clear-history)
|
(clear-history)
|
||||||
|
(fetch-history chat-id)
|
||||||
(delete-chat chat-id true)])
|
(delete-chat chat-id true)])
|
||||||
|
|
||||||
(defn- public-chat-actions [chat-id]
|
(defn- public-chat-actions [chat-id]
|
||||||
[view-my-wallet
|
[view-my-wallet
|
||||||
(share-chat chat-id)
|
(share-chat chat-id)
|
||||||
(clear-history)
|
(clear-history)
|
||||||
|
(fetch-history chat-id)
|
||||||
(delete-chat chat-id false)])
|
(delete-chat chat-id false)])
|
||||||
|
|
||||||
(defn actions [group-chat? chat-id public?]
|
(defn actions [group-chat? chat-id public?]
|
||||||
|
|
|
@ -526,6 +526,7 @@
|
||||||
"and-you": "and you",
|
"and-you": "and you",
|
||||||
"wallets": "Wallets",
|
"wallets": "Wallets",
|
||||||
"clear-history": "Clear history",
|
"clear-history": "Clear history",
|
||||||
|
"fetch-history": "Fetch last 24 hours",
|
||||||
"currency-display-name-sgd": "Singapore Dollar",
|
"currency-display-name-sgd": "Singapore Dollar",
|
||||||
"wallet-manage-assets": "Manage Assets",
|
"wallet-manage-assets": "Manage Assets",
|
||||||
"wallet-choose-from-contacts": "Choose from Contacts",
|
"wallet-choose-from-contacts": "Choose from Contacts",
|
||||||
|
|
Loading…
Reference in New Issue