Commit Graph

70 Commits

Author SHA1 Message Date
Andrea Maria Piana 789271f179
[Fixes: #5124] Fix rtl flag
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-05-22 09:55:05 +02:00
yenda 1bf68094e3
add clj-kondo to linting phase
Signed-off-by: yenda <eric@status.im>
2020-05-07 10:40:30 +02:00
Andrea Maria Piana c2d129d04e
Fix mark as read for hidden messages
If a message is hidden and is not currently loaded, it will not be
marked as read, resulting in the count being always positive. To avoid this
we always mark it as read, and from the backend we return whether it has
been marked as read or was already seen.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-04-07 13:27:06 +02:00
Andrea Maria Piana 619e176087
Set waku mode dynamically
This commit allows setting waku-mode and waku-bloom-filter-mode
dynamically.
It requires a relogin for the changes to take effect.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-03-16 08:09:27 +01:00
Andrea Maria Piana 21ef5a68b8
Add mark all read
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-02-26 13:35:31 +01:00
Andrea Maria Piana a2af83f034
Add option to enable waku-mode
This commit adds an option to enable waku mode through ENV settings.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-02-17 18:22:50 +01:00
Andrea Maria Piana 4734a4ee04
offload chat messages
This commit does a few things:

1) Messages are offloaded from any chat once we go back from the home.
This allows us to ignore any message that is coming in from a chat we
are not currently focused.
2) After 5 seconds of not-scrolling activity, any received message that
is not currently visible will be offloaded to the database.
3) Similarly received messages that are not visible will be offloaded to
the database directly

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2020-02-14 15:56:28 +01:00
yenda 84828891a0
Add chat commands
Signed-off-by: yenda <eric@status.im>
2020-01-10 20:13:19 +01:00
Andrea Maria Piana 78d694f52f
Move message processing to status-go and introduce protobuf
This commit moves all the processing of messages to status-go.

Messages are going arrive to status-react already saved an processed.

Receiving/sending/retrieving from db is now using the same identical
structure. The only processing left in status-react is to mark the
messages as seen and update the unviewed count locally (only
status-react knows whether the count should be updated).

Partially remove commands as well as won't be used anymore.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-12-05 17:30:30 +01:00
Andrea Maria Piana 5fe385c225
Parse messages in status-go
This commit enables parsing of messages in status-go.
Currently only a few messages are supported in status-protocol-go.
For now we only enable Message types.
Status-react will conditionally use the parsed version if present.
Eventually this can be moved to a separate signal/different structure,
but for the time being is best to validate with the minimum amount of
changes.

The next step would be handle validation and processing of the field in
status-go, so we can skip saving the message from status-react.

This commit should improve performance of receiving messages from a
chat, although haven't had time to validate that.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-11-06 19:30:47 +01:00
Andrea Maria Piana c69863cda2
Fix message ordering and improve performance rec. messages
This commit does a few things:

==== Ordering of messages ====

Change the ordering of messages from a mixture of timestamp/clock-value to use
only clock-value.

Datemarks are now not used for sorting anymore, which means that the
order of messages is always causally related (not the case before, as we
were breaking this property by sorting by datemark), but datemark
calculation is unreliable (a reply to a message might have a timestamp <
then the message that is replied to).
So for timestamp calculation we
naively group them ignoring "out-of-order timestamp" messages, although
there's much to improve.
It fixes an issue whereby the user would change their time and the
message will be displayed in the past, although it is still possible to
craft a message with a lower clock value and order it in the past
(there's no way we can prevent this to some extent, but there are ways
to mitigate, but outside the scope of this PR).

==== Performance of receiving messages ====

The app would freeze on pulling messages from a mailserver (100 or so).
This is due to the JS Thread being hogged by CPU calculation, coupled
with the fact that we always tried to process messages all in one go.

This strategy can't scale, and given x is big enough (200,300,1000) the
UI will freeze.

Instead, each message is now processed separately, and we leave a gap
between processing each message for the UI to respond to user input
(otherwise the app freezes again).
Pulling messages will be longer overall, but the app will be usuable
while this happen (albeit it might slow down).
Other strategies are possible (calculate off-db and do a big swap,
avoiding many re-renders etc), but this is the reccommended strategy by
re-frame author (Solving the CPU Hog problem), so sounds like a safe
base point.

