fix #1486 chat: removable console chat
This commit is contained in:
parent
7a3e9a1f96
commit
4521020ce5
|
@ -22,7 +22,7 @@
|
|||
:content-type text-content-type
|
||||
:outgoing true})
|
||||
|
||||
; todo fn name is not too smart, but...
|
||||
;; todo fn name is not too smart, but...
|
||||
(defn command-content
|
||||
[command content]
|
||||
{:command (name command)
|
||||
|
@ -182,22 +182,23 @@
|
|||
:to "me"}]))
|
||||
|
||||
(def console-chat
|
||||
{:chat-id console-chat-id
|
||||
:name (s/capitalize console-chat-id)
|
||||
:color default-chat-color
|
||||
:group-chat false
|
||||
:is-active true
|
||||
:timestamp (.getTime (js/Date.))
|
||||
:photo-path console-chat-id
|
||||
:contacts [{:identity console-chat-id
|
||||
:text-color "#FFFFFF"
|
||||
:background-color "#AB7967"}]})
|
||||
{:chat-id console-chat-id
|
||||
:name (s/capitalize console-chat-id)
|
||||
:color default-chat-color
|
||||
:group-chat false
|
||||
:is-active true
|
||||
:unremovable? true
|
||||
:timestamp (.getTime (js/Date.))
|
||||
:photo-path console-chat-id
|
||||
:contacts [{:identity console-chat-id
|
||||
:text-color "#FFFFFF"
|
||||
:background-color "#AB7967"}]})
|
||||
|
||||
(def console-contact
|
||||
{:whisper-identity console-chat-id
|
||||
:name (s/capitalize console-chat-id)
|
||||
:photo-path console-chat-id
|
||||
:dapp? true
|
||||
:unremovable? true
|
||||
:bot-url "local://console-bot"
|
||||
:dapp-hash 858845357})
|
||||
{:whisper-identity console-chat-id
|
||||
:name (s/capitalize console-chat-id)
|
||||
:photo-path console-chat-id
|
||||
:dapp? true
|
||||
:unremovable? true
|
||||
:bot-url "local://console-bot"
|
||||
:dapp-hash 858845357})
|
||||
|
|
|
@ -117,7 +117,8 @@
|
|||
chat-name)]]]))
|
||||
|
||||
(defn chat-list-item-inner-view [{:keys [chat-id name color online
|
||||
group-chat contacts public?] :as chat}
|
||||
group-chat contacts public?
|
||||
unremovable?] :as chat}
|
||||
edit?]
|
||||
(let [last-message (subscribe [:get-last-message chat-id])
|
||||
name (or (get-contact-translated chat-id :name name)
|
||||
|
@ -136,4 +137,4 @@
|
|||
[message-content-text chat-id]
|
||||
(when-not edit? [unviewed-indicator chat-id])]]
|
||||
[view st/chat-options-container
|
||||
(when edit? [options-btn chat-id])]]))
|
||||
(when (and edit? (not unremovable?)) [options-btn chat-id])]]))
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
[status-im.utils.homoglyph :as h]
|
||||
[status-im.utils.js-resources :as js-res]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.chat.sign-up :as sign-up]
|
||||
[status-im.bots.constants :as bots-constants]
|
||||
[status-im.utils.datetime :as time]
|
||||
[status-im.data-store.local-storage :as local-storage]
|
||||
|
|
|
@ -8,9 +8,10 @@
|
|||
[status-im.data-store.realm.schemas.account.v7.core :as v7]
|
||||
[status-im.data-store.realm.schemas.account.v8.core :as v8]
|
||||
[status-im.data-store.realm.schemas.account.v9.core :as v9]
|
||||
[status-im.data-store.realm.schemas.account.v10.core :as v10]))
|
||||
[status-im.data-store.realm.schemas.account.v10.core :as v10]
|
||||
[status-im.data-store.realm.schemas.account.v11.core :as v11]))
|
||||
|
||||
; put schemas ordered by version
|
||||
;; put schemas ordered by version
|
||||
(def schemas [{:schema v1/schema
|
||||
:schemaVersion 1
|
||||
:migration v1/migration}
|
||||
|
@ -40,4 +41,7 @@
|
|||
:migration v9/migration}
|
||||
{:schema v10/schema
|
||||
:schemaVersion 10
|
||||
:migration v10/migration}])
|
||||
:migration v10/migration}
|
||||
{:schema v11/schema
|
||||
:schemaVersion 11
|
||||
:migration v11/migration}])
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v11.chat
|
||||
(:require [taoensso.timbre :as log]
|
||||
[status-im.components.styles :refer [default-chat-color]]))
|
||||
|
||||
(def schema {:name :chat
|
||||
:primaryKey :chat-id
|
||||
:properties {:chat-id :string
|
||||
:name :string
|
||||
:color {:type :string
|
||||
:default default-chat-color}
|
||||
:group-chat {:type :bool
|
||||
:indexed true}
|
||||
:group-admin {:type :string
|
||||
:optional true}
|
||||
:is-active :bool
|
||||
:timestamp :int
|
||||
:contacts {:type :list
|
||||
:objectType :chat-contact}
|
||||
:unremovable? {:type :bool
|
||||
:default false}
|
||||
:removed-at {:type :int
|
||||
:optional true}
|
||||
:removed-from-at {:type :int
|
||||
:optional true}
|
||||
:added-to-at {:type :int
|
||||
:optional true}
|
||||
:updated-at {:type :int
|
||||
:optional true}
|
||||
:last-message-id :string
|
||||
:message-overhead {:type :int
|
||||
:default 0}
|
||||
:public-key {:type :string
|
||||
:optional true}
|
||||
:private-key {:type :string
|
||||
:optional true}
|
||||
:contact-info {:type :string
|
||||
:optional true}
|
||||
:debug? {:type :bool
|
||||
:default false}
|
||||
:public? {:type :bool
|
||||
:default false}}})
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating chat schema v11")
|
||||
;; make sure that console chat has `:unremovable?` set to true
|
||||
(when-let [console-chat (-> new-realm
|
||||
(.objects "chat")
|
||||
(.filtered "chat-id = \"console\"")
|
||||
(aget 0))]
|
||||
(aset console-chat "unremovable?" true)))
|
|
@ -0,0 +1,39 @@
|
|||
(ns status-im.data-store.realm.schemas.account.v11.core
|
||||
(:require [status-im.data-store.realm.schemas.account.v11.chat :as chat]
|
||||
[status-im.data-store.realm.schemas.account.v1.chat-contact :as chat-contact]
|
||||
[status-im.data-store.realm.schemas.account.v6.command :as command]
|
||||
[status-im.data-store.realm.schemas.account.v9.command-parameter :as command-parameter]
|
||||
[status-im.data-store.realm.schemas.account.v7.contact :as contact]
|
||||
[status-im.data-store.realm.schemas.account.v1.discover :as discover]
|
||||
[status-im.data-store.realm.schemas.account.v1.kv-store :as kv-store]
|
||||
[status-im.data-store.realm.schemas.account.v10.message :as message]
|
||||
[status-im.data-store.realm.schemas.account.v7.pending-message :as pending-message]
|
||||
[status-im.data-store.realm.schemas.account.v1.processed-message :as processed-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]
|
||||
[status-im.data-store.realm.schemas.account.v5.contact-group :as contact-group]
|
||||
[status-im.data-store.realm.schemas.account.v5.group-contact :as group-contact]
|
||||
[status-im.data-store.realm.schemas.account.v8.local-storage :as local-storage]
|
||||
[taoensso.timbre :as log]))
|
||||
|
||||
(def schema [chat/schema
|
||||
chat-contact/schema
|
||||
command/schema
|
||||
command-parameter/schema
|
||||
contact/schema
|
||||
discover/schema
|
||||
kv-store/schema
|
||||
message/schema
|
||||
pending-message/schema
|
||||
processed-message/schema
|
||||
request/schema
|
||||
tag/schema
|
||||
user-status/schema
|
||||
contact-group/schema
|
||||
group-contact/schema
|
||||
local-storage/schema])
|
||||
|
||||
(defn migration [old-realm new-realm]
|
||||
(log/debug "migrating v11 account database: " old-realm new-realm)
|
||||
(chat/migration old-realm new-realm))
|
Loading…
Reference in New Issue