2018-09-06 10:04:12 +00:00
|
|
|
(ns status-im.events
|
2019-06-03 07:42:29 +00:00
|
|
|
(:require [clojure.string :as string]
|
|
|
|
[re-frame.core :as re-frame]
|
2019-07-03 14:29:01 +00:00
|
|
|
[status-im.multiaccounts.core :as multiaccounts]
|
|
|
|
[status-im.multiaccounts.create.core :as multiaccounts.create]
|
|
|
|
[status-im.multiaccounts.login.core :as multiaccounts.login]
|
|
|
|
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
|
|
|
|
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
|
|
|
|
[status-im.multiaccounts.update.core :as multiaccounts.update]
|
2019-09-15 15:20:10 +00:00
|
|
|
status-im.multiaccounts.biometric.core
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.bootnodes.core :as bootnodes]
|
2018-09-21 13:41:40 +00:00
|
|
|
[status-im.browser.core :as browser]
|
|
|
|
[status-im.browser.permissions :as browser.permissions]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.chat.commands.core :as commands]
|
2018-10-09 08:10:47 +00:00
|
|
|
[status-im.chat.commands.input :as commands.input]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.chat.db :as chat.db]
|
2018-09-24 16:27:04 +00:00
|
|
|
[status-im.chat.models :as chat]
|
|
|
|
[status-im.chat.models.input :as chat.input]
|
2018-10-09 08:10:47 +00:00
|
|
|
[status-im.chat.models.loading :as chat.loading]
|
|
|
|
[status-im.chat.models.message :as chat.message]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.contact.block :as contact.block]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.contact.core :as contact]
|
2019-06-03 07:42:29 +00:00
|
|
|
[status-im.ethereum.core :as ethereum]
|
|
|
|
[status-im.ethereum.ens :as ethereum.ens]
|
2019-05-08 23:33:19 +00:00
|
|
|
[status-im.ethereum.subscriptions :as ethereum.subscriptions]
|
2019-05-13 11:44:46 +00:00
|
|
|
[status-im.ethereum.transactions.core :as ethereum.transactions]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.fleet.core :as fleet]
|
2018-07-19 15:51:06 +00:00
|
|
|
[status-im.group-chats.core :as group-chats]
|
2018-09-18 16:27:58 +00:00
|
|
|
[status-im.hardwallet.core :as hardwallet]
|
2019-07-03 18:38:10 +00:00
|
|
|
[status-im.signing.keycard :as signing.keycard]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.i18n :as i18n]
|
|
|
|
[status-im.init.core :as init]
|
|
|
|
[status-im.log-level.core :as log-level]
|
|
|
|
[status-im.mailserver.core :as mailserver]
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
[status-im.mailserver.constants :as mailserver.constants]
|
|
|
|
[status-im.mailserver.topics :as mailserver.topics]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.node.core :as node]
|
2018-10-09 10:43:07 +00:00
|
|
|
[status-im.pairing.core :as pairing]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.privacy-policy.core :as privacy-policy]
|
|
|
|
[status-im.protocol.core :as protocol]
|
|
|
|
[status-im.qr-scanner.core :as qr-scanner]
|
2018-10-13 16:47:34 +00:00
|
|
|
[status-im.search.core :as search]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.signals.core :as signals]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.stickers.core :as stickers]
|
2019-02-22 13:12:29 +00:00
|
|
|
[status-im.transport.core :as transport]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.transport.message.core :as transport.message]
|
2019-06-17 09:41:37 +00:00
|
|
|
status-im.wallet.choose-recipient.core
|
|
|
|
status-im.wallet.collectibles.core
|
|
|
|
status-im.wallet.accounts.core
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.ui.components.bottom-sheet.core :as bottom-sheet]
|
|
|
|
[status-im.ui.components.react :as react]
|
|
|
|
[status-im.ui.screens.add-new.new-chat.db :as new-chat.db]
|
|
|
|
[status-im.ui.screens.currency-settings.models
|
|
|
|
:as
|
|
|
|
currency-settings.models]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.ui.screens.navigation :as navigation]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.utils.build :as build]
|
|
|
|
[status-im.utils.config :as config]
|
2018-09-24 15:59:02 +00:00
|
|
|
[status-im.utils.fx :as fx]
|
2018-09-06 10:04:12 +00:00
|
|
|
[status-im.utils.handlers :as handlers]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.utils.logging.core :as logging]
|
2018-10-16 09:48:12 +00:00
|
|
|
[status-im.utils.utils :as utils]
|
2019-05-18 11:06:42 +00:00
|
|
|
[status-im.wallet.core :as wallet]
|
2019-02-22 12:26:40 +00:00
|
|
|
[status-im.wallet.custom-tokens.core :as custom-tokens]
|
2019-05-17 10:02:16 +00:00
|
|
|
[status-im.wallet.db :as wallet.db]
|
2019-06-17 09:41:37 +00:00
|
|
|
[taoensso.timbre :as log]
|
|
|
|
[status-im.chat.commands.sending :as commands.sending]
|
2019-07-08 11:38:47 +00:00
|
|
|
[status-im.utils.money :as money]
|
|
|
|
status-im.popover.core))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
;; init module
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:init/app-started
|
|
|
|
(fn [cofx _]
|
2018-09-28 14:48:59 +00:00
|
|
|
(init/start-app cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
;; multiaccounts module
|
2019-01-25 13:07:33 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.update.callback/published
|
2019-01-25 13:07:33 +00:00
|
|
|
(fn [{:keys [now] :as cofx} _]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.update/multiaccount-update cofx {:last-updated now} {})))
|
2019-01-25 13:07:33 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.update.callback/failed-to-publish
|
2019-01-25 13:07:33 +00:00
|
|
|
(fn [{:keys [now] :as cofx} [_ message]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(log/warn "failed to publish multiaccount update" message)
|
|
|
|
(multiaccounts.update/multiaccount-update cofx {:last-updated now} {})))
|
2019-01-25 13:07:33 +00:00
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/dev-mode-switched
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx [_ dev-mode?]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/switch-dev-mode cofx dev-mode?)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-03-19 12:24:57 +00:00
|
|
|
(def CUD-url "https://chaos-unicorn-day.org")
|
|
|
|
|
|
|
|
(defn open-chaos-unicorn-day-link []
|
2019-08-26 12:57:26 +00:00
|
|
|
(.openURL react/linking CUD-url))
|
2019-03-19 12:24:57 +00:00
|
|
|
|
2019-03-18 14:41:25 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/chaos-mode-switched
|
2019-03-19 12:24:57 +00:00
|
|
|
(fn [{:keys [db] :as cofx} [_ chaos-mode?]]
|
2019-08-01 20:11:59 +00:00
|
|
|
(let [old-chaos-mode? (get-in db [:multiaccount :chaos-mode?])]
|
2019-03-26 13:17:16 +00:00
|
|
|
(fx/merge
|
|
|
|
cofx
|
|
|
|
(when (and chaos-mode?
|
|
|
|
(not= old-chaos-mode? chaos-mode?))
|
|
|
|
{:ui/show-confirmation
|
|
|
|
{:title (i18n/label :t/chaos-unicorn-day)
|
|
|
|
:content (i18n/label :t/chaos-unicorn-day-details)
|
|
|
|
:confirm-button-text (i18n/label :t/see-details)
|
|
|
|
:cancel-button-text (i18n/label :t/cancel)
|
|
|
|
:on-accept open-chaos-unicorn-day-link}})
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/switch-chaos-mode chaos-mode?)))))
|
2019-03-18 14:41:25 +00:00
|
|
|
|
2018-10-19 15:50:35 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/notifications-enabled
|
2018-10-19 15:50:35 +00:00
|
|
|
(fn [cofx [_ desktop-notifications?]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/enable-notifications cofx desktop-notifications?)))
|
2018-10-19 15:50:35 +00:00
|
|
|
|
2019-07-26 08:12:10 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:multiaccounts.ui/toggle-datasync
|
|
|
|
(fn [cofx [_ enabled?]]
|
|
|
|
(multiaccounts/toggle-datasync cofx enabled?)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:multiaccounts.ui/toggle-v1-messages
|
|
|
|
(fn [cofx [_ enabled?]]
|
|
|
|
(multiaccounts/toggle-v1-messages cofx enabled?)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:multiaccounts.ui/toggle-disable-discovery-topic
|
|
|
|
(fn [cofx [_ enabled?]]
|
|
|
|
(multiaccounts/toggle-disable-discovery-topic cofx enabled?)))
|
|
|
|
|
2018-09-05 15:31:57 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/web3-opt-in-mode-switched
|
2018-09-05 15:31:57 +00:00
|
|
|
(fn [cofx [_ opt-in]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/switch-web3-opt-in-mode cofx opt-in)))
|
2018-09-05 15:31:57 +00:00
|
|
|
|
2019-05-08 12:26:39 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/preview-privacy-mode-switched
|
2019-05-08 12:26:39 +00:00
|
|
|
(fn [cofx [_ private?]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/switch-preview-privacy-mode cofx private?)))
|
2019-05-08 12:26:39 +00:00
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.ui/wallet-set-up-confirmed
|
2019-07-08 11:38:47 +00:00
|
|
|
(fn [cofx _]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts/confirm-wallet-set-up cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
;; multiaccounts login module
|
2018-09-06 10:04:12 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.login.ui/multiaccount-selected
|
2019-08-01 20:11:59 +00:00
|
|
|
(fn [cofx [_ address photo-path name public-key]]
|
|
|
|
(multiaccounts.login/open-login cofx address photo-path name public-key)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
;; multiaccounts logout module
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.logout.ui/logout-pressed
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx _]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.logout/show-logout-confirmation cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.logout.ui/logout-confirmed
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx _]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.logout/logout cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-07-03 14:29:01 +00:00
|
|
|
;; multiaccounts update module
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-07-03 14:29:01 +00:00
|
|
|
:multiaccounts.update.callback/save-settings-success
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx _]
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.logout/logout cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
;; mailserver module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/user-defined-mailserver-selected
|
|
|
|
(fn [cofx [_ mailserver-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/edit cofx mailserver-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/default-mailserver-selected
|
|
|
|
(fn [cofx [_ mailserver-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/show-connection-confirmation cofx mailserver-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/add-pressed
|
|
|
|
(fn [cofx _]
|
2018-09-24 15:59:02 +00:00
|
|
|
(navigation/navigate-to-cofx cofx :edit-mailserver nil)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/save-pressed
|
2018-09-24 16:27:04 +00:00
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/upsert cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/input-changed
|
|
|
|
(fn [cofx [_ input-key value]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/set-input cofx input-key value)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/delete-confirmed
|
|
|
|
(fn [cofx [_ mailserver-id]]
|
2018-10-18 00:05:02 +00:00
|
|
|
(mailserver/delete cofx mailserver-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/delete-pressed
|
|
|
|
(fn [cofx [_ mailserver-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/show-delete-confirmation cofx mailserver-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/qr-code-scanned
|
|
|
|
(fn [cofx [_ _ url]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/set-url-from-qr cofx url)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-02-21 11:24:38 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/resend-request
|
|
|
|
(fn [cofx [_ request]]
|
|
|
|
(mailserver/resend-request cofx request)))
|
|
|
|
|
2018-09-18 08:13:35 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/connect-pressed
|
2019-03-19 12:24:57 +00:00
|
|
|
(fn [cofx [_ mailserver-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/show-connection-confirmation cofx mailserver-id)))
|
2018-09-18 08:13:35 +00:00
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/connect-confirmed
|
|
|
|
(fn [cofx [_ current-fleet mailserver-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(mailserver/save-settings cofx current-fleet mailserver-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2018-10-18 00:05:02 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/reconnect-mailserver-pressed
|
2018-11-22 09:22:02 +00:00
|
|
|
(fn [cofx _]
|
2018-10-18 00:05:02 +00:00
|
|
|
(mailserver/connect-to-mailserver cofx)))
|
|
|
|
|
2019-03-01 09:36:49 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/unpin-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/unpin cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/pin-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/pin cofx)))
|
|
|
|
|
2018-11-22 09:22:02 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/request-error-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/show-request-error-popup cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.ui/retry-request-pressed
|
|
|
|
(fn [cofx [_ args]]
|
|
|
|
(mailserver/retry-next-messages-request cofx)))
|
|
|
|
|
2018-10-18 00:05:02 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver/check-connection-timeout
|
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/check-connection cofx)))
|
|
|
|
|
2019-01-31 12:32:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver/fetch-history
|
|
|
|
(fn [cofx [_ chat-id from-timestamp]]
|
2019-04-04 13:55:35 +00:00
|
|
|
(mailserver/fetch-history cofx chat-id {:from from-timestamp})))
|
2019-01-31 12:32:06 +00:00
|
|
|
|
2018-10-18 00:05:02 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/generate-mailserver-symkey-success
|
|
|
|
(fn [cofx [_ mailserver sym-key-id]]
|
|
|
|
(mailserver/add-mailserver-sym-key cofx mailserver sym-key-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/mark-trusted-peer-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(mailserver/add-mailserver-trusted cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/mark-trusted-peer-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(log/error "Error on mark-trusted-peer: " error)
|
|
|
|
(mailserver/check-connection cofx)))
|
|
|
|
|
2019-02-19 08:24:53 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/request-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(mailserver/handle-request-error cofx error)))
|
|
|
|
|
2019-02-27 11:50:41 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:mailserver.callback/request-success
|
|
|
|
(fn [cofx [_ request-id]]
|
|
|
|
(mailserver/handle-request-success cofx request-id)))
|
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
;; fleet module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:fleet.ui/save-fleet-confirmed
|
|
|
|
(fn [cofx [_ fleet]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(fleet/save cofx fleet)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:fleet.ui/fleet-selected
|
|
|
|
(fn [cofx [_ fleet]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(fleet/show-save-confirmation cofx fleet)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
;; bootnodes module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bootnodes.ui/custom-bootnodes-switch-toggled
|
|
|
|
(fn [cofx [_ value]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(bootnodes/toggle-custom-bootnodes cofx value)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bootnodes.ui/add-bootnode-pressed
|
|
|
|
(fn [cofx [_ bootnode-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(bootnodes/edit cofx bootnode-id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2018-09-18 08:19:13 +00:00
|
|
|
:bootnodes.callback/qr-code-scanned
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx [_ _ url]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(bootnodes/set-bootnodes-from-qr cofx url)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bootnodes.ui/input-changed
|
|
|
|
(fn [cofx [_ input-key value]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(bootnodes/set-input cofx input-key value)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2018-09-18 08:19:13 +00:00
|
|
|
:bootnodes.ui/save-pressed
|
2018-09-24 16:27:04 +00:00
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2018-09-06 10:04:12 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(bootnodes/upsert cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bootnodes.ui/delete-pressed
|
2019-03-14 07:31:15 +00:00
|
|
|
(fn [cofx [_ id]]
|
|
|
|
(bootnodes/show-delete-bootnode-confirmation cofx id)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bootnodes.ui/delete-confirmed
|
|
|
|
(fn [cofx [_ bootnode-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(bootnodes/delete-bootnode cofx bootnode-id)))
|
2018-10-11 15:22:43 +00:00
|
|
|
|
2018-12-15 18:57:00 +00:00
|
|
|
;; logging module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:logging.ui/send-logs-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(logging/send-logs cofx)))
|
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
;; log-level module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:log-level.ui/change-log-level-confirmed
|
|
|
|
(fn [cofx [_ log-level]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(log-level/save-log-level cofx log-level)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:log-level.ui/log-level-selected
|
|
|
|
(fn [cofx [_ log-level]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(log-level/show-change-log-level-confirmation cofx log-level)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2018-12-13 15:42:28 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:log-level.ui/logging-enabled
|
|
|
|
(fn [cofx [_ enabled]]
|
|
|
|
(log/debug "### :log-level.ui/logging-enabled" enabled)
|
|
|
|
|
|
|
|
(log-level/show-logging-enabled-confirmation cofx enabled)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:log-level.ui/logging-enabled-confirmed
|
|
|
|
(fn [cofx [_ enabled]]
|
|
|
|
(log-level/save-logging-enabled cofx enabled)))
|
|
|
|
|
2018-09-13 14:07:42 +00:00
|
|
|
;; Browser bridge module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.bridge.callback/qr-code-scanned
|
2018-10-02 14:14:35 +00:00
|
|
|
(fn [cofx [_ _ data qr-code-data]]
|
|
|
|
(browser/handle-scanned-qr-code cofx data (:data qr-code-data))))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.bridge.callback/qr-code-canceled
|
|
|
|
(fn [cofx [_ _ qr-code-data]]
|
|
|
|
(browser/handle-canceled-qr-code cofx (:data qr-code-data))))
|
2018-09-13 14:07:42 +00:00
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
;; qr-scanner module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:qr-scanner.ui/scan-qr-code-pressed
|
2018-09-13 14:07:42 +00:00
|
|
|
(fn [cofx [_ identifier handler & [opts]]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(qr-scanner/scan-qr-code cofx identifier (merge {:handler handler} opts))))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:qr-scanner.callback/scan-qr-code-success
|
|
|
|
(fn [cofx [_ context data]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(qr-scanner/set-qr-code cofx context data)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2018-10-02 14:14:35 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:qr-scanner.callback/scan-qr-code-cancel
|
|
|
|
(fn [cofx [_ context]]
|
|
|
|
(qr-scanner/set-qr-code-cancel cofx context)))
|
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
;; privacy-policy module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:privacy-policy/privacy-policy-button-pressed
|
2018-09-24 15:59:02 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(privacy-policy/open-privacy-policy-link cofx)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
;; wallet modules
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.settings.ui/currency-selected
|
|
|
|
(fn [cofx [_ currency]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(currency-settings.models/set-currency cofx currency)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
|
|
|
;; chat module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/clear-history-pressed
|
|
|
|
(fn [_ _]
|
2018-09-24 16:27:04 +00:00
|
|
|
{:ui/show-confirmation {:title (i18n/label :t/clear-history-title)
|
|
|
|
:content (i18n/label :t/clear-history-confirmation-content)
|
2018-09-06 10:04:12 +00:00
|
|
|
:confirm-button-text (i18n/label :t/clear-history-action)
|
2018-09-24 16:27:04 +00:00
|
|
|
:on-accept #(re-frame/dispatch [:chat.ui/clear-history])}}))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2018-12-12 08:55:59 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/fetch-history-pressed
|
2019-04-04 13:55:35 +00:00
|
|
|
(fn [{:keys [now] :as cofx} [_ chat-id]]
|
|
|
|
(mailserver/fetch-history cofx chat-id
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
{:from (- (quot now 1000) mailserver.constants/one-day)})))
|
2019-04-16 19:09:18 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/fetch-history-pressed48-60
|
|
|
|
(fn [{:keys [now] :as cofx} [_ chat-id]]
|
|
|
|
(let [now (quot now 1000)]
|
|
|
|
(mailserver/fetch-history cofx chat-id
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
{:from (- now (* 2.5 mailserver.constants/one-day))
|
|
|
|
:to (- now (* 2 mailserver.constants/one-day))}))))
|
2019-04-16 19:09:18 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/fetch-history-pressed84-96
|
|
|
|
(fn [{:keys [now] :as cofx} [_ chat-id]]
|
|
|
|
(let [now (quot now 1000)]
|
|
|
|
(mailserver/fetch-history cofx chat-id
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
{:from (- now (* 4 mailserver.constants/one-day))
|
|
|
|
:to (- now (* 3.5 mailserver.constants/one-day))}))))
|
2019-04-04 13:55:35 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-04-16 19:09:18 +00:00
|
|
|
:chat.ui/fill-gaps
|
|
|
|
(fn [{:keys [db] :as cofx} [_ gap-ids]]
|
|
|
|
(let [chat-id (:current-chat-id db)
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
topics (mailserver.topics/topics-for-current-chat db)
|
2019-04-16 19:09:18 +00:00
|
|
|
gaps (keep
|
|
|
|
(fn [id]
|
|
|
|
(get-in db [:mailserver/gaps chat-id id]))
|
|
|
|
gap-ids)]
|
2019-04-04 13:55:35 +00:00
|
|
|
(mailserver/fill-the-gap
|
|
|
|
cofx
|
2019-04-16 19:09:18 +00:00
|
|
|
{:gaps gaps
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
:topics topics
|
2019-04-16 19:09:18 +00:00
|
|
|
:chat-id chat-id}))))
|
2018-12-12 08:55:59 +00:00
|
|
|
|
2019-04-24 19:32:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/fetch-more
|
|
|
|
(fn [{:keys [db] :as cofx}]
|
|
|
|
(let [chat-id (:current-chat-id db)
|
|
|
|
|
|
|
|
{:keys [lowest-request-from]}
|
|
|
|
(get-in db [:mailserver/ranges chat-id])
|
|
|
|
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
topics (mailserver.topics/topics-for-current-chat db)
|
2019-04-24 19:32:06 +00:00
|
|
|
gaps [{:id :first-gap
|
|
|
|
:to lowest-request-from
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
:from (- lowest-request-from mailserver.constants/one-day)}]]
|
2019-04-24 19:32:06 +00:00
|
|
|
(mailserver/fill-the-gap
|
|
|
|
cofx
|
|
|
|
{:gaps gaps
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
:topics topics
|
2019-04-24 19:32:06 +00:00
|
|
|
:chat-id chat-id}))))
|
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
(handlers/register-handler-fx
|
2018-09-24 16:27:04 +00:00
|
|
|
:chat.ui/remove-chat-pressed
|
2018-10-01 08:47:20 +00:00
|
|
|
(fn [_ [_ chat-id]]
|
2018-09-24 16:27:04 +00:00
|
|
|
{:ui/show-confirmation {:title (i18n/label :t/delete-confirmation)
|
|
|
|
:content (i18n/label :t/delete-chat-confirmation)
|
|
|
|
:confirm-button-text (i18n/label :t/delete)
|
|
|
|
:on-accept #(re-frame/dispatch [:chat.ui/remove-chat chat-id])}}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/set-chat-ui-props
|
|
|
|
(fn [{:keys [db]} [_ kvs]]
|
|
|
|
{:db (chat/set-chat-ui-props db kvs)}))
|
|
|
|
|
2019-02-27 12:58:56 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/join-time-messages-checked
|
2019-04-08 14:30:59 +00:00
|
|
|
(fn [cofx [_ chat-id]]
|
|
|
|
(chat/join-time-messages-checked cofx chat-id)))
|
2019-02-27 12:58:56 +00:00
|
|
|
|
2018-09-24 16:27:04 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/show-message-options
|
|
|
|
(fn [{:keys [db]} [_ options]]
|
|
|
|
{:db (chat/set-chat-ui-props db {:show-message-options? true
|
|
|
|
:message-options options})}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/navigate-to-chat
|
|
|
|
(fn [cofx [_ chat-id opts]]
|
|
|
|
(chat/navigate-to-chat cofx chat-id opts)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/load-more-messages
|
|
|
|
(fn [cofx _]
|
2019-09-04 09:41:05 +00:00
|
|
|
(let [chat-id (get-in cofx [:db :current-chat-id])]
|
|
|
|
(fx/merge cofx
|
|
|
|
(chat.loading/load-more-messages)
|
|
|
|
(mailserver/load-gaps-fx chat-id)))))
|
2018-09-24 16:27:04 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/start-chat
|
|
|
|
(fn [cofx [_ contact-id opts]]
|
|
|
|
(chat/start-chat cofx contact-id opts)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/start-public-chat
|
2018-10-17 11:02:34 +00:00
|
|
|
(fn [cofx [_ topic opts]]
|
2018-12-04 12:03:41 +00:00
|
|
|
(fx/merge
|
|
|
|
cofx
|
|
|
|
(chat/start-public-chat topic opts)
|
|
|
|
(pairing/sync-public-chat topic))))
|
2018-09-24 16:27:04 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/remove-chat
|
|
|
|
(fn [cofx [_ chat-id]]
|
|
|
|
(chat/remove-chat cofx chat-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/clear-history
|
|
|
|
(fn [{{:keys [current-chat-id]} :db :as cofx} _]
|
|
|
|
(chat/clear-history cofx current-chat-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/resend-message
|
|
|
|
(fn [cofx [_ chat-id message-id]]
|
|
|
|
(chat.message/resend-message cofx chat-id message-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/delete-message
|
|
|
|
(fn [cofx [_ chat-id message-id]]
|
|
|
|
(chat.message/delete-message cofx chat-id message-id)))
|
|
|
|
|
2018-10-18 00:05:39 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/message-expand-toggled
|
|
|
|
(fn [cofx [_ chat-id message-id]]
|
|
|
|
(chat.message/toggle-expand-message cofx chat-id message-id)))
|
|
|
|
|
2018-09-24 16:27:04 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/set-chat-input-text
|
|
|
|
(fn [cofx [_ text]]
|
|
|
|
(chat.input/set-chat-input-text cofx text)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/select-chat-input-command
|
|
|
|
(fn [cofx [_ command params previous-command-message]]
|
|
|
|
(chat.input/select-chat-input-command cofx command params previous-command-message)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/set-command-prefix
|
|
|
|
(fn [cofx _]
|
|
|
|
(chat.input/set-command-prefix cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/cancel-message-reply
|
|
|
|
(fn [cofx _]
|
|
|
|
(chat.input/cancel-message-reply cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/reply-to-message
|
2019-08-05 06:17:55 +00:00
|
|
|
(fn [cofx [_ message-id]]
|
|
|
|
(chat.input/reply-to-message cofx message-id)))
|
2018-09-24 16:27:04 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/send-current-message
|
|
|
|
(fn [cofx _]
|
|
|
|
(chat.input/send-current-message cofx)))
|
|
|
|
|
2018-11-20 21:43:40 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/set-command-parameter
|
|
|
|
(fn [{{:keys [chats current-chat-id chat-ui-props id->command access-scope->command-id]} :db :as cofx} [_ value]]
|
2019-03-19 12:24:57 +00:00
|
|
|
(let [current-chat (get chats current-chat-id)
|
|
|
|
selection (get-in chat-ui-props [current-chat-id :selection])
|
|
|
|
commands (commands/chat-commands id->command access-scope->command-id current-chat)
|
2018-11-20 21:43:40 +00:00
|
|
|
{:keys [current-param-position params]} (commands.input/selected-chat-command
|
|
|
|
(:input-text current-chat) selection commands)
|
|
|
|
last-param-idx (dec (count params))]
|
|
|
|
(commands.input/set-command-parameter cofx
|
|
|
|
(= current-param-position last-param-idx)
|
|
|
|
current-param-position
|
|
|
|
value))))
|
|
|
|
|
2019-07-05 09:05:36 +00:00
|
|
|
(defn- mark-messages-seen
|
|
|
|
[{:keys [db] :as cofx}]
|
|
|
|
(let [{:keys [current-chat-id]} db]
|
|
|
|
(chat/mark-messages-seen cofx current-chat-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat.ui/mark-messages-seen
|
|
|
|
(fn [{:keys [db] :as cofx} [_ view-id]]
|
|
|
|
(fx/merge cofx
|
|
|
|
{:db (assoc db :view-id view-id)}
|
|
|
|
#(mark-messages-seen %))))
|
|
|
|
|
2018-11-27 09:36:51 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat/send-plain-text-message
|
|
|
|
(fn [{{:keys [current-chat-id]} :db :as cofx} [_ message-text]]
|
|
|
|
(chat.input/send-plain-text-message-fx cofx message-text current-chat-id)))
|
|
|
|
|
2019-01-07 12:50:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat/send-sticker
|
2019-07-03 14:29:01 +00:00
|
|
|
(fn [{{:keys [current-chat-id multiaccount]} :db :as cofx} [_ {:keys [hash] :as sticker}]]
|
2019-01-07 12:50:06 +00:00
|
|
|
(fx/merge
|
|
|
|
cofx
|
2019-08-01 20:11:59 +00:00
|
|
|
(multiaccounts.update/multiaccount-update
|
2019-09-30 10:52:33 +00:00
|
|
|
{:stickers/recent-stickers (conj (remove #(= hash %) (:stickers/recent-stickers multiaccount)) hash)}
|
2019-08-01 20:11:59 +00:00
|
|
|
{})
|
2019-02-07 15:49:07 +00:00
|
|
|
(chat.input/send-sticker-fx sticker current-chat-id))))
|
2019-01-07 12:50:06 +00:00
|
|
|
|
2018-09-24 16:27:04 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:chat/disable-cooldown
|
|
|
|
(fn [cofx _]
|
|
|
|
(chat/disable-chat-cooldown cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:message/add
|
|
|
|
(fn [cofx [_ messages]]
|
|
|
|
(chat.message/receive-many cofx messages)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:message/update-message-status
|
|
|
|
(fn [cofx [_ chat-id message-id status]]
|
|
|
|
(chat.message/update-message-status cofx chat-id message-id status)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2019-01-10 16:54:37 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-01-18 11:45:54 +00:00
|
|
|
:message/messages-persisted
|
|
|
|
(fn [cofx [_ raw-messages]]
|
|
|
|
(apply fx/merge
|
|
|
|
cofx
|
|
|
|
(map
|
|
|
|
(fn [raw-message]
|
|
|
|
(chat.message/confirm-message-processed raw-message))
|
|
|
|
raw-messages))))
|
2019-01-10 16:54:37 +00:00
|
|
|
|
2018-09-06 10:04:12 +00:00
|
|
|
;; signal module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:signals/signal-received
|
|
|
|
(fn [cofx [_ event-str]]
|
|
|
|
(log/debug :event-str event-str)
|
2018-09-24 15:59:02 +00:00
|
|
|
(signals/process cofx event-str)))
|
2018-09-06 10:04:12 +00:00
|
|
|
|
2018-09-18 16:27:58 +00:00
|
|
|
;; hardwallet module
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-register-card-events
|
|
|
|
(fn [cofx [_ listeners]]
|
|
|
|
(hardwallet/on-register-card-events cofx listeners)))
|
|
|
|
|
2019-02-08 13:30:44 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/get-application-info
|
2019-02-25 20:01:37 +00:00
|
|
|
(fn [cofx _]
|
2019-04-03 08:46:53 +00:00
|
|
|
(hardwallet/get-application-info cofx nil nil)))
|
2019-02-08 13:30:44 +00:00
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-get-application-info-success
|
2018-12-04 13:49:09 +00:00
|
|
|
(fn [cofx [_ info on-success]]
|
|
|
|
(hardwallet/on-get-application-info-success cofx info on-success)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-get-application-info-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-get-application-info-error cofx error)))
|
|
|
|
|
2018-09-18 16:27:58 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/check-nfc-support-success
|
|
|
|
(fn [cofx [_ supported?]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(hardwallet/set-nfc-support cofx supported?)))
|
2018-09-18 16:27:58 +00:00
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-card-connected
|
|
|
|
(fn [cofx [_ data]]
|
|
|
|
(hardwallet/on-card-connected cofx data)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-card-disconnected
|
|
|
|
(fn [cofx [_ data]]
|
|
|
|
(hardwallet/on-card-disconnected cofx data)))
|
|
|
|
|
2019-02-08 13:30:44 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-init-card-success
|
|
|
|
(fn [cofx [_ secrets]]
|
|
|
|
(hardwallet/on-init-card-success cofx secrets)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-init-card-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-init-card-error cofx error)))
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-install-applet-and-init-card-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-install-applet-and-init-card-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-05-29 19:20:29 +00:00
|
|
|
:hardwallet.callback/on-pair-success
|
2018-12-04 13:41:34 +00:00
|
|
|
(fn [cofx [_ pairing]]
|
2019-05-29 19:20:29 +00:00
|
|
|
(hardwallet/on-pair-success cofx pairing)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-05-29 19:20:29 +00:00
|
|
|
:hardwallet.callback/on-pair-error
|
2018-12-04 13:41:34 +00:00
|
|
|
(fn [cofx [_ error]]
|
2019-05-29 19:20:29 +00:00
|
|
|
(hardwallet/on-pair-error cofx error)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-generate-mnemonic-success
|
|
|
|
(fn [cofx [_ mnemonic]]
|
|
|
|
(hardwallet/on-generate-mnemonic-success cofx mnemonic)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-generate-mnemonic-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-generate-mnemonic-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-generate-and-load-key-success
|
|
|
|
[(re-frame/inject-cofx :random-guid-generator)
|
2019-08-01 20:11:59 +00:00
|
|
|
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]
|
2018-12-04 13:41:34 +00:00
|
|
|
(fn [cofx [_ data]]
|
|
|
|
(hardwallet/on-generate-and-load-key-success cofx data)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-generate-and-load-key-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-generate-and-load-key-error cofx error)))
|
|
|
|
|
2018-12-25 14:57:19 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-unblock-pin-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-unblock-pin-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-unblock-pin-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-unblock-pin-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-verify-pin-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-verify-pin-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-verify-pin-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-verify-pin-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-change-pin-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-change-pin-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-change-pin-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-change-pin-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-unpair-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-unpair-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-unpair-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-unpair-error cofx error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-delete-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-delete-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-delete-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-delete-error cofx error)))
|
|
|
|
|
2019-04-08 15:03:08 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-remove-key-success
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/on-remove-key-success cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-remove-key-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-remove-key-error cofx error)))
|
|
|
|
|
2018-12-04 13:49:09 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-get-keys-success
|
|
|
|
(fn [cofx [_ data]]
|
|
|
|
(hardwallet/on-get-keys-success cofx data)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-get-keys-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-get-keys-error cofx error)))
|
|
|
|
|
2019-04-03 08:46:53 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.callback/on-sign-error
|
|
|
|
(fn [cofx [_ error]]
|
|
|
|
(hardwallet/on-sign-error cofx error)))
|
|
|
|
|
2018-09-20 16:36:12 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/password-option-pressed
|
|
|
|
(fn [cofx _]
|
2019-02-25 20:01:37 +00:00
|
|
|
(hardwallet/password-option-pressed cofx)))
|
2018-09-20 16:36:12 +00:00
|
|
|
|
2018-09-18 16:27:58 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/go-to-settings-button-pressed
|
|
|
|
(fn [_ _]
|
|
|
|
{:hardwallet/open-nfc-settings nil}))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
2018-09-20 11:24:14 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/begin-setup-button-pressed
|
2018-12-04 13:41:34 +00:00
|
|
|
(fn [cofx _]
|
2019-02-08 13:30:44 +00:00
|
|
|
(hardwallet/begin-setup-button-pressed cofx)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-02-08 13:30:44 +00:00
|
|
|
:hardwallet/start-installation
|
2018-12-04 13:41:34 +00:00
|
|
|
(fn [cofx _]
|
2019-02-08 13:30:44 +00:00
|
|
|
(hardwallet/start-installation cofx)))
|
2018-10-01 16:35:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/pair-card-button-pressed
|
|
|
|
(fn [{:keys [db]} _]
|
|
|
|
{:db (assoc-in db [:hardwallet :setup-step] :enter-pair-code)}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/pair-code-input-changed
|
|
|
|
(fn [{:keys [db]} [_ pair-code]]
|
2019-02-08 13:30:44 +00:00
|
|
|
{:db (assoc-in db [:hardwallet :secrets :password] pair-code)}))
|
2018-10-01 16:35:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/pair-code-next-button-pressed
|
2019-02-08 13:30:44 +00:00
|
|
|
(fn [cofx]
|
2019-04-30 10:52:14 +00:00
|
|
|
(hardwallet/pair-code-next-button-pressed cofx)))
|
2018-10-01 16:35:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2018-12-04 13:41:34 +00:00
|
|
|
:hardwallet.ui/recovery-phrase-next-button-pressed
|
|
|
|
(fn [cofx _]
|
2019-02-25 20:01:37 +00:00
|
|
|
(hardwallet/recovery-phrase-next-button-pressed cofx)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/recovery-phrase-confirm-word-next-button-pressed
|
2018-10-01 16:35:06 +00:00
|
|
|
(fn [cofx _]
|
2018-12-04 13:41:34 +00:00
|
|
|
(hardwallet/recovery-phrase-confirm-word cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/recovery-phrase-confirm-word-back-button-pressed
|
|
|
|
(fn [{:keys [db]} _]
|
|
|
|
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/recovery-phrase-confirm-word-input-changed
|
|
|
|
(fn [{:keys [db]} [_ input]]
|
|
|
|
{:db (assoc-in db [:hardwallet :recovery-phrase :input-word] input)}))
|
2018-10-01 16:35:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2018-12-04 13:41:34 +00:00
|
|
|
:hardwallet.ui/recovery-phrase-confirm-pressed
|
2018-10-01 16:35:06 +00:00
|
|
|
(fn [cofx _]
|
2018-12-04 13:41:34 +00:00
|
|
|
(hardwallet/load-loading-keys-screen cofx)))
|
|
|
|
|
2019-03-05 10:23:51 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/load-loading-keys-screen
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/load-loading-keys-screen cofx)))
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/recovery-phrase-cancel-pressed
|
|
|
|
(fn [{:keys [db]} _]
|
|
|
|
{:db (assoc-in db [:hardwallet :setup-step] :recovery-phrase)}))
|
2018-09-20 11:24:14 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/connection-error
|
|
|
|
(fn [_ _]
|
|
|
|
{:utils/show-popup {:title (i18n/label :t/cant-read-card)
|
|
|
|
:content (i18n/label :t/cant-read-card-error-explanation)
|
|
|
|
:on-dismiss #(re-frame/dispatch [:hardwallet.ui/connection-error-confirm-button-pressed])}}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/connection-error-confirm-button-pressed
|
|
|
|
(fn [{:keys [db] :as cofx} _]
|
2018-09-24 15:59:02 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
{:db (assoc-in db [:hardwallet :setup-step] :begin)}
|
|
|
|
(navigation/navigate-to-cofx :hardwallet-setup nil))))
|
2018-09-20 11:24:14 +00:00
|
|
|
|
2019-03-05 10:23:51 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/load-generating-mnemonic-screen
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/load-generating-mnemonic-screen cofx)))
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/pair
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/pair cofx)))
|
2018-09-20 11:24:14 +00:00
|
|
|
|
2019-05-01 17:09:00 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/verify-pin
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/verify-pin cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/change-pin
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/change-pin cofx)))
|
|
|
|
|
2018-09-20 11:24:14 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/success-button-pressed
|
|
|
|
(fn [cofx _]
|
2018-12-04 13:41:34 +00:00
|
|
|
(hardwallet/success-button-pressed cofx)))
|
2018-09-20 11:24:14 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/pin-numpad-button-pressed
|
|
|
|
(fn [cofx [_ number step]]
|
2018-12-25 14:57:19 +00:00
|
|
|
(hardwallet/update-pin cofx number step)))
|
|
|
|
|
2019-04-03 08:46:53 +00:00
|
|
|
(handlers/register-handler-fx
|
2019-05-01 17:09:00 +00:00
|
|
|
:hardwallet.ui/enter-pin-navigate-back-button-clicked
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/enter-pin-navigate-back-button-clicked cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/hardwallet-connect-navigate-back-button-clicked
|
2019-04-03 08:46:53 +00:00
|
|
|
(fn [cofx _]
|
2019-05-01 17:09:00 +00:00
|
|
|
(hardwallet/hardwallet-connect-navigate-back-button-clicked cofx)))
|
2019-04-03 08:46:53 +00:00
|
|
|
|
2018-12-25 14:57:19 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/process-pin-input
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/process-pin-input cofx)))
|
2018-09-20 11:24:14 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/pin-numpad-delete-button-pressed
|
|
|
|
(fn [{:keys [db]} [_ step]]
|
|
|
|
(when-not (empty? (get-in db [:hardwallet :pin step]))
|
|
|
|
{:db (update-in db [:hardwallet :pin step] pop)})))
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/card-ready-next-button-pressed
|
|
|
|
(fn [cofx _]
|
2019-02-25 20:01:37 +00:00
|
|
|
(hardwallet/card-ready-next-button-pressed cofx)))
|
2018-12-04 13:41:34 +00:00
|
|
|
|
2019-04-08 15:03:08 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/proceed-to-generate-mnemonic
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/proceed-to-generate-mnemonic cofx)))
|
|
|
|
|
2018-12-04 13:41:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/generate-mnemonic
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/generate-mnemonic cofx)))
|
|
|
|
|
2018-10-03 13:16:28 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/create-pin-button-pressed
|
|
|
|
(fn [{:keys [db]} _]
|
2018-12-04 13:41:34 +00:00
|
|
|
{:db (-> db
|
|
|
|
(assoc-in [:hardwallet :setup-step] :pin)
|
|
|
|
(assoc-in [:hardwallet :pin :enter-step] :original))}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet.ui/error-button-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/error-button-pressed cofx)))
|
2018-10-03 13:16:28 +00:00
|
|
|
|
2018-12-25 14:57:19 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:keycard-settings.ui/change-pin-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/change-pin-pressed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/proceed-to-change-pin
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/proceed-to-change-pin cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:keycard-settings.ui/unpair-card-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/unpair-card-pressed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:keycard-settings.ui/unpair-card-confirmed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/unpair-card-confirmed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/unpair
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/unpair cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:keycard-settings.ui/reset-card-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/reset-card-pressed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:keycard-settings.ui/reset-card-next-button-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/reset-card-next-button-pressed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/proceed-to-reset-card
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/proceed-to-reset-card cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/unpair-and-delete
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/unpair-and-delete cofx)))
|
|
|
|
|
2019-04-08 15:03:08 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/remove-key-with-unpair
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/remove-key-with-unpair cofx)))
|
|
|
|
|
2018-12-25 14:57:19 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/navigate-to-enter-pin-screen
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/navigate-to-enter-pin-screen cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/navigate-to-reset-card-screen
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/navigate-to-reset-card-screen cofx)))
|
|
|
|
|
2019-04-15 10:06:48 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:hardwallet/unblock-pin
|
|
|
|
(fn [cofx _]
|
|
|
|
(hardwallet/unblock-pin cofx)))
|
|
|
|
|
2018-09-21 13:41:40 +00:00
|
|
|
;; browser module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/browser-item-selected
|
|
|
|
(fn [cofx [_ browser-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/open-existing-browser cofx browser-id)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/url-input-pressed
|
|
|
|
(fn [cofx _]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/update-browser-option cofx :url-editing? true)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/url-input-blured
|
|
|
|
(fn [cofx _]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/update-browser-option cofx :url-editing? false)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/url-submitted
|
|
|
|
(fn [cofx [_ url]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/open-url-in-current-browser cofx url)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/message-link-pressed
|
|
|
|
(fn [cofx [_ link]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/handle-message-link cofx link)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/remove-browser-pressed
|
|
|
|
(fn [cofx [_ browser-id]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/remove-browser cofx browser-id)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/lock-pressed
|
|
|
|
(fn [cofx [_ secure?]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/update-browser-option cofx :show-tooltip (if secure? :secure :not-secure))))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/close-tooltip-pressed
|
|
|
|
(fn [cofx _]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/update-browser-option cofx :show-tooltip nil)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/previous-page-button-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(browser/navigate-to-previous-page cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/next-page-button-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(browser/navigate-to-next-page cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser/navigation-state-changed
|
|
|
|
(fn [cofx [_ event error?]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/navigation-state-changed cofx event error?)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser/bridge-message-received
|
|
|
|
(fn [cofx [_ message]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/process-bridge-message cofx message)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser/error-occured
|
|
|
|
(fn [cofx _]
|
|
|
|
(browser/handle-browser-error cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser/loading-started
|
|
|
|
(fn [cofx _]
|
2019-03-14 13:39:46 +00:00
|
|
|
(browser/update-browser-options cofx {:error? false :loading? true})))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.callback/resolve-ens-multihash-success
|
2019-04-25 13:02:25 +00:00
|
|
|
(fn [cofx [_ m]]
|
|
|
|
(browser/resolve-ens-multihash-success cofx m)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.callback/resolve-ens-multihash-error
|
|
|
|
(fn [cofx _]
|
2018-11-06 15:09:58 +00:00
|
|
|
(browser/resolve-ens-multihash-error cofx)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
2018-12-12 14:48:17 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.callback/resolve-ens-contenthash
|
|
|
|
(fn [cofx _]
|
|
|
|
(browser/resolve-ens-contenthash cofx)))
|
|
|
|
|
2018-09-21 13:41:40 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.callback/call-rpc
|
|
|
|
(fn [cofx [_ message]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/send-to-bridge cofx message)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.permissions.ui/dapp-permission-allowed
|
2018-09-28 13:40:19 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(browser.permissions/allow-permission cofx)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.permissions.ui/dapp-permission-denied
|
2018-09-28 13:40:19 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(browser.permissions/deny-permission cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.permissions.ui/permission-animation-finished
|
2018-09-21 13:41:40 +00:00
|
|
|
(fn [cofx [_ dapp-name]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser.permissions/process-next-permission cofx dapp-name)))
|
2018-09-21 13:41:40 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2019-06-08 04:04:07 +00:00
|
|
|
:browser.ui/open-url
|
2019-08-08 16:19:49 +00:00
|
|
|
(fn [cofx [_ url]]
|
|
|
|
(browser/open-url cofx url)))
|
2018-09-06 14:08:20 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:browser.ui/open-modal-chat-button-pressed
|
|
|
|
(fn [cofx [_ host]]
|
2018-09-24 15:59:02 +00:00
|
|
|
(browser/open-chat-from-browser cofx host)))
|
2018-07-19 15:51:06 +00:00
|
|
|
|
2019-02-04 09:07:41 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:dapps/revoke-access
|
|
|
|
(fn [cofx [_ dapp]]
|
|
|
|
(browser.permissions/revoke-dapp-permissions cofx dapp)))
|
|
|
|
|
2018-07-19 15:51:06 +00:00
|
|
|
;; group-chats module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/create-pressed
|
|
|
|
[(re-frame/inject-cofx :random-guid-generator)]
|
|
|
|
(fn [cofx [_ chat-name]]
|
|
|
|
(group-chats/create cofx chat-name)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/name-changed
|
|
|
|
(fn [cofx [_ chat-name]]
|
|
|
|
(group-chats/handle-name-changed cofx chat-name)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/save-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(group-chats/save cofx)))
|
|
|
|
|
2018-10-01 08:47:20 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/add-members-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(group-chats/add-members cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/remove-member-pressed
|
|
|
|
(fn [cofx [_ chat-id public-key]]
|
|
|
|
(group-chats/remove-member cofx chat-id public-key)))
|
|
|
|
|
2018-11-29 10:06:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/make-admin-pressed
|
|
|
|
(fn [cofx [_ chat-id public-key]]
|
|
|
|
(group-chats/make-admin cofx chat-id public-key)))
|
|
|
|
|
2018-10-01 08:47:20 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/remove-chat-pressed
|
|
|
|
(fn [_ [_ chat-id group?]]
|
|
|
|
{:ui/show-confirmation {:title (i18n/label :t/delete-confirmation)
|
|
|
|
:content (i18n/label :t/delete-chat-confirmation)
|
|
|
|
:confirm-button-text (i18n/label :t/delete)
|
|
|
|
:on-accept #(re-frame/dispatch [:group-chats.ui/remove-chat-confirmed chat-id])}}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/remove-chat-confirmed
|
|
|
|
(fn [cofx [_ chat-id]]
|
|
|
|
(group-chats/remove cofx chat-id)))
|
|
|
|
|
2018-12-17 14:59:04 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.ui/join-pressed
|
|
|
|
(fn [cofx [_ chat-id]]
|
|
|
|
(group-chats/join-chat cofx chat-id)))
|
|
|
|
|
2018-07-19 15:51:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:group-chats.callback/sign-success
|
|
|
|
[(re-frame/inject-cofx :random-guid-generator)]
|
|
|
|
(fn [cofx [_ group-update]]
|
|
|
|
(group-chats/handle-sign-success cofx group-update)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
2018-10-01 08:47:20 +00:00
|
|
|
:group-chats.callback/extract-signature-success
|
2019-02-17 18:27:34 +00:00
|
|
|
(fn [cofx [_ group-update message-info sender-signature]]
|
|
|
|
(group-chats/handle-membership-update cofx group-update message-info sender-signature)))
|
2018-10-01 08:26:47 +00:00
|
|
|
|
2018-10-09 08:10:47 +00:00
|
|
|
;; profile module
|
|
|
|
|
2018-12-25 14:57:19 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:profile.ui/keycard-settings-button-pressed
|
|
|
|
(fn [cofx]
|
|
|
|
(hardwallet/navigate-to-keycard-settings cofx)))
|
|
|
|
|
2018-10-09 08:10:47 +00:00
|
|
|
;; transport module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:transport/messages-received
|
|
|
|
[handlers/logged-in (re-frame/inject-cofx :random-id-generator)]
|
|
|
|
(fn [cofx [_ js-error js-messages chat-id]]
|
|
|
|
(transport.message/receive-whisper-messages cofx js-error js-messages chat-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:transport/send-status-message-error
|
|
|
|
(fn [{:keys [db] :as cofx} [_ err]]
|
|
|
|
(log/error :send-status-message-error err)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:transport/message-sent
|
2019-08-05 06:17:55 +00:00
|
|
|
(fn [cofx [_ chat-id message message-type message-id messages-count]]
|
|
|
|
(fx/merge cofx
|
|
|
|
(when message (chat.message/add-message-with-id (assoc message :message-id message-id) chat-id))
|
|
|
|
|
|
|
|
(transport.message/set-message-envelope-hash chat-id message-id message-type messages-count))))
|
2018-10-09 08:10:47 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:transport/contact-message-sent
|
|
|
|
(fn [cofx [_ chat-id envelope-hash]]
|
|
|
|
(transport.message/set-contact-message-envelope-hash cofx chat-id envelope-hash)))
|
2018-10-11 08:38:23 +00:00
|
|
|
|
2019-02-22 12:26:40 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:transport.callback/node-info-fetched
|
|
|
|
(fn [cofx [_ node-info]]
|
|
|
|
(transport/set-node-info cofx node-info)))
|
|
|
|
|
2018-10-11 08:38:23 +00:00
|
|
|
;; contact module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/add-to-contact-pressed
|
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2018-10-26 18:06:23 +00:00
|
|
|
(fn [cofx [_ public-key]]
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
(contact/add-contact cofx public-key)))
|
2018-10-11 08:38:23 +00:00
|
|
|
|
2018-12-20 14:50:02 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/block-contact-confirmed
|
|
|
|
(fn [cofx [_ public-key]]
|
2019-02-22 12:26:40 +00:00
|
|
|
(contact.block/block-contact cofx public-key)))
|
2018-12-20 14:50:02 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/unblock-contact-pressed
|
|
|
|
(fn [cofx [_ public-key]]
|
2019-02-22 12:26:40 +00:00
|
|
|
(contact.block/unblock-contact cofx public-key)))
|
2018-12-20 14:50:02 +00:00
|
|
|
|
2018-10-11 08:38:23 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact/qr-code-scanned
|
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2019-02-22 12:26:40 +00:00
|
|
|
(fn [{:keys [db] :as cofx} [_ _ contact-identity]]
|
2019-07-03 14:29:01 +00:00
|
|
|
(let [current-multiaccount (:multiaccount db)
|
2019-02-22 12:26:40 +00:00
|
|
|
fx {:db (assoc db :contacts/new-identity contact-identity)}
|
|
|
|
validation-result (new-chat.db/validate-pub-key db contact-identity)]
|
|
|
|
(if (some? validation-result)
|
|
|
|
{:utils/show-popup {:title (i18n/label :t/unable-to-read-this-code)
|
|
|
|
:content validation-result
|
|
|
|
:on-dismiss #(re-frame/dispatch [:navigate-to-clean :home])}}
|
|
|
|
(fx/merge cofx
|
|
|
|
fx
|
Adds topic negotiation and partitioned topic
All the code has been implemented in statusgo: status-im/status-go#1466
Basically all the whisper filter management is done at that level.
Technical description
On startup we load all chats and send a list of them to status go:
For a public chat: {:chatId "status"}, we create a single filter, based on the name of the chat.
For each contact added by us, each user in a group chat and each one to one chat open, we send:
{:chatId "0x", :oneToOne true}. This will create a chats, to listen to their contact code.
Any previously negotiated topic is also returned.
Once loaded, we create our filters, and upsert the mailserver topics, both of which are solely based on the filters loaded.
In order to remove a chat, we delete/stopwatching first the the filter in status-react and then ask status-go to remove the filter. For a public chat we always remove, for a one-to-one we remove only if the user is not in our contacts, or in a group chat or we have a chat open. Negotiated topics are never removed, as otherwise the other user won't be able to contact us anymore.
On stopping whisper we don't have to ask status-go to remove filters as they are removed automatically.
Some more logic can be pushed in status-go, but that will be in subsequent PRs.
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-06-05 11:34:04 +00:00
|
|
|
(chat/start-chat contact-identity {:navigation-reset? true}))))))
|
2019-01-23 18:15:07 +00:00
|
|
|
|
2018-10-11 08:38:23 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/start-group-chat-pressed
|
|
|
|
(fn [{:keys [db] :as cofx} _]
|
|
|
|
(contact/open-contact-toggle-list cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/send-message-pressed
|
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2018-10-26 18:06:23 +00:00
|
|
|
(fn [cofx [_ {:keys [public-key]}]]
|
2019-02-22 12:26:40 +00:00
|
|
|
(chat/start-chat cofx public-key {:navigation-reset? true})))
|
2018-10-11 08:38:23 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:contact.ui/contact-code-submitted
|
|
|
|
[(re-frame/inject-cofx :random-id-generator)]
|
2019-02-22 12:26:40 +00:00
|
|
|
(fn [{{:contacts/keys [new-identity]} :db :as cofx} _]
|
|
|
|
(chat/start-chat cofx new-identity {:navigation-reset? true})))
|
2018-10-13 16:47:34 +00:00
|
|
|
|
|
|
|
;; search module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:search/filter-changed
|
|
|
|
(fn [cofx [_ search-filter]]
|
|
|
|
(search/filter-changed cofx search-filter)))
|
2018-10-09 10:43:07 +00:00
|
|
|
|
|
|
|
;; pairing module
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/pair-devices-pressed
|
|
|
|
(fn [cofx _]
|
2018-11-02 13:48:45 +00:00
|
|
|
(pairing/pair-installation cofx)))
|
2018-10-09 10:43:07 +00:00
|
|
|
|
2019-01-14 14:43:34 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/set-name-pressed
|
|
|
|
(fn [cofx [_ installation-name]]
|
|
|
|
(pairing/set-name cofx installation-name)))
|
|
|
|
|
2018-10-09 10:43:07 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/synchronize-installation-pressed
|
|
|
|
(fn [cofx _]
|
2018-11-08 13:07:29 +00:00
|
|
|
(pairing/send-installation-messages cofx)))
|
2018-11-02 13:48:45 +00:00
|
|
|
|
2019-06-25 14:34:55 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.callback/get-our-installations-success
|
|
|
|
(fn [cofx [_ installations]]
|
|
|
|
(pairing/load-installations cofx installations)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.callback/set-installation-metadata-success
|
|
|
|
(fn [cofx [_ installation-id metadata]]
|
|
|
|
(pairing/update-installation cofx installation-id metadata)))
|
|
|
|
|
2018-10-27 19:24:47 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:set-initial-props
|
|
|
|
(fn [cofx [_ initial-props]]
|
|
|
|
{:db (assoc (:db cofx) :initial-props initial-props)}))
|
|
|
|
|
2018-11-02 13:48:45 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/enable-installation-pressed
|
|
|
|
(fn [cofx [_ installation-id]]
|
|
|
|
(pairing/enable-fx cofx installation-id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/disable-installation-pressed
|
|
|
|
(fn [cofx [_ installation-id]]
|
|
|
|
(pairing/disable-fx cofx installation-id)))
|
|
|
|
|
2018-11-30 15:11:32 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/prompt-dismissed
|
|
|
|
(fn [cofx _]
|
|
|
|
(pairing/prompt-dismissed cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.ui/prompt-accepted
|
|
|
|
(fn [cofx _]
|
|
|
|
(pairing/prompt-accepted cofx)))
|
|
|
|
|
2018-11-02 13:48:45 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.callback/enable-installation-success
|
|
|
|
(fn [cofx [_ installation-id]]
|
2019-02-05 15:49:10 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
(pairing/enable installation-id)
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.update/send-multiaccount-update))))
|
2018-11-02 13:48:45 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:pairing.callback/disable-installation-success
|
|
|
|
(fn [cofx [_ installation-id]]
|
2019-02-05 15:49:10 +00:00
|
|
|
(fx/merge cofx
|
|
|
|
(pairing/disable installation-id)
|
2019-07-03 14:29:01 +00:00
|
|
|
(multiaccounts.update/send-multiaccount-update))))
|
2018-12-27 12:12:54 +00:00
|
|
|
|
2019-01-07 12:50:06 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/load-sticker-pack-success
|
2019-02-15 09:08:42 +00:00
|
|
|
(fn [cofx [_ edn-string id price open?]]
|
|
|
|
(stickers/load-sticker-pack-success cofx edn-string id price open?)))
|
2019-01-07 12:50:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/install-pack
|
|
|
|
(fn [cofx [_ id]]
|
|
|
|
(stickers/install-stickers-pack cofx id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/load-packs
|
2019-02-15 09:08:42 +00:00
|
|
|
(fn [cofx _]
|
|
|
|
(stickers/load-packs cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/load-pack
|
2019-07-26 10:29:17 +00:00
|
|
|
(fn [cofx [_ url id price open?]]
|
|
|
|
(stickers/load-pack cofx url id price open?)))
|
2019-01-07 12:50:06 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/select-pack
|
|
|
|
(fn [{:keys [db]} [_ id]]
|
2019-01-29 09:42:53 +00:00
|
|
|
{:db (assoc db :stickers/selected-pack id)}))
|
2019-02-07 15:49:07 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/open-sticker-pack
|
2019-02-15 09:08:42 +00:00
|
|
|
(fn [cofx [_ id]]
|
|
|
|
(stickers/open-sticker-pack cofx id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/buy-pack
|
|
|
|
(fn [cofx [_ id price]]
|
|
|
|
(stickers/approve-pack cofx id price)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/get-owned-packs
|
|
|
|
(fn [cofx _]
|
|
|
|
(stickers/get-owned-pack cofx)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/pack-owned
|
|
|
|
(fn [cofx [_ id]]
|
|
|
|
(stickers/pack-owned cofx id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/pending-pack
|
|
|
|
(fn [cofx [_ id]]
|
|
|
|
(stickers/pending-pack cofx id)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:stickers/pending-timout
|
|
|
|
(fn [cofx _]
|
|
|
|
(stickers/pending-timeout cofx)))
|
2019-02-22 13:12:29 +00:00
|
|
|
|
2019-01-17 13:25:30 +00:00
|
|
|
;; Tribute to Talk
|
2019-02-22 12:26:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
;; bottom-sheet events
|
2019-03-18 14:01:09 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bottom-sheet/show-sheet
|
2019-05-14 20:39:40 +00:00
|
|
|
(fn [cofx [_ view options]]
|
2019-03-18 14:01:09 +00:00
|
|
|
(bottom-sheet/show-bottom-sheet
|
|
|
|
cofx
|
2019-05-14 20:39:40 +00:00
|
|
|
{:view view
|
|
|
|
:options options})))
|
2019-03-18 14:01:09 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:bottom-sheet/hide-sheet
|
|
|
|
(fn [cofx _]
|
|
|
|
(bottom-sheet/hide-bottom-sheet cofx)))
|
2019-05-08 23:33:19 +00:00
|
|
|
|
2019-05-20 08:02:56 +00:00
|
|
|
;;custom tokens
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/decimals-result
|
|
|
|
(fn [cofx [_ result]]
|
|
|
|
(custom-tokens/decimals-result cofx result)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/symbol-result
|
|
|
|
(fn [cofx [_ contract result]]
|
|
|
|
(custom-tokens/symbol-result cofx contract result)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/name-result
|
|
|
|
(fn [cofx [_ contract result]]
|
|
|
|
(custom-tokens/name-result cofx contract result)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/balance-result
|
|
|
|
(fn [cofx [_ contract result]]
|
|
|
|
(custom-tokens/balance-result cofx contract result)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/total-supply-result
|
|
|
|
(fn [cofx [_ contract result]]
|
|
|
|
(custom-tokens/total-supply-result cofx contract result)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token/contract-address-is-pasted
|
|
|
|
(fn [cofx [_ contract]]
|
|
|
|
(custom-tokens/contract-address-is-changed cofx contract)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token.ui/contract-address-paste
|
|
|
|
(fn [_ _]
|
|
|
|
{:wallet.custom-token/contract-address-paste nil}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token.ui/field-is-edited
|
|
|
|
(fn [cofx [_ field-key value]]
|
|
|
|
(custom-tokens/field-is-edited cofx field-key value)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token.ui/add-pressed
|
|
|
|
(fn [cofx _]
|
|
|
|
(fx/merge cofx
|
2019-05-22 11:32:18 +00:00
|
|
|
(custom-tokens/add-custom-token)
|
2019-05-20 08:02:56 +00:00
|
|
|
(navigation/navigate-back))))
|
2019-05-22 11:32:18 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.custom-token.ui/remove-pressed
|
|
|
|
(fn [cofx [_ token navigate-back?]]
|
|
|
|
(fx/merge cofx
|
|
|
|
(custom-tokens/remove-custom-token token)
|
|
|
|
(when navigate-back?
|
2019-05-09 19:51:41 +00:00
|
|
|
(navigation/navigate-back)))))
|
|
|
|
|
|
|
|
;; ethereum subscriptions events
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:ethereum.callback/subscription-success
|
|
|
|
(fn [cofx [_ id handler]]
|
|
|
|
(ethereum.subscriptions/register-subscription cofx id handler)))
|
|
|
|
|
2019-05-13 11:44:46 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:ethereum.transactions.callback/etherscan-error
|
|
|
|
(fn [cofx [event error]]
|
|
|
|
(log/info event error)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:ethereum.transactions.callback/fetch-token-history-success
|
|
|
|
(fn [cofx [_ transactions]]
|
|
|
|
(ethereum.transactions/handle-token-history cofx transactions)))
|
|
|
|
|
2019-05-17 10:02:16 +00:00
|
|
|
;; wallet events
|
2019-05-18 11:06:42 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.ui/pull-to-refresh
|
|
|
|
(fn [cofx _]
|
2019-05-19 19:47:54 +00:00
|
|
|
(wallet/update-prices cofx)))
|
2019-05-18 11:06:42 +00:00
|
|
|
|
2019-05-17 10:02:16 +00:00
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.transactions/add-filter
|
|
|
|
(fn [{:keys [db]} [_ id]]
|
|
|
|
{:db (update-in db [:wallet :filters] conj id)}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.transactions/remove-filter
|
|
|
|
(fn [{:keys [db]} [_ id]]
|
|
|
|
{:db (update-in db [:wallet :filters] disj id)}))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.transactions/add-all-filters
|
|
|
|
(fn [{:keys [db]} _]
|
|
|
|
{:db (assoc-in db [:wallet :filters]
|
|
|
|
wallet.db/default-wallet-filters)}))
|
2019-05-18 11:06:42 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.settings/toggle-visible-token
|
|
|
|
(fn [cofx [_ symbol checked?]]
|
|
|
|
(wallet/toggle-visible-token cofx symbol checked?)))
|
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.settings.ui/navigate-back-pressed
|
|
|
|
(fn [cofx [_ on-close]]
|
|
|
|
(fx/merge cofx
|
|
|
|
(when on-close
|
|
|
|
{:dispatch on-close})
|
2019-08-23 23:21:38 +00:00
|
|
|
(navigation/navigate-back))))
|
2019-05-18 11:06:42 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.ui/show-transaction-details
|
2019-08-12 08:53:31 +00:00
|
|
|
(fn [cofx [_ hash address]]
|
|
|
|
(wallet/open-transaction-details cofx hash address)))
|
2019-05-18 11:06:42 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet.setup.ui/navigate-back-pressed
|
|
|
|
(fn [{:keys [db] :as cofx}]
|
|
|
|
(fx/merge cofx
|
|
|
|
{:db (assoc-in db [:wallet :send-transaction] {})}
|
|
|
|
(navigation/navigate-back))))
|
2019-05-07 06:37:43 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:shake-event
|
|
|
|
(fn [cofx _]
|
|
|
|
(logging/show-logs-dialog cofx)))
|
2019-06-05 11:11:47 +00:00
|
|
|
|
|
|
|
(re-frame/reg-fx
|
|
|
|
:dismiss-keyboard
|
|
|
|
(fn []
|
2019-06-03 07:42:29 +00:00
|
|
|
(react/dismiss-keyboard!)))
|
2019-06-17 09:41:37 +00:00
|
|
|
|
|
|
|
(handlers/register-handler-fx
|
|
|
|
:wallet-send-request
|
|
|
|
(fn [{:keys [db] :as cofx} [_ public-key amount symbol decimals]]
|
|
|
|
(assert public-key)
|
|
|
|
(let [request-command (get-in db [:id->command ["request" #{:personal-chats}]])]
|
|
|
|
(fx/merge cofx
|
2019-07-08 11:38:47 +00:00
|
|
|
(navigation/navigate-back)
|
2019-06-17 09:41:37 +00:00
|
|
|
(chat/start-chat public-key nil)
|
|
|
|
(commands.sending/send public-key
|
|
|
|
request-command
|
|
|
|
{:asset (name symbol)
|
2019-06-25 14:34:55 +00:00
|
|
|
:amount (str (money/internal->formatted amount symbol decimals))})))))
|