The underlying data structure for holding messages was also changed, we
used an immutable Red and Black Tree, same as a sorted map for clojure, but we use
a js library as is twice as performing then clojure sorted map.

We also don't sort messages again each time we receive them O(nlogn), but we
insert them in order O(logn).

Other data structures considered but discarded:
1) Plain vector, but performance prepending/insertion in the middle
(both O(n)) were not great, as not really suited for these operations.

2) Linked list, appealing as append/prepend is O(1), while insertion is
O(n). This is probably acceptable as messages tend to come in order
(from the db, so adding N messages is O(n)), or the network (most of
them prepends, or close to the head), while mailserver would not follow this path.
An implementation of a linked list was built, which performed roughtly the
same as a clojure sorted-map (although faster append/prepend), but not
worth the complexity of having our own implementation.

3) Clojure sorted-map, probably the most versatile, performance were
acceptable, but nowhere near the javascript implementation we decided on

4) Priority map, much slower than a sorted map (twice as slow)

5) Mutable sorted map, js implementation, (bintrees), not explored this very much, but from
just a quick benchmark, performance were much worse that clojure
immutable sorted map

Given that each message is now processed separately, saving the chat /
messages is also debounced to avoid spamming status-go with network
requests. This is a temporary measure for now until that's done directly
in status-go, without having to ping-pong with status-react.

Next steps performance wise is to move stuff to status-go, parsing of
transit, validation, which is heavy, at which point we can re-consider
performance and how to handle messages.

Fixes also an issue with the last message in the chat, we were using the
last message in the chat list, which might not necessarely be the last
message the chat has seen, in case messages were not loaded and a more
recent message is the database (say you fetch historical messages for
1-to-1 A, you don't have any messages in 1-to-1 chat B loaded, you receive an
historical message for chat B, it sets it as last message).

Also use clj beans instead of js->clj for type conversion

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-11-01 23:59:26 +01:00
Andrea Maria Piana 9cd891365a
Use payload & avoid transforming in clojure objects.
This commit includes a few performance fixes:
1) Pass a string payload instead of an hex encoded string, to avoid
unecessary conversion
2) Don't js->clj on messages, as that's fairly expensive and we can get
away without
3) Don't use `pr-str` `read-string`, rather convert to json

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-10-23 15:52:32 +02:00
Andrea Maria Piana dcb7415208
Move messages to status-go
This commit does a few things:

1) Move messages to status-go
2) Use message-id computed from status-go
3) Remove old replies

Old message id was used for compatibility of replies with older clients.
Given that v1 is breaking, this is not needed anymore and simplifies
moving messages to status-go. No protocol/data-store change is made, to minimize
changes.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2019-08-20 13:25:05 +02:00
yenda 04de022eae
[refactor] replace web3-prototype
- replace web3-prototype wherever possible
- currently only the money namespace is left
for future refactoring, the ideal solution
would be to use strings for big numbers all
the time and only convert for arithmetic operations
- use json-rpc call to replace trivial web3 calls

Signed-off-by: yenda <eric@status.im>
2019-06-06 15:57:34 +02:00
yenda 1ae42ea424
[perf] upgrade realm and improve schemas/queries
- upgrade to realm 2.28 to benefit from perf improvements
- remove user-statuses and replace by seen and outgoing-status fields
to get rid of a lot of bloat queries and computations
- remove unused seen message, bottom-infos
- remove unused fields in transport schema
- use objectForPrimaryKey whenever possible instead of get by field

Signed-off-by: yenda <eric@status.im>
2019-06-04 23:36:35 +02:00
yenda a1d6ead6d3
[perf] use objectForPrimaryKey instead of getByField
Signed-off-by: yenda <eric@status.im>
2019-06-03 16:36:51 +02:00
Roman Volosovskyi c7c7b50281
RAM bundle basic setup 2019-05-27 17:34:17 +03:00
yenda b80e02d8cf
[feature] add block user feature in user profile
- add block/unblock action to user profile
- blocking deletes all messages from user and ignores future messages
- unblocking stops ignoring new messages from user but doesn't recover past ones

[feature] add contact list

