kibit suggestion (in progress)

This commit is contained in:
Roman Volosovskyi 2016-12-27 19:45:54 +02:00
parent 81257b815a
commit 9f4fd79586
44 changed files with 173 additions and 194 deletions

View File

@ -94,7 +94,7 @@
(not= status old-status))]
(when status-updated?
(let [hashtags (get-hashtags status)]
(when-not (empty? hashtags)
(when (seq hashtags)
(dispatch [:broadcast-status status hashtags]))))))))
(register-handler

View File

@ -23,18 +23,17 @@
:updates-private-key private
:signed-up? true}]
(log/debug "account-recovered")
(when (not (str/blank? public-key))
(do
(dispatch [:set-in [:recover :passphrase] ""])
(dispatch [:set-in [:recover :password] ""])
(dispatch [:add-account account])
(dispatch [:navigate-back])))))
(when-not (str/blank? public-key)
(dispatch [:set-in [:recover :passphrase] ""])
(dispatch [:set-in [:recover :password] ""])
(dispatch [:add-account account])
(dispatch [:navigate-back]))))
(defn recover-account
[_ [_ passphrase password]]
(status/recover-account
passphrase
password
(fn [result] (account-recovered result))))
account-recovered))
(register-handler :recover-account (u/side-effect! recover-account))

View File

