Skip to content

Commit

Permalink
wip 2
Browse files Browse the repository at this point in the history
  • Loading branch information
cammellos committed Jun 10, 2019
1 parent f0a2999 commit aa065a1
Show file tree
Hide file tree
Showing 28 changed files with 861 additions and 584 deletions.
2 changes: 1 addition & 1 deletion STATUS_GO_SHA256
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh <tag>` instead

0kxiw130lf4yf9kk0zcs60k58ycd88khwqy1wqvlskj0yqsbmy8k
0z7my6abmfl82vr9f5cr888nv7wm2kkwqrg9dmb3sj4khzxaw5wc
2 changes: 1 addition & 1 deletion STATUS_GO_VERSION
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## DO NOT EDIT THIS FILE BY HAND. USE `scripts/update-status-go.sh <tag>` instead

v0.26.0-alpha.38
v0.26.0-alpha.43
Original file line number Diff line number Diff line change
Expand Up @@ -1133,64 +1133,4 @@ Map<String, Object> getConstants() {
public void isDeviceRooted(final Callback callback) {
callback.invoke(rootedDevice);
}

@ReactMethod
public void loadFilters(final String chats, final Callback callback) {
Log.d(TAG, "loadFilters");
if (!checkAvailability()) {
callback.invoke(false);
return;
}

Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.loadFilters(chats);

callback.invoke(res);
}
};

StatusThreadPoolExecutor.getInstance().execute(r);
}

@ReactMethod
public void loadFilter(final String chat, final Callback callback) {
Log.d(TAG, "loadFilter");
if (!checkAvailability()) {
callback.invoke(false);
return;
}

Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.loadFilter(chat);

callback.invoke(res);
}
};

StatusThreadPoolExecutor.getInstance().execute(r);
}

@ReactMethod
public void removeFilter(final String chat, final Callback callback) {
Log.d(TAG, "removeFilter");
if (!checkAvailability()) {
callback.invoke(false);
return;
}

Runnable r = new Runnable() {
@Override
public void run() {
String res = Statusgo.removeFilter(chat);

callback.invoke(res);
}
};

StatusThreadPoolExecutor.getInstance().execute(r);
}
}
12 changes: 2 additions & 10 deletions src/status_im/chat/db.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[status-im.chat.commands.input :as commands.input]
[status-im.contact.db :as contact.db]
[status-im.group-chats.db :as group-chats.db]
[status-im.mailserver.core :as mailserver]
[status-im.mailserver.constants :as mailserver.constants]
[status-im.transport.partitioned-topic :as topic]
[status-im.utils.gfycat.core :as gfycat]))

Expand Down Expand Up @@ -53,14 +53,6 @@
{}
chats))

(defn topic-by-current-chat
[{:keys [current-chat-id chats] :as db}]
(let [{:keys [public?]} (get chats current-chat-id)
public-key (get-in db [:account/account :public-key])]
(if public?
(get-in db [:transport/chats current-chat-id :topic])
(topic/public-key->discovery-topic-hash public-key))))

(defn sort-message-groups
"Sorts message groups according to timestamp of first message in group"
[message-groups messages]
Expand Down Expand Up @@ -164,7 +156,7 @@
(not (nil? highest-request-to))
(not (nil? lowest-request-from))
(< (- highest-request-to lowest-request-from)
mailserver/max-gaps-range))
mailserver.constants/max-gaps-range))
(update acc :messages conj {:type :gap
:value (str :first-gap)
:first-gap? true})
Expand Down
19 changes: 8 additions & 11 deletions src/status_im/chat/models.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
[status-im.data-store.messages :as messages-store]
[status-im.i18n :as i18n]
[status-im.mailserver.core :as mailserver]
[status-im.transport.chat.core :as transport.chat]
[status-im.transport.message.public-chat :as public-chat]
[status-im.transport.message.protocol :as transport.protocol]
[status-im.tribute-to-talk.core :as tribute-to-talk]
[status-im.ui.components.colors :as colors]
[status-im.ui.components.desktop.events :as desktop.events]
Expand Down Expand Up @@ -169,16 +168,12 @@
(log/error "can't remove a chat:" error))}]}
(navigation/navigate-to-cofx :home {}))
(fx/merge cofx
#(when (public-chat? % chat-id)
(mailserver/remove-chat-from-mailserver-topic % chat-id))
(mailserver/remove-gaps chat-id)
(mailserver/remove-gaps chat-id)
(mailserver/remove-range chat-id)
(deactivate-chat chat-id)
(clear-history chat-id)
#(when (one-to-one-chat? % chat-id)
(contact-code/stop-listening % chat-id))
#(when (public-chat? % chat-id)
(transport.chat/unsubscribe-from-chat % chat-id))
(contact-code/stop-listening chat-id)
(transport.protocol/remove-chat chat-id)
(navigation/navigate-to-cofx :home {}))))

(defn- unread-messages-number [chats]
Expand Down Expand Up @@ -243,7 +238,8 @@
(fx/merge cofx
{:db (-> (assoc db :current-chat-id chat-id)
(set-chat-ui-props {:validation-messages nil}))}
(contact-code/listen-to-chat chat-id)
(when-not (group-chat? cofx chat-id)
(contact-code/load-chat chat-id))
(when platform/desktop?
(mark-messages-seen chat-id))
(tribute-to-talk/check-tribute chat-id)))
Expand Down Expand Up @@ -287,6 +283,7 @@
(fx/merge cofx
(upsert-chat {:chat-id chat-id
:is-active true})
(contact-code/load-chat chat-id)
(navigate-to-chat chat-id opts)))))

(fx/defn start-public-chat
Expand All @@ -297,9 +294,9 @@
(navigate-to-chat cofx topic opts))
(fx/merge cofx
(add-public-chat topic)
(contact-code/load-chat topic)
#(when-not dont-navigate?
(navigate-to-chat % topic opts))
(public-chat/join-public-chat topic)
#(when platform/desktop?
(desktop.events/change-tab % :home)))))

Expand Down
7 changes: 1 addition & 6 deletions src/status_im/contact/core.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
{:db (-> db
(update-in [:contacts/contacts public-key] merge contact))
:data-store/tx [(contacts-store/save-contact-tx contact)]}
#(when (contact.db/added? contact)
(contact-code/listen-to-chat % public-key))))
(contact-code/load-contact contact)))

(fx/defn send-contact-request
[{:keys [db] :as cofx} {:keys [public-key] :as contact}]
Expand All @@ -70,10 +69,6 @@
(fx/merge cofx
{:db (assoc-in db [:contacts/new-identity] "")}
(upsert-contact contact)
(mailserver/upsert-mailserver-topic
{:chat-ids [public-key]
:topic (transport.topic/discovery-topic-hash)
:fetch? false})
(whitelist/add-to-whitelist public-key)
(send-contact-request contact)
(mailserver/process-next-messages-request)))))
Expand Down
Loading

0 comments on commit aa065a1

Please sign in to comment.