[tests] added scroll to BackupRecoveryPhraseButton

[tests] added scroll to public key

Signed-off-by: yenda <eric@status.im>
2019-02-05 16:29:56 +01:00
Andrea Maria Piana dfdbe1ccbc
Paginate using clock-value & message-id instead of skip/limit
Paginating using the count of loaded messages might result in some
messages being skipped and not being loaded in the database, in case of
out-of-order messages received.

This commit changes the behavior to sort by `clock-value` and
`message-id`, which gives a consistent sorting.

The initial idea was to use a cursor `clock-value-message-id` and
iterate on that, but realm does not support filtering on string (</>),
so instead we keep track of messages with identical clock-value and
exclude those in the next page query.

The change might result in pages that have duplicates (so messages needs
to be deduped), but won't result in skipped messages.
2018-12-24 18:12:50 +01:00
Roman Volosovskyi 8f48dc8df6
Safe deserialization of the last message's content
The issue was fixed in #7085 but reintroduced in #7055.
2018-12-24 18:09:59 +02:00
Roman Volosovskyi c440b7a3a7
[slow sign in] Denorlmalize last message
The last messages of the chats are necessary to properly show the chat
list, which is shown right after signing in. Before this commit, the
last message was retrieved as one of 20 last messages fetched for each
chat.

Implementation:
- `:last-message-content` and `:last-message-type` fields were added to
  `chat` entity
- both fields are updated when messages are received/sent
- loading of the last 20 messages for each chat was removed as
  initialization step