@ -254,7 +254,7 @@
(register-handler :account-generation-message
(u/side-effect!
(fn [_]
(when (not (messages/get-by-id sign-up-service/passphraze-message-id))
(when-not (messages/get-by-id sign-up-service/passphraze-message-id)
(sign-up-service/account-generation-message)))))
(register-handler :show-mnemonic
@ -449,12 +449,12 @@
(chats/save chat')))
(register-handler :update-chat!
(-> (fn [db [_ {:keys [chat-id name] :as chat}]]
(let [chat' (if name chat (dissoc chat :name))]
(if (get-in db [:chats chat-id])
(update-in db [:chats chat-id] merge chat')
db)))
((after update-chat!))))
(after update-chat!)
(fn [db [_ {:keys [chat-id name] :as chat}]]
(let [chat' (if name chat (dissoc chat :name))]
(if (get-in db [:chats chat-id])
(update-in db [:chats chat-id] merge chat')
db))))
(register-handler :upsert-chat!
(fn [db [_ {:keys [chat-id] :as opts}]]

View File

@ -53,9 +53,7 @@
(let [{:keys [name]} command]
(case name
"js" (let [{:keys [err data messages]} handler-data
content (if err
err
data)]
content (or err data)]
(doseq [message messages]
(let [{:keys [message type]} message]
(dispatch [:received-message

View File

@ -41,7 +41,7 @@
exists? (chats/exists? chat-id')
active? (chats/is-active? chat-id')
chat-clock-value (messages/get-last-clock-value chat-id')
clock-value (if (= clock-value 0)
clock-value (if (zero? clock-value)
(inc chat-clock-value)
clock-value)]
(when (and (not same-message)

View File

@ -228,9 +228,7 @@
(u/side-effect!
(fn [_ [_ chat-id {:keys [returned]}]]
(let [{:keys [data messages err]} returned
content (if err
err
data)]
content (or err data)]
(doseq [message messages]
(let [{:keys [message type]} message]
(dispatch [:received-message

View File

@ -47,7 +47,7 @@
(dispatch [:sign-up-confirm (second matches)])))
(defn start-listening-confirmation-code-sms [db]
(if (not (:confirmation-code-sms-listener db))
(if-not (:confirmation-code-sms-listener db)
(assoc db :confirmation-code-sms-listener (add-sms-listener handle-sms))
db))
@ -83,11 +83,10 @@
:to "me"}])
(let [status (keyword (:status body))]
(when (= :confirmed status)
(do
(dispatch [:stop-listening-confirmation-code-sms])
(sync-contacts)
;; TODO should be called after sync-contacts?
(dispatch [:set-signed-up true])))
(dispatch [:stop-listening-confirmation-code-sms])
(sync-contacts)
;; TODO should be called after sync-contacts?
(dispatch [:set-signed-up true]))
(when (= :failed status)
(on-sign-up-response (label :t/incorrect-code)))))

View File

@ -184,7 +184,7 @@
(register-sub :is-request-answered?
(fn [_ [_ message-id]]
(let [requests (subscribe [:get-requests])]
(reaction (not (some #(= message-id (:message-id %)) @requests))))))
(reaction (not-any? #(= message-id (:message-id %)) @requests)))))
(register-sub :validation-errors
(fn [db]
@ -211,7 +211,7 @@
(let [chat-id (subscribe [:get-current-chat-id])]
(reaction
(min (get-in @db [:animations :to-response-height @chat-id])
(if (> (:layout-height @db) 0)
(if (pos? (:layout-height @db))
(- (:layout-height @db)
(get-in platform-specific [:component-styles :status-bar status-bar :height]))
0))))))

View File

@ -23,7 +23,7 @@
[chat-icon-view-menu-item chat-id group-chat name color true])
(defn- members-text [members]
(str (s/join ", " (map #(:name %) members))
(str (s/join ", " (map :name members))
" "
(label :t/and-you)))
@ -121,8 +121,9 @@
(when-let [actions (if @group-chat
(group-chat-items @members)
(user-chat-items @chat-id))]
[view (-> (st/actions-wrapper status-bar-height)
(merge (get-in platform-specific [:component-styles :actions-list-view])))
[view (merge
(st/actions-wrapper status-bar-height)
(get-in platform-specific [:component-styles :actions-list-view]))
[view st/actions-separator]
[view st/actions-view
(for [action actions]

View File

@ -185,7 +185,7 @@
[text
{:key (str idx "_" string)
:style style}
(subs string 1 (- (count string) 1))]))
(subs string 1 (dec (count string)))]))
(re-seq regx string)))
styled-text' (if (> (count general-text)
(count styled-text))
@ -331,7 +331,7 @@
(defn message-container-animation-logic [{:keys [to-value val callback]}]
(fn [_]
(let [to-value @to-value]
(when (< 0 to-value)
(when (pos? to-value)
(anim/start
(anim/timing val {:toValue to-value
:duration 250})

View File

@ -33,8 +33,7 @@
type [:command-type]
suggestions [:get-suggestions]
message-input-height [:get-message-input-view-height]]
(let [on-top? (or (and (not (empty? suggestions))
(not command?))
(let [on-top? (or (and (seq suggestions) (not command?))
(not= response-height input-height))
style (get-in platform-specific [:component-styles :chat :new-message])]
[view {:style (merge (st/new-message-container margin on-top?) style)

View File

@ -20,7 +20,8 @@
(defn label [command]
(when command
(->> (name (:name command))
(->> (:name command)
name
(str "request-"))))
(def min-scale 1)

View File

@ -22,7 +22,7 @@
contact (let [last-online (get contact :last-online)
last-online-date (time/to-date last-online)
now-date (t/now)]
(if (and (> last-online 0)
(if (and (pos? last-online)
(<= last-online-date now-date))
(time/time-ago last-online-date)
(label :t/active-unknown)))

View File

@ -93,7 +93,7 @@
registered-only)))
(remove (fn [[n]]
(and
(not (= console-chat-id id))
(not= console-chat-id id)
(h/matches (name n) "password"))))
(into {})))

View File

@ -158,18 +158,11 @@
:default-chat-icon (st/default-chat-icon-profile color)
:default-chat-icon-text st/default-chat-icon-text}]
[view (:container styles)
(if (and photo-path (not (empty? photo-path)))
(if (and photo-path (seq photo-path))
[chat-icon photo-path styles]
[default-chat-icon name styles])
[contact-badge badge-type styles]]))
(defview profile-icon []
[contact [:contact]]
(let [;; TODO: stub
type :online
color default-chat-color]
[profile-icon-view (:photo-path @contact) (:name @contact) color type]))
(defn my-profile-icon [{{:keys [photo-path name]} :account
edit? :edit?}]
(let [type (if edit? :edit :blank)

View File

@ -2,7 +2,7 @@
(:require [status-im.components.styles :refer [color-white]]))
(def tabs-height 56)
(def tab-height (- tabs-height 1))
(def tab-height (dec tabs-height))
(def bottom-gradient
{:position :absolute

View File

@ -48,8 +48,7 @@
(defn toolbar-actions-container [actions-count custom]
(merge {:flex-direction "row"
:margin-left toolbar-icon-spacing}
(when (and (= actions-count 0)
(not custom))
(when (and (zero? actions-count) (not custom))
{:width (+ toolbar-icon-width toolbar-icon-spacing)})))
(def toolbar-action

View File

@ -25,7 +25,7 @@
[view {:style style}
[view st/toolbar
[view (st/toolbar-nav-actions-container actions)
(when (not hide-nav?)
(when-not hide-nav?
(if nav-action
[touchable-highlight {:on-press (:handler nav-action)}
[view (get-in platform-specific [:component-styles :toolbar-nav-action])

View File

@ -208,15 +208,16 @@
((after send-contact-request))))
(register-handler ::update-pending-contact
(-> add-new-contact
((after save-contact))))
(after save-contact)
add-new-contact)
(register-handler :add-pending-contact
(u/side-effect!
(fn [{:keys [chats contacts]} [_ chat-id]]
(let [contact (if-let [contact-info (get-in chats [chat-id :contact-info])]
(read-string contact-info)
(-> (get contacts chat-id)
(-> contacts
(get chat-id)
(assoc :pending false)))]
(dispatch [::prepare-contact contact])
(dispatch [:update-chat! {:chat-id chat-id
@ -259,12 +260,12 @@
:last-online timestamp}]))))))
(register-handler :remove-contact
(-> (u/side-effect!
(fn [_ [_ {:keys [whisper-identity] :as contact}]]
(dispatch [:update-chat! {:chat-id whisper-identity
:pending-contact? true}])
(dispatch [:update-contact! (assoc contact :pending true)])))
((after stop-watching-contact))))
(after stop-watching-contact)
(u/side-effect!
(fn [_ [_ {:keys [whisper-identity] :as contact}]]
(dispatch [:update-chat! {:chat-id whisper-identity
:pending-contact? true}])
(dispatch [:update-contact! (assoc contact :pending true)]))))
(register-handler :open-contact-menu
(u/side-effect!

View File

@ -9,12 +9,12 @@
(reaction @contacts))))
(defn sort-contacts [contacts]
(->> (vals contacts)
(sort (fn [c1 c2]
(let [name1 (or (:name c1) (:address c1) (:whisper-identity c1))
name2 (or (:name c2) (:address c2) (:whisper-identity c2))]
(compare (clojure.string/lower-case name1)
(clojure.string/lower-case name2)))))))
(sort (fn [c1 c2]
(let [name1 (or (:name c1) (:address c1) (:whisper-identity c1))
name2 (or (:name c2) (:address c2) (:whisper-identity c2))]
(compare (clojure.string/lower-case name1)
(clojure.string/lower-case name2))))
(vals contacts)))
(register-sub :all-added-contacts
(fn [db _]
@ -112,16 +112,13 @@
chat (reaction (get-in @db [:chats chat-id]))
contacts (contacts-by-chat filter db chat-id)]
(reaction
(when @chat
(if (:group-chat @chat)
;; TODO return group chat icon
nil
(cond
(:photo-path @chat)
(:photo-path @chat)
(when (and @chat (not (:group-chat @chat)))
(cond
(:photo-path @chat)
(:photo-path @chat)
(pos? (count @contacts))
(:photo-path (first @contacts))
(pos? (count @contacts))
(:photo-path (first @contacts))
:else
(identicon chat-id))))))))
:else
(identicon chat-id)))))))

View File

@ -9,8 +9,7 @@
(defn contact-can-be-added? [identity]
(if (contacts/exists? identity)
(-> (contacts/get-by-id identity)
(get :pending))
(:pending (contacts/get-by-id identity))
true))
(defn valid-length? [identity]

View File

@ -9,8 +9,7 @@
(defn get-all
[]
(-> (data-store/get-all-active)
normalize-contacts))
(normalize-contacts (data-store/get-all-active)))
(defn get-by-id
[id]

View File

@ -4,8 +4,8 @@
(defn get-all
[ordering]
(->> (data-store/get-all-as-list ordering)
(mapv #(update % :tags vals))))
(mapv #(update % :tags vals)
(data-store/get-all-as-list ordering)))
(defn save
[discover]

View File

@ -5,8 +5,7 @@
(realm/get-all realm/base-realm :account))
(defn get-all-as-list []
(-> (get-all)
realm/realm-collection->list))
(realm/realm-collection->list (get-all)))
(defn get-by-address [address]
(realm/get-one-by-field-clj realm/base-realm :account :address address))

View File

@ -5,13 +5,13 @@
(defn get-all
[]
(-> (realm/get-all @realm/account-realm :chat)
(-> @realm/account-realm
(realm/get-all :chat)
(realm/sorted :timestamp :desc)))
(defn get-all-as-list
[]
(-> (get-all)
realm/realm-collection->list))
(realm/realm-collection->list (get-all)))
(defn get-all-active
[]
@ -36,7 +36,8 @@
(defn get-by-id
[chat-id]
(-> (realm/get-one-by-field-clj @realm/account-realm :chat :chat-id chat-id)
(-> @realm/account-realm
(realm/get-one-by-field-clj :chat :chat-id chat-id)
(realm/list->array :contacts)))
(defn save
@ -58,7 +59,8 @@
(defn get-contacts
[chat-id]
(-> (realm/get-one-by-field @realm/account-realm :chat :chat-id chat-id)
(-> @realm/account-realm
(realm/get-one-by-field :chat :chat-id chat-id)
(aget "contacts")))
(defn has-contact?
@ -102,7 +104,8 @@
[chat-id property-name value]
(realm/write @realm/account-realm
(fn []
(-> (realm/get-one-by-field @realm/account-realm :chat :chat-id chat-id)
(-> @realm/account-realm
(realm/get-one-by-field :chat :chat-id chat-id)
(aset (name property-name) value)))))
(defn get-property

View File

@ -4,13 +4,13 @@
(defn get-all
[]
(-> (realm/get-all @realm/account-realm :contact)
(-> @realm/account-realm
(realm/get-all :contact)
(realm/sorted :name :asc)))
(defn get-all-as-list
[]
(-> (get-all)
realm/realm-collection->list))
(realm/realm-collection->list (get-all)))
(defn get-by-id
[whisper-identity]

View File

@ -35,7 +35,6 @@
(open-realm (last schemas) file-name))
(def new-account-filename "new-account")
(def new-accout-realm-file (str new-account-filename ".realm"))
(def base-realm (open-migrated-realm (.-defaultPath realm-class) base/schemas))
@ -122,7 +121,8 @@
(.filtered results filter-query))
(defn realm-collection->list [collection]
(-> (.map collection (fn [object _ _] object))
(-> collection
(.map (fn [object _ _] object))
(js->clj :keywordize-keys true)))
(defn list->array [record list-field]
@ -136,7 +136,8 @@
(js->clj :keywordize-keys true)))
(defn get-by-filter [realm schema-name filter]
(-> (.objects realm (name schema-name))
(-> realm
(.objects (name schema-name))
(.filtered filter)))
(defn- get-schema-by-name [opts]

View File

@ -5,13 +5,13 @@
(defn get-all
[ordering]
(-> (realm/get-all @realm/account-realm :discover)
(-> @realm/account-realm
(realm/get-all :discover)
(realm/sorted :created-at ordering)))
(defn get-all-as-list
[ordering]
(-> (get-all ordering)
realm/realm-collection->list))
(realm/realm-collection->list (get-all ordering)))
(defn get-tag-by-name [tag]
(log/debug "Getting tag: " tag)
@ -65,7 +65,8 @@
(let [discoveries (realm/get-all @realm/account-realm :discover)
count (realm/get-count discoveries)]
(if (> count critical-count)
(let [to-delete (-> (realm/sorted discoveries by ordering)
(let [to-delete (-> discoveries
(realm/sorted by ordering)
(realm/page 0 to-delete-count))]
(realm/write @realm/account-realm
(fn []

View File

@ -9,8 +9,7 @@
(defn get-all-as-list
[]
(-> (get-all)
realm/realm-collection->list))
(realm/realm-collection->list (get-all)))
(defn get-by-id
[message-id]
@ -29,8 +28,7 @@
(defn get-count-by-chat-id
[chat-id]
(-> (get-by-chat-id chat-id)
(realm/get-count)))
(realm/get-count (get-by-chat-id chat-id)))
(defn get-by-fields
[fields from number-of-messages]
@ -47,8 +45,9 @@
(defn get-unviewed
[]
(-> (realm/get-by-fields @realm/account-realm :message :and {:outgoing false
:message-status nil})
(-> @realm/account-realm
(realm/get-by-fields :message :and {:outgoing false
:message-status nil})
(realm/realm-collection->list)))
(defn exists?

View File

@ -4,7 +4,8 @@
(defn get-all
[]
(-> (realm/get-all @realm/account-realm :processed-message)
(-> @realm/account-realm
(realm/get-all :processed-message)
(realm/sorted :ttl :asc)))
(defn get-filtered
@ -13,8 +14,7 @@
(defn get-filtered-as-list
[condition]
(-> (get-filtered condition)
realm/realm-collection->list))
(realm/realm-collection->list (get-filtered condition)))
(defn save
[processed-message]

View File

@ -7,8 +7,7 @@
(defn get-all-as-list
[]
(-> (get-all)
realm/realm-collection->list))
(realm/realm-collection->list (get-all)))
(defn get-open-by-chat-id
[chat-id]
@ -27,8 +26,9 @@
(defn- get-by-message-id
[chat-id message-id]
(-> (realm/get-by-fields @realm/account-realm :request :and [[:chat-id chat-id]
[:message-id message-id]])
(-> @realm/account-realm
(realm/get-by-fields :request :and [[:chat-id chat-id]
[:message-id message-id]])
(realm/single)))
(defn mark-as-answered

View File

@ -18,7 +18,8 @@
(defn- get-discoveries-by-tags [discoveries current-tag tags]
(let [tags' (or tags [current-tag])]
(filter #(every? (->> (map :name (:tags %))
(filter #(every? (->> (:tags %)
(map :name)
(into (hash-set)))
tags')
(vals discoveries))))
@ -42,13 +43,11 @@
(register-sub :get-popular-tags
(fn [db [_ limit]]
(-> (take limit (:tags @db))
(reaction))))
(reaction (take limit (:tags @db)))))
(register-sub :get-discover-search-results
(fn [db _]
(let [discoveries (reaction (:discoveries @db))
current-tag (reaction (:current-tag @db))
tags (reaction (:discover-search-tags @db))]
(-> (get-discoveries-by-tags @discoveries @current-tag @tags)
(reaction)))))
(reaction (get-discoveries-by-tags @discoveries @current-tag @tags)))))

View File

@ -31,14 +31,13 @@
(assoc-in db [:chats current-chat-id property-name] property))))
(defn prepare-chat-settings
[{:keys [current-chat-id] :as db} _]
[{:keys [current-chat-id] :as db}]
(let [{:keys [name color]} (-> db
(get-in [:chats current-chat-id])
(select-keys [:name :color]))]
(-> db
(assoc :new-chat-name name
:new-chat-color color
:group-settings {}))))
(assoc db :new-chat-name name
:new-chat-color color
:group-settings {})))
(register-handler :show-group-settings
(after (fn [_ _] (dispatch [:navigate-to :group-settings])))

View File

@ -42,13 +42,13 @@
([db type message-id command-key]
(set-command-input db type message-id command-key nil))
([{:keys [current-chat-id] :as db} type message-id command-key params]
(let [command (-> (get-response-or-command type db command-key)
(add-params params))
first-parameter (get (:params command) 0)
value (:value first-parameter)]
(let [command (get-response-or-command type db command-key)
command' (add-params command params)
first-parameter (get (:params command') 0)
value (:value first-parameter)]
(update-in db [:chats current-chat-id :command-input] merge
{:content value
:command command
:command command'
:parameter-idx 0
:params params
:to-message-id message-id}))))

View File

@ -45,20 +45,18 @@
[{:keys [web3 message]}]
(debug :send-clock-value-request message)
(d/add-pending-message!
web3
(merge message-defaults
(-> message
(assoc
:type :clock-value-request
:requires-ack? false)))))
web3
(merge message-defaults
(assoc message
:type :clock-value-request
:requires-ack? false))))
(defn send-clock-value!
[{:keys [web3 message]}]
(debug :send-clock-value message)
(d/add-pending-message!
web3
(merge message-defaults
(-> message
(assoc
:type :clock-value
:requires-ack? false)))))
web3
(merge message-defaults
(assoc message
:type :clock-value
:requires-ack? false))))

View File

@ -115,9 +115,8 @@
(defn send-status!
[{:keys [web3 message]}]
(debug :broadcasting-status)
(let [message (-> message
(assoc :type :discover
:topics [(make-discover-topic (:from message))]))]
(let [message (assoc message :type :discover
:topics [(make-discover-topic (:from message))])]
(d/add-pending-message! web3 message)))
(defn send-discoveries-request!
@ -125,19 +124,18 @@
(debug :sending-discoveries-request)
(d/add-pending-message!
web3
(-> message
(assoc :type :discoveries-request
:topics [(make-discover-topic (:from message))]))))
(assoc message :type :discoveries-request
:topics [(make-discover-topic (:from message))])))
(defn send-discoveries-response!
[{:keys [web3 discoveries message]}]
(debug :sending-discoveries-response)
(doseq [portion (->> (take 100 discoveries)
(doseq [portion (->> discoveries
(take 100)
(partition 10 10 nil))]
(d/add-pending-message!
web3
(-> message
(assoc :type :discoveries-response
:topics [(make-discover-topic (:from message))]
:message-id (random/id)
:payload {:data (into [] portion)})))))
(assoc message :type :discoveries-response
:topics [(make-discover-topic (:from message))]
:message-id (random/id)
:payload {:data (into [] portion)}))))

View File

@ -8,7 +8,8 @@
"Returns {:private \"private key\" :public \"public key\""
[]
(let [{:keys [enc dec]}
(-> (.generate ecc (.-ENC_DEC ecc) default-curve)
(-> ecc
(.generate (.-ENC_DEC ecc) default-curve)
(js->clj :keywordize-keys true))]
{:private dec
:public enc}))

View File

@ -16,7 +16,8 @@
[status-im.utils.datetime :as dt]
[taoensso.timbre :as log :refer-macros [debug]]
[status-im.constants :as c]
[status-im.components.status :as status]))
[status-im.components.status :as status]
[clojure.string :refer [join]]))
(register-handler :initialize-protocol
(fn [db [_ current-account-id]]
@ -75,10 +76,11 @@
(register-handler :initialize-sync-listener
(fn [{:keys [web3 sync-listener] :as db} _]
(if-not sync-listener
(->> (.isSyncing (.-eth web3)
(fn [error sync]
(dispatch [:update-sync-state error sync])))
(assoc db :sync-listener))
(let [sync-listener (.isSyncing
(.-eth web3)
(fn [error sync]
(dispatch [:update-sync-state error sync])))]
(assoc db :sync-listener sync-listener))
db)))
(register-handler :incoming-message
@ -152,13 +154,15 @@
[identity from {:keys [message-id timestamp]}]
(let [remover-name (:name (contacts/get-by-id from))
removed-name (:name (contacts/get-by-id identity))]
(->> (str (or remover-name from) " " (label :t/removed) " " (or removed-name identity))
(->> [(or remover-name from) (label :t/removed) (or removed-name identity)]
(join " ")
(system-message message-id timestamp))))
(defn you-removed-from-group-message
[from {:keys [message-id timestamp]}]
(let [remover-name (:name (contacts/get-by-id from))]
(->> (str (or remover-name from) " " (label :t/removed-from-chat))
(->> [(or remover-name from) (label :t/removed-from-chat)]
(join " ")
(system-message message-id timestamp))))
(defn participant-left-group-message
@ -198,10 +202,9 @@
[_ {:keys [from]
{:keys [group-id timestamp] :as payload} :payload}]]
(when (chats/new-update? timestamp group-id)
(let [message
(-> (you-removed-from-group-message from payload)
(assoc :group-id group-id))]
(dispatch [:received-message message]))
(let [message (you-removed-from-group-message from payload)
message' (assoc message :group-id group-id)]
(dispatch [:received-message message']))
(protocol/stop-watching-group! {:web3 web3
:group-id group-id})
(dispatch [:update-chat! {:chat-id group-id
@ -329,18 +332,18 @@
(register-handler :message-clock-value-request
(u/side-effect!
(fn [_ [_ {:keys [from] {:keys [message-id]} :payload}]]
(let [{:keys [chat-id]} (messages/get-by-id message-id)
message-overhead (chats/get-message-overhead chat-id)
last-clock-value (messages/get-last-clock-value chat-id)]
(if (> message-overhead 0)
(let [last-outgoing (->> (messages/get-last-outgoing chat-id message-overhead)
(reverse)
(map-indexed vector))]
(chats/reset-message-overhead chat-id)
(doseq [[i message] last-outgoing]
(dispatch [:update-clock-value! from i message (+ last-clock-value 100)])))
(dispatch [:send-clock-value! from message-id]))))))
(fn [_ [_ {:keys [from] {:keys [message-id]} :payload}]]
(let [{:keys [chat-id]} (messages/get-by-id message-id)
message-overhead (chats/get-message-overhead chat-id)
last-clock-value (messages/get-last-clock-value chat-id)]
(if (pos? message-overhead)
(let [last-outgoing (->> (messages/get-last-outgoing chat-id message-overhead)
(reverse)
(map-indexed vector))]
(chats/reset-message-overhead chat-id)
(doseq [[i message] last-outgoing]
(dispatch [:update-clock-value! from i message (+ last-clock-value 100)])))
(dispatch [:send-clock-value! from message-id]))))))
(register-handler :message-clock-value
(after save-message-clock-value!)

View File

@ -6,7 +6,7 @@
(defn init!
[messages]
(reset! messages-set (into #{} messages))
(reset! messages-set (set messages))
(reset! messages-map (->> messages
(map (fn [{:keys [message-id type] :as message}]
[[message-id type] message]))

View File

@ -4,8 +4,6 @@
(def web3 (js/require "web3"))
(def status-app-topic "status-app")
(defn from-utf8 [s]
(.fromUtf8 web3.prototype s))
@ -16,8 +14,9 @@
(.-shh web3))
(defn make-web3 [rpc-url]
(->> (web3.providers.HttpProvider. rpc-url)
(web3.)))
(->> rpc-url
web3.providers.HttpProvider.
web3.))
(defn timestamp []
(to-long (now)))

View File

@ -35,7 +35,7 @@
:else (today-format-fn local)))))
(defn day-relative [ms]
(when (> ms 0)
(when (pos? ms)
(to-short-str ms #(label :t/datetime-today))))
(defn format-time-ago [diff unit]

View File

@ -4,8 +4,7 @@
(def Web3 (js/require "web3"))
(defn web3 []
(->> (Web3.providers.HttpProvider. c/ethereum-rpc-url)
(Web3.)))
(Web3. (Web3.providers.HttpProvider. c/ethereum-rpc-url)))
(def networks
{"0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" :mainnet

View File

@ -5,8 +5,7 @@
(defn- pick-random
[vector]
(-> (rand-nth vector)
str/capitalize))
(str/capitalize (rand-nth vector)))
(defn generate-gfy
[]

View File

@ -12,11 +12,9 @@
(.catch on-error))))
(defn- image-base64-encode [path on-success on-error]
(let [on-encoded (fn [data]
(on-success data))
on-error (fn [error]
(let [on-error (fn [error]
(on-error :base64 error))]
(read-file path "base64" on-encoded on-error)))
(read-file path "base64" on-success on-error)))
(defn img->base64 [path on-success on-error]
(let [on-resized (fn [path]