Beginning of chat (#296), fix for status saving
This commit is contained in:
parent
1128e5d089
commit
ba885ea97f
|
@ -79,6 +79,7 @@
|
|||
(let [message (-> row
|
||||
(add-message-color contact-by-identity)
|
||||
(assoc :group-chat group-chat)
|
||||
(assoc :messages-count messages-count)
|
||||
(assoc :last-message (= (js/parseInt index) (dec messages-count))))]
|
||||
(list-item [chat-message message])))
|
||||
|
||||
|
@ -142,15 +143,27 @@
|
|||
:custom-action [toolbar-action]
|
||||
:style (get-in platform-specific [:component-styles :toolbar])}]])
|
||||
|
||||
(defn get-intro-status-message [all-messages]
|
||||
(let [{:keys [timestamp content-type] :as last-message} (last all-messages)]
|
||||
(when (not= content-type content-type-status)
|
||||
{:message-id "intro-status"
|
||||
:content-type content-type-status
|
||||
:timestamp (or timestamp (time/now-ms))})))
|
||||
|
||||
|
||||
(defn messages-with-timemarks [all-messages]
|
||||
(let [messages (->> all-messages
|
||||
(map #(assoc % :datemark (time/day-relative (:timestamp %))))
|
||||
(group-by :datemark)
|
||||
(map (fn [[k v]] [v {:type :datemark :value k}]))
|
||||
(flatten))
|
||||
remove-last? (some (fn [{:keys [content-type]}]
|
||||
(= content-type content-type-status))
|
||||
messages)]
|
||||
(let [status-message (get-intro-status-message all-messages)
|
||||
all-messages (if status-message
|
||||
(concat all-messages [status-message])
|
||||
all-messages)
|
||||
messages (->> all-messages
|
||||
(map #(assoc % :datemark (time/day-relative (:timestamp %))))
|
||||
(group-by :datemark)
|
||||
(map (fn [[k v]] [v {:type :datemark :value k}]))
|
||||
(flatten))
|
||||
remove-last? (some (fn [{:keys [content-type]}]
|
||||
(= content-type content-type-status))
|
||||
messages)]
|
||||
(if remove-last?
|
||||
(drop-last messages)
|
||||
messages)))
|
||||
|
|
|
@ -121,8 +121,6 @@
|
|||
;; TODO highlight '!phone'
|
||||
(start-signup))
|
||||
|
||||
|
||||
|
||||
(def intro-status
|
||||
{:message-id "intro-status"
|
||||
:content (label :t/intro-status)
|
||||
|
|
|
@ -40,6 +40,9 @@
|
|||
{:margin-top 10
|
||||
:margin-bottom -4})
|
||||
|
||||
(def message-empty-spacing
|
||||
{:height 16})
|
||||
|
||||
(def message-body-base
|
||||
{:padding-right 8
|
||||
:padding-left 8})
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
(merge message
|
||||
{:same-author (if previous-message
|
||||
(= (:from previous-message) from)
|
||||
false)
|
||||
true)
|
||||
:same-direction (if previous-message
|
||||
(= (:outgoing previous-message) outgoing)
|
||||
true)}))
|
||||
|
|
|
@ -18,12 +18,16 @@
|
|||
[status-im.models.commands :refer [parse-command-message-content
|
||||
parse-command-request]]
|
||||
[status-im.resources :as res]
|
||||
[status-im.constants :refer [text-content-type
|
||||
[status-im.utils.datetime :as time]
|
||||
[status-im.constants :refer [console-chat-id
|
||||
text-content-type
|
||||
content-type-status
|
||||
content-type-command
|
||||
content-type-command-request]]
|
||||
[status-im.utils.identicon :refer [identicon]]
|
||||
[status-im.chat.utils :as cu]))
|
||||
[status-im.i18n :refer [label]]
|
||||
[status-im.chat.utils :as cu]
|
||||
[clojure.string :as str]))
|
||||
|
||||
(defn contact-photo [photo-path]
|
||||
[view st/contact-photo-container
|
||||
|
@ -32,28 +36,46 @@
|
|||
{:uri photo-path})
|
||||
:style st/contact-photo}]])
|
||||
|
||||
(defn contact-online [{:keys [online]}]
|
||||
(when online
|
||||
(defn contact-online [online?]
|
||||
(when online?
|
||||
[view st/online-container
|
||||
[view st/online-dot-left]
|
||||
[view st/online-dot-right]]))
|
||||
|
||||
(defview message-content-status
|
||||
[{:keys [from content datemark]}]
|
||||
[{chat-name :name} [:get-chat-by-id from]
|
||||
photo-path [:chat-photo from]]
|
||||
[view st/status-container
|
||||
[view st/status-image-view
|
||||
[contact-photo photo-path]
|
||||
[contact-online {:online true}]]
|
||||
[text {:style st/status-from
|
||||
:font :default}
|
||||
(or chat-name from)]
|
||||
[text {:style st/status-text
|
||||
:font :default}
|
||||
content]
|
||||
[view st/message-datemark
|
||||
[chat-datemark datemark]]])
|
||||
;;[photo-path (subscribe [:chat-photo from])
|
||||
|
||||
(defn message-content-status [{:keys [from]}]
|
||||
(let [chat-photo-path (subscribe [:chat-photo from])
|
||||
{:keys [group-chat name]} (subscribe [:chat-properties [:group-chat :name]])
|
||||
members (subscribe [:current-chat-contacts])]
|
||||
(fn [{:keys [messages-count content datemark]}]
|
||||
(let [{:keys [photo-path
|
||||
status
|
||||
last-online]} (if @group-chat
|
||||
{:photo-path nil
|
||||
:status nil
|
||||
:last-online 0}
|
||||
(first @members))
|
||||
online? (-> (- (time/now-ms) last-online)
|
||||
(< (* 60 1000)))]
|
||||
[view st/status-container
|
||||
[view st/status-image-view
|
||||
[contact-photo (or photo-path @chat-photo-path)]
|
||||
[contact-online online?]]
|
||||
[text {:style st/status-from
|
||||
:font :default
|
||||
:number-of-lines 1}
|
||||
(if (str/blank? @name)
|
||||
(label :t/user-anonymous)
|
||||
(or @name (label :t/chat-name)))]
|
||||
(when (or status content)
|
||||
[text {:style st/status-text
|
||||
:font :default}
|
||||
(or status content)])
|
||||
(if (> messages-count 1)
|
||||
[view st/message-datemark
|
||||
[chat-datemark datemark]]
|
||||
[view st/message-empty-spacing])]))))
|
||||
|
||||
(defn message-content-audio [_]
|
||||
[view st/audio-container
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
(ns status-im.data-store.realm.schemas.account.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v1.core :as v1]))
|
||||
(:require [status-im.data-store.realm.schemas.account.v1.core :as v1]
|
||||
[status-im.data-store.realm.schemas.account.v2.core :as v2]))
|
||||
|
||||
; put schemas ordered by version
|
||||
(def schemas [{:schema v1/schema
|
||||
:schemaVersion 1
|
||||
:migration v1/migration}])
|
||||
:migration v1/migration}
|
||||
{:schema v2/schema
|
||||
:schemaVersion 2
|
||||
:migration v2/migration}])
|
|
@ -0,0 +1,22 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v2.contact
|
||||
(:require [taoensso.timbre :as log]))
|
||||
|
||||
(def schema {:name :contact
|
||||
:primaryKey :whisper-identity
|
||||
:properties {:address {:type "string" :optional true}
|
||||
:whisper-identity "string"
|
||||
:name {:type "string" :optional true}
|
||||
:photo-path {:type "string" :optional true}
|
||||
:last-updated {:type "int" :default 0}
|
||||
:last-online {:type "int" :default 0}
|
||||
:pending {:type "bool" :default false}
|
||||
:status {:type "string" :optional true}
|
||||
:public-key {:type :string
|
||||
:optional true}
|
||||
:private-key {:type :string
|
||||
:optional true}
|
||||
:dapp? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating contact schema"))
|
|
@ -0,0 +1,29 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v2.core
|
||||
(:require [taoensso.timbre :as log]
|
||||
[status-im.data-store.realm.schemas.account.v2.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.command :as command]
|
||||
[status-im.data-store.realm.schemas.account.v1.discovery :as discovery]
|
||||
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
|
||||
[status-im.data-store.realm.schemas.account.v1.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v1.pending-message :as pending-message]
|
||||
[status-im.data-store.realm.schemas.account.v1.request :as request]
|
||||
[status-im.data-store.realm.schemas.account.v1.tag :as tag]
|
||||
[status-im.data-store.realm.schemas.account.v1.user-status :as user-status]))
|
||||
|
||||
(def schema [chat/schema
|
||||
chat-contact/schema
|
||||
command/schema
|
||||
contact/schema
|
||||
discovery/schema
|
||||
kv-store/schema
|
||||
message/schema
|
||||
pending-message/schema
|
||||
request/schema
|
||||
tag/schema
|
||||
user-status/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v2 account database: " old-realm new-realm)
|
||||
(contact/migration old-realm new-realm))
|
Loading…
Reference in New Issue