2018-12-17 13:29:10 +02:00
Andrea Maria Piana 54b9ba5a2e
Dont choke on wrongly serialized messages
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-12-14 16:59:34 +01:00
Roman Volosovskyi e7d0312d25
[#6903] fix replies compatibility
Issue was caused by https://github.com/status-im/status-react/pull/6722

Implementation:
1. `old-message-id` field (indexed) was introduced in `message` entity
   and is calculated as `message-id` was calculated in `0.9.31`
```clojure
(defn old-message-id
  [message]
  (sha3 (pr-str message)))
```
2. When a reply message is sent from the PR version of app both `response-to`
   and `response-to-v2` fields are sent as a part of `message`'s `content`
   field, so that it can be recognized by `0.9.31`.
3. When PR version of app receives reply from `0.9.31` we check whether
   message's `content` contains `response-to` but doesn't contain
   `response-to-v2`, and if so we check whether DB contains message with
   `old-message-id=response-to`. If such message has been found we assoc
   `response-to-v2` to content.
4. If message from DB contains only `response-to` but not `response-to-v2`
   attempt to fetch the message by `old-message-id` is done.
2018-12-05 07:22:40 +02:00
Roman Volosovskyi 5d5847e4b9
[slow sign in] Add unviewed messages counter to chat entity.
Before we fetched ALL user-statuses with `status=received` (which means that
a message hasn't been seen), iterated them, grouped by chat and then stored
`message-ids` of these `user-statuses` in chat's `:unviewed-messages` key.

This commit introduces :unviewed-messages-count field in chat entity.
That means that there is no need to iterate `user-statuses` in order to count
a total number of unviewed messages, it is always stored along with chat.
In the rest of it, the difference is only that chat's db record should be
updated each time when unviewed messages are seen.
2018-11-23 17:08:48 +02:00
Roman Volosovskyi d66198a420
[slow sign in]
fix iterating over all messages from realm db (was done for deduplication)
async loading of chats (:init-chats event)
2018-11-21 18:21:52 +02:00
Roman Volosovskyi 1dcc7727f1
[slow sign in] faster :get-referenced-messages 2018-11-21 10:50:45 +02:00
Roman Volosovskyi b792ab5cf3
[slow sign in] faster get-unviewed-messages 2018-11-21 08:04:33 +02:00
Eric Dvorsak f8f499d9b0
[refactor] rename whisper-id and whisper-identity to public-key 2018-11-09 11:16:27 +01:00
Andrea Maria Piana 7aa597517e
Add system messages to group chats
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-11-05 14:54:43 +01:00
janherich 76165cc7cb
[#6460] [#6438] Deduplication-ids 2018-10-24 09:43:52 +02:00
janherich 99d33ebbc9
Always load messages referenced in responses 2018-10-11 11:21:34 +02:00
janherich 44fbe62773
Chat replies + refactoring 2018-09-28 16:15:47 +02:00
Eric Dvorsak 6d84795b2a
[fix 5738] unread counter disappears after app restart
`get-unviewed-messages` cofx was using the `current-public-key`
field from app-db
since it is not set at the point cofx are computed during the init
phase this field is nil and therefore no unread messages were found

the fix changes the cofx so that it returns a function as it is
already done for many cofx that needs parameters that are not
known at the time cofx are computed.

Signed-off-by: Igor Mandrigin <i@mandrigin.ru>
2018-09-04 14:08:11 +02:00
Andrea Maria Piana b34744133b
[fixes #4745] Don't query mailserver on restored account
When creating a new account / recovery we don't poll the mailserver anymore for historic messages, which solves the immediate issue of fetching only received messages

Handle messages sent from a different device in public chat / restore history. The message will be added, shown correctly as sent by the user, and the status will be set as sent ( need to check for seen race condition, as messages will now be added twice). This means that multidevice should now work for public chats.

Move contact updates to discovery topic. This is necessary as there is a pre-existing bug whereby contact updates would not work anymore after wallet recovery, as the code relies on the initial contact request being stored on the mailserver, which we cannot guarantee (we only pull 7 days of data). Not pulling history anymore exacerbate the problems but does not introduce it.
To make sure that contact updates will work after wallet recovery, we also need to consider a ContactUpdate in the same way we consider a ContactRequest (the other peer has no idea that the user has recovered the wallet). This does not change any behaviour in terms of obscurity/security as ContactRequest are automatically processed (in both case the contact will be set as pending?, not as accepted)
At this stage ContactRequest, ContactRequestConfirmed, ContactUpdate have all the same logic, i.e. update the contact information, leave the pending flag alone.

Only 1 day of history is fetched for newly joined chats, if catching up 7 days is the cap as before.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-07-03 17:21:59 +02:00
Pedro Pombeiro 227014674c
Add 6 new languages as public channels in the localized language. Closes #4753 2018-06-20 19:11:56 +03:00
janherich 4ba78de407
Faster seen marking
Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
2018-06-11 12:16:42 +02:00
janherich cd5542f648
Persist unseen messages 2018-06-05 15:24:55 +02:00
janherich 62a9f26e30
First stage of realm transactions 2018-05-10 17:21:23 +02:00
Roman Volosovskyi 6c620728da
reformat status-im.data-store.* namespaces
reformat status-im.utils.* namespaces
2018-05-08 09:01:24 +03:00
Dmitry Novotochinov a8a03067a1
Add resend and delete message actions
* Set message status based on signal from Go
* Set status as "not-sent" on app start if no signal received

Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
2018-04-27 11:03:42 +03:00
Andrea Maria Piana 3256d67c2e
Add clock values for public group/chats
I have extended and modified the current algorithm for message ordering
so that it applies for group and public chats alike.

We use Lamport timestamps but we prefix the unix timestamp, which should
maximize the chances of the message being seen on the top of the chat.

Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-04-10 12:19:42 +01:00
Eric Dvorsak df17c50612
Add new protocol
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-04-05 15:40:30 +01:00
Itoh, Masaru 98a0c2081f
Refactor timestamp
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
2018-03-15 11:53:23 +00:00
janherich 80fb8dde8b
Read at startup & write through async queues 2018-02-05 12:28:08 +01:00
Foo Pang ae04dde8ba
[Fix #3076] Separate figwheel from dev lein profile
Signed-off-by: Dmitry Novotochinov <trybeee@gmail.com>
2018-02-02 17:02:45 +03:00
janherich 201484f37f
Faster msg status updates 2018-01-09 15:00:06 +01:00
janherich 52ddccca96
Refactored statuses 2018-01-04 13:49:21 +01:00
alwx a813ff9e9f Chat refactoring: updated console (former sign-up) namespace 2017-12-25 22:16:01 +03:00
janherich eb8d0a8a79
Refactored message data-model and view 2017-12-19 12:50:36 +01:00
Eric Dvorsak df83cbb987 update realm version 2017-11-04 11:00:14 +01:00