chat: fix broken chat delete logic (#1343)

* chat: fix broken chat delete logic

Previously, persisting the chat delete functionality was working
only for group chats, where the `debug?` flag decided if delete was
a real "hard" delete (deleting data from the realm database) or just
marking with the `inactive` flag.

However non-group chats were not deleted at all, which I believe is a
bug fixed by this commit.

* chat: fix broken chat delete logic

Fix the branching logic with `if` instead of `when`
This commit is contained in:
Jan Herich 2017-06-26 19:41:58 +02:00 committed by Roman Volosovskyi
parent fc7cc1d795
commit fa8fe11bd7
1 changed files with 3 additions and 4 deletions

View File

@ -392,10 +392,9 @@
(defn delete-chat!
[_ [_ chat-id]]
(let [{:keys [debug? group-chat]} (chats/get-by-id chat-id)]
(when group-chat
(if debug?
(chats/delete chat-id)
(chats/set-inactive chat-id)))))
(if (and (not debug?) group-chat)
(chats/set-inactive chat-id)
(chats/delete chat-id))))
(defn remove-pending-messages!
[_ [_ chat-id]]