handle multiple incoming messages at once - #4260
Conversation
03049a8 to
b1eaf12
Compare
| ;; regular non command message, we can add it right away | ||
| (message-model/receive message cofx))))) | ||
| (fn [cofx args] | ||
| (if (vector (first args)) |
There was a problem hiding this comment.
did you mean vector? here? Also mind that (vector? '()) -> false so maybe is best to check for the opposite (is it a hash map?), as we might at some point do some processing.
We can probably just wrap and always call add if it's a single message, but adds a bit of overhead for single messages, but clearer code paths.
There was a problem hiding this comment.
yep i mean vector? for sure, typo, thanks
|
@rasom If I understand the code correctly, the |
|
yes sure @janherich, idea was to check difference asap |
though this is not going to be included into this PR for sure |
| (let [temp-cofx (handlers-macro/update-db cofx fx)] | ||
| (handlers-macro/safe-merge | ||
| fx | ||
| (add-one-message [message] temp-cofx)))) |
There was a problem hiding this comment.
We can't just reduce effects produced by add-one-message:
What if there are multiple command type messages in the batch and all needs their preview to be rendered?
What if the messages are for currently opened chat and we need to produce protocol seen messages for all of them ?
What about adding request objects to realm (currently, there is no plural effect for that, till my realm-transactions-2 PR is merged).
Thats why I think we need to tackle this differently.
There was a problem hiding this comment.
What if there are multiple command type messages in the batch and all needs their preview to be rendered?
we can always "accumulate" these preview requests here, not a big deal
What if the messages are for currently opened chat and we need to produce protocol seen messages for all of them ?
same answer, if we need to call some fx it can be batched as well
What about updating adding request objects to realm (currently, there is no plural effect for that, till my realm-transactions-2 PR is merged).
so we will merge it, anyway
There was a problem hiding this comment.
What if the messages are for currently opened chat and we need to produce protocol seen messages for all of them ?
tbh i even doubt that this makes sense in case if user opened public group after starting app and then received like 100 messages from mailserver or so. Why these messages should be marked as seen? That doesn't make sense, the fact that chat was opened doesn't mean that messages were seen. I believe this should be handled completely differently considering UX pov.
There was a problem hiding this comment.
@rasom We don't even have send confirmations for public chats anymore (@cammellos removed them recently). But the same situation can happen in 1-1 chat (going online after longer time and receiving bunch of messages from offline inboxing) and there, it makes perfect sense to send just one seen protocol message with N confirmations, instead of N protocol messages (whisper envelopes are expensive).
Regarding if it makes sense to mark messages as seen upon opening the chat, I don't know how to otherwise detect it, as the condition that chat is opened and new message arrived is synonymous with rendering the message in messages list. The only alternative I see is having some explicit confirmation or much more aggressive lazy rendering when only what's in the content of the screen is really rendered (and hooking seen confirmation into that).
There was a problem hiding this comment.
one seen protocol message with N confirmations
if you actually seen them and not just received. But we can't know this when handling message.
as the condition that chat is opened and new message arrived is synonymous with rendering the message in messages list
That's what we will change soon as well. There is no need to render all incoming messages.
There was a problem hiding this comment.
if you actually seen them and not just received. But we can't know this when handling message.
Sure you can - any good design should be data first. Currently we know that because of the :current-chat-id in db and :chat-id of the message, in the future, with lazy rendering (the change you are talking about), what's rendered will be determined by some range like :rendered-messages [from to] and you will now if the new message is destined for the currently opened chat and will be included in rendered range.
There was a problem hiding this comment.
and also we need to take into account how long is message, how big is screen and is keyboard shown or not. I still doubt that this makes sense on handling, though it's doable, I agree :D
|
@rasom I thought that this is "normal" PR which is to be merged into develop, not experiment only. Sorry for the confusion. |
|
Nope it is normal PR which is going to be merged. Though perfect design is not objective as well, objective is performance. |
Also @janherich just to understand correctly, you are saying that at the moment message preview will not work if multiple messages needs a preview? If both are true, it seems to me easier to do as janerich proposed, changing the signature of |
|
tbh i'm not sure that i really get how moving this stuff to So my point is pretty simple, if we can quickly find the way to batch effects produced by
this can be done as a separate PR, anyway impact on performance is pretty small because we are not using commands that heavily, main objective are regular messages anyway |
|
@rasom I think the point is rewriting the |
as i said, this is only about moving of place where effects produced by
for now 2-3 days is a big effort and big amount of time, considering that i have other ideas for improvements on which i would like to work and release should happen soon. So as i said, i will make sure that all effects produced by |
|
oh wow, i'm taking my words back, i'm not going to touch |
|
How we handle incoming message in 1:1 and pub chats in develop is:
So as objective here are pub groups and 1-1 messages what we need to ensure is that dispatching of So that's literally it, what is planned to be done by this PR. I don't see why refactoring of the way how we send requests to jail should be included to the scope, as well why rewriting of |
|
|
||
| (re-frame/reg-fx | ||
| :shh/add-new-sym-keys | ||
| (fn [keys] |
There was a problem hiding this comment.
Is this working ? Isn't it suppose to receive a map as parameter ? and add-new-sym-key as well ?
There was a problem hiding this comment.
Here in PR it receives vector always. add-new-sym-key receives map. Basically messaging is working in this PR, so i believe it's not broken.
There was a problem hiding this comment.
it is broken but we use public key for messages. try updating a contact
There was a problem hiding this comment.
maybe it is not broken but it must be renamed args because keys is just plain wrong this is not keys
| (message-model/receive message cofx))))) | ||
| (fn [cofx args] | ||
| (if (vector? (first args)) | ||
| (add args cofx) |
There was a problem hiding this comment.
i don't get what you mean by this
| (fn [cofx args] | ||
| (if (vector? (first args)) | ||
| (add args cofx) | ||
| (add-one-message args cofx)))) |
There was a problem hiding this comment.
both names are too un-conventionnal, add-message and add-messages has clearer intent
| (message/receive status-message (or chat-id sig) sig cofx)))) | ||
|
|
||
| (defn receive-whisper-message [{:keys [db] :as cofx} [js-error js-message chat-id]] | ||
| (reduce (fn [fx message] |
There was a problem hiding this comment.
docstring explaining that a whisper message can contain a vector of messages or a single message
There was a problem hiding this comment.
i will make sure that whisper message will always be a single now, at least if you are speaking about message parameter, that's always single message. No need for doc exactly here
There was a problem hiding this comment.
maybe my comment should be one line above, I mean that js-message is a vector of message. is it always the case ?
There was a problem hiding this comment.
yes, i will rename it to js messages
19a9d13 to
98b54a4
Compare
| (handlers-macro/merge-fx cofx | ||
| {:shh/get-new-sym-key {:web3 (:web3 db) | ||
| :on-success on-success}} | ||
| {:shh/get-new-sym-key [{:web3 (:web3 db) |
There was a problem hiding this comment.
because i forget to rename it
| :on-error log-error}))) | ||
| :shh/add-new-sym-keys | ||
| (fn [args] | ||
| (doseq [key args] |
There was a problem hiding this comment.
this is still args. first it's a list of maps of args and then a map of args that is passed to add-new-sym-key, still not a key
There was a problem hiding this comment.
eh man, so how would you like to rename args and key here?
There was a problem hiding this comment.
I can't think of a good name for both :(
key -> add-new-sym-key-params
would be a good start to remove possible confusion
98b54a4 to
b27bd2b
Compare
7e1731e to
602220b
Compare
|
apk uploaded to https://i.diawi.com/3TYhTw for branch PR-4260 |
|
ipa uploaded to https://i.diawi.com/SaZwT2 for branch PR-4260 |
93% of end-end tests have passedFailed tests (1)Click to expand
Passed tests (14)Click to expand
|
087a567 to
9b5058d
Compare
|
apk uploaded to https://i.diawi.com/Hhs8aN for branch PR-4260 |
|
ipa uploaded to https://i.diawi.com/PmXBLP for branch PR-4260 |
Idea of this PR #4260 is to make changes to web3 so that all messages received from go-ethereum side as a batch are sent to client all together, instead of separate event for each. status-im/web3.js@47318ea#diff-2ccb13c15898607b8166dd84c582b56dL124
Thus all these messages are handled together in react app.
I run the next test:
for develop results are
02:00,41 (minutes:seconds)
02:24,03
02:09,71
for experiment
00:54,76
00:35,02
01:01,17
Though for 100 messages results are less noticeable:
Old
00:12,53
00:08,01
00:17,24
New
00:10,02
00:04,58
00:15,54
status: ready