parent
8919410735
commit
435d11eb2a
|
@ -113,14 +113,12 @@
|
||||||
:icon-style {:width 12
|
:icon-style {:width 12
|
||||||
:height 12}
|
:height 12}
|
||||||
:title "Clear history"
|
:title "Clear history"
|
||||||
:subtitle "!not implemented"
|
:handler #(dispatch [:clear-history])}
|
||||||
:handler nil}
|
|
||||||
{:icon :bin
|
{:icon :bin
|
||||||
:icon-style {:width 12
|
:icon-style {:width 12
|
||||||
:height 18}
|
:height 18}
|
||||||
:title "Delete and leave"
|
:title "Delete and leave"
|
||||||
:subtitle "!not implemented"
|
:handler #(dispatch [:leave-group-chat])}]]
|
||||||
:handler nil}]]
|
|
||||||
[view st/settings-container
|
[view st/settings-container
|
||||||
(for [setting settings]
|
(for [setting settings]
|
||||||
^{:key setting} [setting-view setting])]))
|
^{:key setting} [setting-view setting])]))
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
[syng-im.models.messages :refer [save-message
|
[syng-im.models.messages :refer [save-message
|
||||||
update-message!
|
update-message!
|
||||||
message-by-id
|
message-by-id
|
||||||
get-messages]]
|
get-messages
|
||||||
|
clear-history]]
|
||||||
[syng-im.models.commands :as commands :refer [set-chat-command
|
[syng-im.models.commands :as commands :refer [set-chat-command
|
||||||
set-response-chat-command
|
set-response-chat-command
|
||||||
set-chat-command-content
|
set-chat-command-content
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
chat-add-participants
|
chat-add-participants
|
||||||
chat-remove-participants
|
chat-remove-participants
|
||||||
set-chat-active
|
set-chat-active
|
||||||
|
delete-chat
|
||||||
re-join-group-chat
|
re-join-group-chat
|
||||||
chat-by-id2] :as chats]
|
chat-by-id2] :as chats]
|
||||||
[syng-im.models.chat :refer [signal-chat-updated
|
[syng-im.models.chat :refer [signal-chat-updated
|
||||||
|
@ -395,6 +397,13 @@
|
||||||
((after save-commands-to-realm!))
|
((after save-commands-to-realm!))
|
||||||
((after handle-commands))))
|
((after handle-commands))))
|
||||||
|
|
||||||
|
(register-handler :clear-history
|
||||||
|
(fn [db [action]]
|
||||||
|
(log/debug action)
|
||||||
|
(let [chat-id (current-chat-id db)]
|
||||||
|
(clear-history chat-id)
|
||||||
|
(signal-chat-updated db chat-id))))
|
||||||
|
|
||||||
(register-handler :leave-group-chat
|
(register-handler :leave-group-chat
|
||||||
(fn [db [action]]
|
(fn [db [action]]
|
||||||
(log/debug action)
|
(log/debug action)
|
||||||
|
@ -402,6 +411,8 @@
|
||||||
(api/leave-group-chat chat-id)
|
(api/leave-group-chat chat-id)
|
||||||
(set-chat-active chat-id false)
|
(set-chat-active chat-id false)
|
||||||
(left-chat-msg chat-id)
|
(left-chat-msg chat-id)
|
||||||
|
(delete-chat chat-id)
|
||||||
|
(dispatch [:navigate-back])
|
||||||
(signal-chat-updated db chat-id))))
|
(signal-chat-updated db chat-id))))
|
||||||
|
|
||||||
(register-handler :send-group-chat-msg
|
(register-handler :send-group-chat-msg
|
||||||
|
|
|
@ -186,3 +186,12 @@
|
||||||
(-> (r/get-by-field :chats :chat-id chat-id)
|
(-> (r/get-by-field :chats :chat-id chat-id)
|
||||||
(r/single)
|
(r/single)
|
||||||
(aset "is-active" active?)))))
|
(aset "is-active" active?)))))
|
||||||
|
|
||||||
|
(defn delete-chat [chat-id]
|
||||||
|
(r/write
|
||||||
|
(fn []
|
||||||
|
(-> (r/get-by-field :chats :chat-id chat-id)
|
||||||
|
(r/single)
|
||||||
|
(r/delete))))
|
||||||
|
;; TODO temp. Update chat in db atom
|
||||||
|
(dispatch [:initialize-chats]))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(ns syng-im.models.messages
|
(ns syng-im.models.messages
|
||||||
(:require [syng-im.persistence.realm :as r]
|
(:require [syng-im.persistence.realm :as r]
|
||||||
|
[re-frame.core :refer [dispatch]]
|
||||||
[cljs.reader :refer [read-string]]
|
[cljs.reader :refer [read-string]]
|
||||||
[syng-im.utils.random :refer [timestamp]]
|
[syng-im.utils.random :refer [timestamp]]
|
||||||
[syng-im.db :as db]
|
[syng-im.db :as db]
|
||||||
|
@ -41,8 +42,9 @@
|
||||||
:outgoing outgoing
|
:outgoing outgoing
|
||||||
:timestamp (timestamp)
|
:timestamp (timestamp)
|
||||||
:delivery-status nil
|
:delivery-status nil
|
||||||
:same-author same-author
|
;; TODO 'some?' is temp
|
||||||
:same-direction same-direction} true))))))
|
:same-author (some? same-author)
|
||||||
|
:same-direction (some? same-direction)} true))))))
|
||||||
|
|
||||||
(defn get-messages [chat-id]
|
(defn get-messages [chat-id]
|
||||||
(->> (-> (r/get-by-field :msgs :chat-id chat-id)
|
(->> (-> (r/get-by-field :msgs :chat-id chat-id)
|
||||||
|
@ -64,3 +66,10 @@
|
||||||
(fn []
|
(fn []
|
||||||
(when (r/exists? :msgs :msg-id msg-id)
|
(when (r/exists? :msgs :msg-id msg-id)
|
||||||
(r/create :msgs msg true)))))
|
(r/create :msgs msg true)))))
|
||||||
|
|
||||||
|
(defn clear-history [chat-id]
|
||||||
|
(r/write
|
||||||
|
(fn []
|
||||||
|
(r/delete (r/get-by-field :msgs :chat-id chat-id))))
|
||||||
|
;; TODO temp. Update chat in db atom
|
||||||
|
(dispatch [:initialize-chats]))
|
||||||
|
|
Loading…
Reference in New Issue