diff --git a/STATUS_GO_VERSION b/STATUS_GO_VERSION index 2a0970ca75..7eb3095a32 100644 --- a/STATUS_GO_VERSION +++ b/STATUS_GO_VERSION @@ -1 +1 @@ -0.16.1 +0.16.3 diff --git a/modules/react-native-status/desktop/CMakeLists.txt b/modules/react-native-status/desktop/CMakeLists.txt index 41c3c75d1d..7b9aacf243 100755 --- a/modules/react-native-status/desktop/CMakeLists.txt +++ b/modules/react-native-status/desktop/CMakeLists.txt @@ -37,7 +37,7 @@ ExternalProject_Add(StatusGo_ep PREFIX ${StatusGo_PREFIX} SOURCE_DIR ${StatusGo_SOURCE_DIR} GIT_REPOSITORY https://github.com/status-im/status-go.git - GIT_TAG 9f8f0089a3561e77b25279575928de8caba373cc + GIT_TAG c86f8bf6ca35280e7041674f76a2ef1fe333e482 BUILD_BYPRODUCTS ${StatusGo_STATIC_LIB} CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${CONFIGURE_SCRIPT} ${GO_ROOT_PATH} ${StatusGo_ROOT} ${StatusGo_SOURCE_DIR} diff --git a/src/status_im/signals/core.cljs b/src/status_im/signals/core.cljs index b3ce15b71a..52b7e03d0b 100644 --- a/src/status_im/signals/core.cljs +++ b/src/status_im/signals/core.cljs @@ -56,8 +56,8 @@ "envelope.sent" (transport.message/update-envelope-status cofx (:hash event) :sent) "envelope.expired" (transport.message/update-envelope-status cofx (:hash event) :sent) "mailserver.request.completed" (when (accounts.db/logged-in? cofx) - (inbox/update-inbox-topic cofx {:request-id (:requestID event) - :cursor (:cursor event)})) + (inbox/update-inbox-topics cofx {:request-id (:requestID event) + :cursor (:cursor event)})) "mailserver.request.expired" (when (accounts.db/logged-in? cofx) (inbox/resend-request cofx {:request-id (:hash event)})) "discovery.summary" (summary cofx event) diff --git a/src/status_im/transport/db.cljs b/src/status_im/transport/db.cljs index 2e25aa9015..a53c54bf26 100644 --- a/src/status_im/transport/db.cljs +++ b/src/status_im/transport/db.cljs @@ -15,6 +15,7 @@ ;; optional (spec/def ::topic (spec/nilable string?)) +(spec/def ::topics (spec/coll-of ::topic :min-count 1)) (spec/def ::sym-key-id (spec/nilable string?)) ;;TODO (yenda) remove once go implements persistence (spec/def ::sym-key (spec/nilable string?)) @@ -25,8 +26,6 @@ (spec/def :request/to pos-int?) (spec/def :request/attemps int?) (spec/def :request/cursor :global/not-empty-string) -(spec/def :transport.inbox/request (spec/keys :req-un [:request/from :request/to ::topic] - :opt-un [:request/attemps])) (spec/def :transport.inbox.topic/last-request pos-int?) (spec/def :transport.inbox.topic/started-at pos-int?) @@ -36,18 +35,18 @@ :kind set? :min-count 1)) -(spec/def :transport.inbox/topic (allowed-keys :req-un [:transport.inbox.topic/last-request - :transport.inbox.topic/chat-ids] - :opt-un [:transport.inbox.topic/started-at])) -(spec/def :transport/chat (allowed-keys :req-un [::ack ::seen ::pending-ack ::pending-send ::topic] - :opt-un [::sym-key-id ::sym-key ::resend?])) +(spec/def :transport.inbox/topic (spec/keys :req-un [:transport.inbox.topic/last-request + :transport.inbox.topic/chat-ids])) +(spec/def :transport/chat (spec/keys :req-un [::ack ::seen ::pending-ack ::pending-send ::topic] + :opt-un [::sym-key-id ::sym-key ::resend?])) (spec/def :transport.inbox/request-to :request/to) (spec/def :transport/chats (spec/map-of :global/not-empty-string :transport/chat)) (spec/def :transport/filters (spec/map-of :transport/filter-id :transport/filter)) (spec/def :transport.inbox/connection-checks pos-int?) (spec/def :transport.inbox/topics (spec/map-of :global/not-empty-string :transport.inbox/topic)) -(spec/def :transport.inbox/current-request :transport.inbox/request) +(spec/def :transport.inbox/current-request (spec/keys :req-un [:request/from :request/to ::topics] + :opt-un [:request/attemps])) (spec/def :transport.inbox/pending-requests integer?) (defn create-chat diff --git a/src/status_im/transport/inbox.cljs b/src/status_im/transport/inbox.cljs index 19b8c0f056..70cd954efb 100644 --- a/src/status_im/transport/inbox.cljs +++ b/src/status_im/transport/inbox.cljs @@ -170,13 +170,13 @@ mailserver-removed? (connect-to-mailserver cofx))))) -(defn request-messages! [web3 {:keys [sym-key-id address]} {:keys [topic to from]}] +(defn request-messages! [web3 {:keys [sym-key-id address]} {:keys [topics to from]}] (log/info "offline inbox: request-messages for: " - " topic " topic + " topics " topics " from " from " to " to) (.requestMessages (transport.utils/shh web3) - (clj->js {:topic topic + (clj->js {:topics topics :mailServerPeer address :symKeyID sym-key-id :timeout request-timeout @@ -184,8 +184,8 @@ :to to}) (fn [error request-id] (if-not error - (log/info "offline inbox: messages request success for topic " topic "from" from "to" to) - (log/error "offline inbox: messages request error for topic " topic ": " error))))) + (log/info "offline inbox: messages request success for topic " topics "from" from "to" to) + (log/error "offline inbox: messages request error for topic " topics ": " error))))) (re-frame/reg-fx :transport.inbox/request-messages @@ -205,7 +205,7 @@ "NOTE: currently the mailserver is only accepting requests for a span of 24 hours, so we split requests per 24h spans if the last request was done more than 24h ago" - [now-in-s [topic {:keys [last-request]}]] + [now-in-s [last-request topics]] (let [days (conj (into [] (range (max last-request (- now-in-s one-day)) @@ -214,7 +214,7 @@ now-in-s) day-ranges (map vector days (rest days))] (for [[from to] day-ranges] - {:topic topic + {:topics topics :from from :to to}))) @@ -223,7 +223,10 @@ (let [web3 (:web3 db)] (remove nil? (mapcat (partial split-request-per-day request-to) - (:transport.inbox/topics db))))) + (reduce (fn [acc [topic {:keys [last-request]}]] + (update acc last-request conj topic)) + {} + (:transport.inbox/topics db)))))) (fx/defn process-next-messages-request [{:keys [db now] :as cofx}] @@ -325,29 +328,38 @@ {:topic topic :inbox-topic inbox-topic})]}))) -(fx/defn update-inbox-topic +(defn get-updated-inbox-topics [db topics last-request] + (reduce (fn [acc topic] + (if-let [inbox-topic (some-> (get-in db [:transport.inbox/topics topic]) + (assoc :last-request last-request))] + (assoc acc topic inbox-topic) + acc)) + {} + topics)) + +(fx/defn update-inbox-topics "TODO: add support for cursors if there is a cursor, do not update `last-request`" - [{:keys [db now] :as cofx} {:keys [request-id cursor]}] + [{:keys [db now] :as cofx} {:keys [request-id]}] (when-let [request (get db :transport.inbox/current-request)] - (let [{:keys [from to topic]} request - inbox-topic (some-> (get-in db [:transport.inbox/topics topic]) - (assoc :last-request to))] + (let [{:keys [from to topics]} request + inbox-topics (get-updated-inbox-topics db topics to)] (log/info "offline inbox: message request " request-id - "completed for inbox topic" topic "from" from "to" to) - (if inbox-topic - (fx/merge cofx - (if inbox-topic - {:db (-> db - (dissoc :transport.inbox/current-request) - (assoc-in [:transport.inbox/topics topic] inbox-topic)) - :data-store/tx [(transport-store/save-transport-inbox-topic-tx - {:topic topic - :inbox-topic inbox-topic})]}) - (process-next-messages-request)) - ;; when the topic was deleted (filter was removed while request was pending) + "completed for inbox topics" topics "from" from "to" to) + (if (empty? inbox-topics) + ;; when topics were deleted (filter was removed while request was pending) (fx/merge cofx {:db (dissoc db :transport.inbox/current-request)} + (process-next-messages-request)) + (fx/merge cofx + {:db (-> db + (dissoc :transport.inbox/current-request) + (update :transport.inbox/topics merge inbox-topics)) + :data-store/tx (mapv (fn [[topic inbox-topic]] + (transport-store/save-transport-inbox-topic-tx + {:topic topic + :inbox-topic inbox-topic})) + inbox-topics)} (process-next-messages-request)))))) (fx/defn upsert-inbox-topic @@ -378,9 +390,9 @@ {:db (update db :transport.inbox/current-request dissoc :attemps)} (change-mailserver)) (when-let [wnode (get-wnode-when-ready cofx)] - (let [{:keys [topic from to] :as request} (get db :transport.inbox/current-request) + (let [{:keys [topics from to] :as request} (get db :transport.inbox/current-request) web3 (:web3 db)] - (log/info "offline inbox: message request " request-id "expired for inbox topic" topic "from" from "to" to) + (log/info "offline inbox: message request " request-id "expired for inbox topic" topics "from" from "to" to) {:db (update-in db [:transport.inbox/current-request :attemps] inc) :transport.inbox/request-messages {:web3 web3 :wnode wnode diff --git a/src/status_im/ui/components/connectivity/view.cljs b/src/status_im/ui/components/connectivity/view.cljs index 097df0fee7..19817a8588 100644 --- a/src/status_im/ui/components/connectivity/view.cljs +++ b/src/status_im/ui/components/connectivity/view.cljs @@ -20,7 +20,7 @@ [react/text {:style styles/text :on-press (when mailserver-error? #(re-frame/dispatch [:inbox.ui/reconnect-mailserver-pressed]))} - (if fetching? + (if (and (not mailserver-error?) fetching?) (i18n/label :t/fetching-messages {:requests-left (str fetching?)}) (i18n/label label))]]))