Beginning of chat (#296), fix for status saving
Former-commit-id: ba885ea97f
This commit is contained in:
parent
84aea91b99
commit
2296f1ff5b
|
@ -79,6 +79,7 @@
|
||||||
(let [message (-> row
|
(let [message (-> row
|
||||||
(add-message-color contact-by-identity)
|
(add-message-color contact-by-identity)
|
||||||
(assoc :group-chat group-chat)
|
(assoc :group-chat group-chat)
|
||||||
|
(assoc :messages-count messages-count)
|
||||||
(assoc :last-message (= (js/parseInt index) (dec messages-count))))]
|
(assoc :last-message (= (js/parseInt index) (dec messages-count))))]
|
||||||
(list-item [chat-message message])))
|
(list-item [chat-message message])))
|
||||||
|
|
||||||
|
@ -142,8 +143,20 @@
|
||||||
:custom-action [toolbar-action]
|
:custom-action [toolbar-action]
|
||||||
:style (get-in platform-specific [:component-styles :toolbar])}]])
|
: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]
|
(defn messages-with-timemarks [all-messages]
|
||||||
(let [messages (->> all-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 %))))
|
(map #(assoc % :datemark (time/day-relative (:timestamp %))))
|
||||||
(group-by :datemark)
|
(group-by :datemark)
|
||||||
(map (fn [[k v]] [v {:type :datemark :value k}]))
|
(map (fn [[k v]] [v {:type :datemark :value k}]))
|
||||||
|
|
|
@ -121,8 +121,6 @@
|
||||||
;; TODO highlight '!phone'
|
;; TODO highlight '!phone'
|
||||||
(start-signup))
|
(start-signup))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(def intro-status
|
(def intro-status
|
||||||
{:message-id "intro-status"
|
{:message-id "intro-status"
|
||||||
:content (label :t/intro-status)
|
:content (label :t/intro-status)
|
||||||
|
|
|
@ -40,6 +40,9 @@
|
||||||
{:margin-top 10
|
{:margin-top 10
|
||||||
:margin-bottom -4})
|
:margin-bottom -4})
|
||||||
|
|
||||||
|
(def message-empty-spacing
|
||||||
|
{:height 16})
|
||||||
|
|
||||||
(def message-body-base
|
(def message-body-base
|
||||||
{:padding-right 8
|
{:padding-right 8
|
||||||
:padding-left 8})
|
:padding-left 8})
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
(merge message
|
(merge message
|
||||||
{:same-author (if previous-message
|
{:same-author (if previous-message
|
||||||
(= (:from previous-message) from)
|
(= (:from previous-message) from)
|
||||||
false)
|
true)
|
||||||
:same-direction (if previous-message
|
:same-direction (if previous-message
|
||||||
(= (:outgoing previous-message) outgoing)
|
(= (:outgoing previous-message) outgoing)
|
||||||
true)}))
|
true)}))
|
||||||
|
|
|
@ -18,12 +18,16 @@
|
||||||
[status-im.models.commands :refer [parse-command-message-content
|
[status-im.models.commands :refer [parse-command-message-content
|
||||||
parse-command-request]]
|
parse-command-request]]
|
||||||
[status-im.resources :as res]
|
[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-status
|
||||||
content-type-command
|
content-type-command
|
||||||
content-type-command-request]]
|
content-type-command-request]]
|
||||||
[status-im.utils.identicon :refer [identicon]]
|
[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]
|
(defn contact-photo [photo-path]
|
||||||
[view st/contact-photo-container
|
[view st/contact-photo-container
|
||||||
|
@ -32,28 +36,46 @@
|
||||||
{:uri photo-path})
|
{:uri photo-path})
|
||||||
:style st/contact-photo}]])
|
:style st/contact-photo}]])
|
||||||
|
|
||||||
(defn contact-online [{:keys [online]}]
|
(defn contact-online [online?]
|
||||||
(when online
|
(when online?
|
||||||
[view st/online-container
|
[view st/online-container
|
||||||
[view st/online-dot-left]
|
[view st/online-dot-left]
|
||||||
[view st/online-dot-right]]))
|
[view st/online-dot-right]]))
|
||||||
|
|
||||||
(defview message-content-status
|
;;[photo-path (subscribe [:chat-photo from])
|
||||||
[{:keys [from content datemark]}]
|
|
||||||
[{chat-name :name} [:get-chat-by-id from]
|
(defn message-content-status [{:keys [from]}]
|
||||||
photo-path [:chat-photo 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-container
|
||||||
[view st/status-image-view
|
[view st/status-image-view
|
||||||
[contact-photo photo-path]
|
[contact-photo (or photo-path @chat-photo-path)]
|
||||||
[contact-online {:online true}]]
|
[contact-online online?]]
|
||||||
[text {:style st/status-from
|
[text {:style st/status-from
|
||||||
:font :default}
|
:font :default
|
||||||
(or chat-name from)]
|
: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
|
[text {:style st/status-text
|
||||||
:font :default}
|
:font :default}
|
||||||
content]
|
(or status content)])
|
||||||
|
(if (> messages-count 1)
|
||||||
[view st/message-datemark
|
[view st/message-datemark
|
||||||
[chat-datemark datemark]]])
|
[chat-datemark datemark]]
|
||||||
|
[view st/message-empty-spacing])]))))
|
||||||
|
|
||||||
(defn message-content-audio [_]
|
(defn message-content-audio [_]
|
||||||
[view st/audio-container
|
[view st/audio-container
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
(ns status-im.data-store.realm.schemas.account.core
|
(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
|
; put schemas ordered by version
|
||||||
(def schemas [{:schema v1/schema
|
(def schemas [{:schema v1/schema
|
||||||
:schemaVersion 1
|
: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