Commit Graph

742 Commits

Author SHA1 Message Date
Eric Mastro 86e69132c6 feat: add error handling to mark messages as seen logic 2021-04-20 14:44:27 -04:00
Pascal Precht aeedc87368 feat: introduce global settings
This commit introces global settings that apply across accounts used
inside the application. This is useful when settings like the selected
locale should b the same across all accounts.

Closes #2144
2021-04-19 13:53:14 +02:00
Eric Mastro e47092cfd0 feat: settings cache efficiency update
Current settings caching logic was inefficient when attempting to retrieve settings that contain the sensitive mnemonic. While those calls were limited to the login logic, each call would need to round trip to status-go to get all settings when they wanted to include sensitive data, as the cache was not being updated for these calls.

This PR updates the cache regardless if sensitive data is requested of not, effectively making the caching mechanism more efficient during login.
2021-04-15 17:02:28 -04:00
Eric Mastro 0a108dd849 feat: Add libstatus contacts caching
Fixes #2131.

After some heavy profiling, it became clear that sending of each message was causing a fetch to get all contacts from status-go. This was incurring a minimum of a 0.03s delay for each fetch, which was causing a bottleneck each time it was called for various operations throughout the codebase.

This code addds a layer of threadsafe caching to the contacts call, such that only the first call to contacts fetching will incur the delay, as well as every fetch after a contacts CUD operation.
2021-04-15 17:02:08 -04:00
Eric Mastro e7571bd2a4 feat: Add Methuselah and Mailserver long-running task
Fixes #2143.

Methuselah is the a task manager for long-running tasks. It allows fo registration of workers that will each run in their own thead. Each worker can pass messages to and recieve messages from the main thread.

MailserverWoker was also introduced which moves all mailserver model logic to a MethuselahWorker. All communication to/from the model is done via a MethuselahTask. Results of the task are returned to the main thread by way of `signal_handler`, which calls the QtObject slot specified in the task.

Mailsever also provides a way for the model to emit events inside of the worker. These events are forwarded to the main thread via the `receiveEvent` slot of the `MailserverController`.

Co-authored-by: Michael Bradley, Jr <michaelsbradleyjr@gmail.com>
2021-04-14 15:37:05 -04:00
Eric Mastro 0d677eb156 chore: change threadpool logs from debug to trace 2021-04-14 15:36:36 -04:00
Jonathan Rainville 1983fa79aa feat: improve ens search in wallet send by showing the result 2021-04-14 14:39:11 -04:00
Jonathan Rainville 438517a610 fix: fix missing channel identifier in new community chats
Fixes #2211
2021-04-14 12:33:45 -04:00
Jonathan Rainville ba500e5f73 fix: fix notifications not working for community chats
Fixes #2210
2021-04-14 12:33:45 -04:00
Pascal Precht 46fd32aaee feat: add SOCKS token to list of default tokens
Closes #2215
2021-04-14 10:46:49 +02:00
Jonathan Rainville 63b5c549b9 fix: fix invite button not setting Joined correctly
Fixes #2209
2021-04-13 17:50:32 -04:00
Pascal Precht 5ca9d66212 fix(Communities): ensure newly created community is opened 2021-04-13 15:21:00 -04:00
Richard Ramos 8543bf04d4 fix: code review 2021-04-06 14:31:06 -04:00
Richard Ramos 61555d610b fix: it's not necessary to leave chats 2021-04-06 14:31:06 -04:00
Richard Ramos 55ecb50f1b chore: autoremove chat groups 2021-04-06 14:31:06 -04:00
Richard Ramos 31f85787a6 fix: decline chat group invites if admin is not a contact 2021-04-05 12:02:05 -04:00
Richard Ramos 52b18c0c82 fix: leave chat groups 2021-04-05 12:01:45 -04:00
Eric Mastro 40dc428f63 fix: ens search hang
ENS search was executed in a task runner task. The task had a mistake during the copy/paste port from spawnAndSend.
2021-04-01 17:16:54 -04:00
Jonathan Rainville a01e851070 fix: fix being unable to put multiple spaces in a row 2021-04-01 17:07:25 -04:00
Jonathan Rainville 8b3ce83d00 fix: input box disappearing on communities
Fixes #2155
2021-03-31 16:53:08 -04:00
Jonathan Rainville 996b36714d fix: fix scroll speed on Windows 2021-03-30 16:02:10 -04:00
Jonathan Rainville a337b293da feat: show community context menu on Community button 2021-03-30 15:53:32 -04:00
Jonathan Rainville 147d93815f fix: fix unable to write to invite only community channels
This was caused by the fact that the canPost property was not exposed from the ChatItem model.
I'm actually not sure why it didn't show an error trying to call  a function that doesn't exist
2021-03-25 16:38:05 -04:00
Eric Mastro 2336aa4e6f fix: custom token validation for non-token addresses
When contract addresses that are not ERC-20 or ERC-721 were input, the token would be allowed to be added and would crash the app.

In addition, when an ERC-20 contract was deployed without a name and symbol, “Invalid ERC-20 address” would appear.

This PR adds error checking from the token detail lookup and reports the error back to the user in the modal. This prevents non-ERC-20/721 contracts from being able to be added to the app and prevents a crash.
2021-03-25 15:52:02 -04:00
Pascal Precht bb932ac35e fix(Timeline): remove "fetch more" fake message
Two fake messages are usually added to chat message lists inside a channel or
chat:

- One that imitates a chat identifier
- one that creates a button to fetch older messages

These two fake messages are added so it's ensured they show up at the beginning
of the chat.

The status timeline is also just a list of messages (filtered by a certain message
type), however there's no need to render these fake messages in this scenario.
That's why a `addFakeMessages` flag has been introduced which conditionally adds
those fake messages here: https://github.com/status-im/status-desktop/commit/3f012dbf0#diff-6aa545137319516beb03623bc6a9750e1d14a40c68d8868b5a672320fc4d680aR69

At some point, possibly around here (https://github.com/status-im/status-desktop/commit/8ee5abe57), the fake message for
the fetch more button has been reintroduced as default fake message.

This commit puts it back into the function so that it doesn't show up
inside the timeline view.
2021-03-24 14:41:43 -04:00
Michael Bradley, Jr 1200632989 feat: remove all remaining spawnAndSends
refactor: move threadpool task declarations inline with views

Co-authored-by: Michael Bradley Jr. <michaelsbradleyjr@gmail.com>
Co-authored-by: Eric Mastro <eric.mastro@gmail.com>
2021-03-24 14:30:33 -04:00
Jonathan Rainville 7188579e46 fix: fix mention showing as pubkey and show styling 2021-03-24 14:16:55 -04:00
Jonathan Rainville 5d67a3f5f9 fix: fix sending three word names mentions not working 2021-03-24 14:16:55 -04:00
Jonathan Rainville 2a9f9118a1 fix: fix settings not being refetched when they had been edited before 2021-03-24 12:06:24 -05:00
Pascal Precht 20d0d162b5 fix(Contacts): ensure app doesn't crash when contact can't be resolved
There was a bug introduced https://github.com/status-im/status-desktop/commit/2ac67f95a where we'd rely on the
possibly resolved public key, which is passed to `generateAlias()`.

The public key is never guaranteed to be an actual key (if resolution fails,
it's a an empty string). Passing an empty string to `generateAlias()` causes
`status-go` to crash and we don't handle that error.

This commit ensures that we only attempt to generate an alias when we
indeed have a successfully resolved public key.
2021-03-22 15:49:38 -04:00
Eric Mastro b7124372e9 feat: stickers spawnAndSend to threadpool task
Move the remaining stickers spawnAndSend (obtainAvailableStickerPacks) into a threadpool task.

refactor: create a base class for tasks models to inherit from

NOTE: this branch is based off of `experiment/tasks-3` and should be rebased on master once that branch is merged.
2021-03-19 15:38:50 -04:00
Eric Mastro 66912fd811 feat: introduce Task Manager threadpool
The `TaskManager` threadpool is a memory-safe replacement for the `spawnAndSend` operations that are currently causing memory issues in status-desktop.

From a fundamental memory management point of view, `libstatus/settings`, `libstatus/contracts`, and `libstatus/tokens` (custom tokens) have all been converted to `{.threadvar.}`s and `Atomic[bool]`s to maintain the cache and `dirty` flag across threads, respectively, eliminating the need for thread locks and incorrect `{.gcsafe.}` compiler overrides.

The successful [recyclable threadpool experiment from `nim-task-runner`](https://github.com/status-im/nim-task-runner/blob/test/use-cases/test/use_cases/test_sync.nim) using `AsyncChannel[ThreadSafeString]`s was brought over to `status-desktop` and implemented in somewhat of a hardcoded manner, as we knew this would save some time instead of trying to create a fully fleshed out `nim-task-runner` API and build a miraculous macro that may or may not be able to generate the needed API.

The threadpool is started by the `TaskManager` and both the `TaskManager` and the `TaskManager`'s threadpool are started as early as possible in the application lifecycle (in `nim_status_client.nim`). The `TaskManager` creates a thread to run the threadpool. During its initialization, the threadpool then spools up all the threads it will manage and puts them in an idle thread sequence. This is to prevent expensive thread creation and teardown happening during the app's lifetime as it is quite expensive and blocks the main thread. When tasks comes in to the pool, the task is sent to an idle thread, or put in a queue if all threads are busy. The idle thread is moved to the busy thread sequence. When a task is completed, the thread is taken out of the busy threads sequence and moved back in to the sequence of idle threads, effectively recycling it.

The first `spawnAndSend` we were able to change over to the new threadpool was `estimate`, which estimates the gas of a sticker purchase transaction.

From the consumer point of view, the existing `spawnAndSend` to achieve this looks like:
```nim
  proc estimate*(self: StickersView, packId: int, address: string, price: string, uuid: string) {.slot.} =
    let status_stickers = self.status.stickers
    spawnAndSend(self, "setGasEstimate") do:
      var success: bool
      var estimate = status_stickers.estimateGas(packId, address, price, success)
      if not success:
        estimate = 325000
      let result: tuple[estimate: int, uuid: string] = (estimate, uuid)
      Json.encode(result)
```
And the new syntax looks like this:
```nim
  proc estimate*(self: StickersView, packId: int, address: string, price: string, uuid: string) {.slot.} =
    self.status.taskManager.threadPool.stickers.stickerPackPurchaseGasEstimate(cast[pointer](self.vptr), "setGasEstimate", packId, address, price, uuid)
```
The logic inside the `spawnAndSend` body was moved to [src/status/tasks/stickers.nim](https://github.com/status-im/status-desktop/compare/experiment/tasks-3?expand=1#diff-09e57eef00b0cee5c4abdb9039f948d8372e7003e09e934a9b4c7e9167d47658).

This is just the first migration of `spawnAndSend`, however moving the majority of the remaining `spawnAndSend`s will likely just be an exercise in copy/pasta. There will be one or two that may require a bit more thinking, depending how they rely on data from the model.

Once the `spawnAndSend`s have been converted to the threadpool, we can start implementing the [long-running process from the task runner use case experiments](https://github.com/status-im/nim-task-runner/blob/test/use-cases/test/use_cases/test_long_running.nim).

And finally, we can then implement the [async tasks](https://github.com/status-im/nim-task-runner/blob/test/use-cases/test/use_cases/test_async.nim) if needed.

@michaelsbradleyjr and I spent many hours digging in to the depths of nim's memory management in an attempt to understand it. We have created [a presentation with our task runner experiment findings](https://docs.google.com/presentation/d/1ItCxAfsVTcIoH_E4bgvmHljhbU-tC3T6K2A6ahwAedk/edit?usp=sharing), and @michaelsbradleyjr has spent time [answering questions off the back of that presentation.](https://gist.github.com/michaelsbradleyjr/1eaa9937b3fbb4ffff3fb814f0dd82a9).

We have created a fork of `edn.nim` at `status-im/edn.nim` and we need the PR to be merged and the commit hash updated before we can merge this PR in to `status-desktop`.
2021-03-18 13:15:05 -04:00
Jonathan Rainville 62d10eba49 feat: show community invite component on community link 2021-03-17 16:09:23 -04:00
Jonathan Rainville 5581fca41d feat: show default unfurling for community links 2021-03-17 16:09:23 -04:00
Pascal Precht 9faf349b83 fix(libstatus): add safety check before accessing API response
We've introduced a regression in https://github.com/status-im/status-desktop/commit/f1e83f74b#diff-f35edd413addd14c1f81816d6b5ee2bcbdf85fa0e3295d324cb78c98e26d4327L364 where we check whether an RPC's `error` is `null`
and its `result` is not `null`.

This breaks the application with an illegal storage access,
 as in case of a successful API call, the response will have only a `result` key
 (even when it's `null`).

Since we haven't done anything with a possible `error` in the reponse even before
that change was made, this commit removes the `error` check and safe guards around
whether `result` exists.

Fixes #2062
2021-03-17 12:13:59 +01:00
Michael Bradley, Jr 016dd3081b refactor: nim_status -> status_go
Also, `status_go.startWallet` proc should be called with a boolean argument.
2021-03-16 16:37:27 -04:00
Richard Ramos 4f4a3f1c30 feat: see stickers details when clicking on a sticker 2021-03-16 15:39:52 -04:00
Eric Mastro f1e83f74bc feat: drag and drop images
Allow up to 5 images to be dragged and dropped in to one-on-one chats and in the timeline. Can be combined with the existing upload button. The upload file dialog has been changed to allow multiple selections. Drag and dropped images adhere to the following rules, with corresponding validations messages:
- Max 5 image
- Image size must be 0.5 MB or less
- File extension must be one of [".png", ".jpg", ".jpeg", ".heif", "tif", ".tiff"]

Drag and drop and uploaded images are now also deduplicated.
2021-03-16 13:51:37 -04:00
Jonathan Rainville 7bb8a968c9 fix: fixes the ordering problem on deleting a channel
Fixes #2035
Also goes back to your first channel when deleting the current channel
2021-03-15 14:10:14 -04:00
Richard Ramos 3c024db15e fix: marking a mailserver as trusted is not necessary as this is done by status-go already 2021-03-11 10:35:31 -05:00
Pascal Precht 99dfd7b13a fix(Communities): ensure importCommunity API returns response
Prior to this commit we were ignoring the returned response of the
API call, making it impossible to work with it in case it's needed.
2021-03-11 10:00:05 -05:00
Pascal Precht 01d3369c64 fix(Communities): fallback to letter identicon if no image available
Prior to this commit, communities without an image would render invisible
in the navigation bar of the application. To avoid this, we're now falling
back to our StatusLetterIdenticon component, which renders the first letter
of the community name with the color of the community.
2021-03-11 10:00:05 -05:00
Jonathan Rainville 131685ecf5 fix: fix member popup layout and member not showing
Fixes #1949
2021-03-05 13:57:49 -05:00
Jonathan Rainville 5300dcac28 fix: fix getChannelById crashing on timeline call
Fixes #1987
2021-03-05 12:21:06 -05:00
Jonathan Rainville e94cfaec74 fix: fix member count not updating when inviting
Fixes #1949
2021-03-03 16:45:23 -05:00
Jonathan Rainville d1c6c0f9a9 fix: fix adding a second channel to a community disapearing
Fixes #1953
2021-03-03 16:45:23 -05:00
Jonathan Rainville 2f8d46fa76 fix: fix community channel color undefined issue 2021-03-03 16:45:23 -05:00
Jonathan Rainville e806ef9ff9 fix: fix clear chat and mute/unmute chat for communities 2021-03-03 16:45:23 -05:00
Jonathan Rainville 84034d5dbf fix: fix channel color in communities 2021-03-03 16:45:23 -05:00
Jonathan Rainville b33a7b8fcf fix: fix right clicking a channel in community
Fixes #1950
2021-03-03 16:45:23 -05:00