Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: NewClient dialog flow (WPD-284) #1785

Merged
merged 24 commits into from
Jun 19, 2023
Merged

Conversation

borichellow
Copy link
Contributor

@borichellow borichellow commented Jun 7, 2023

What's new in this PR?

Issues

A "this account was used on ..." dialog is shown in the media share extension

Aslo issue that I found while working on it:
If user didn't open the app for some time and during this time more than 1 NewClient came -> User will see a dialog only about 1 NewClient (the last one).

Causes (Optional)

NewClients event is not saved anywhere, there was only Singleton NewClientManager which we were using for emitting such an event into observers (ObserveNewClientsUseCase) and it emits new clients one by one

Solutions

Add new DB-table NewClient and save NewClients there. Now we can observe and not observe NewClients depending on screen, without losing any NewClient.

  • Instead of emitting newClients one by one ObserveNewClientsUseCase emits a list of newClients.

Important:

Breaking changes! Merge only when android PR ready for merge

@CLAassistant
Copy link

CLAassistant commented Jun 7, 2023

CLA assistant check
All committers have signed the CLA.

@MohamadJaara
Copy link
Member

storing those events in the global DB add a layer of complication that is unnecessary, for example on login we need to remember to clear those events.

we can keep those events in the user self DB and if you want to globally observe the list you can observe active accounts -> get events for each account separately

@github-actions
Copy link
Contributor

github-actions bot commented Jun 7, 2023

Unit Test Results

   306 files   -   68     306 suites   - 68   18s ⏱️ - 1m 31s
1 691 tests  - 300  1 627 ✔️  - 282  64 💤  - 18  0 ±0 

Results for commit 52a4393. ± Comparison against base commit 64a1c87.

♻️ This comment has been updated with latest results.

@codecov-commenter
Copy link

codecov-commenter commented Jun 7, 2023

Codecov Report

Merging #1785 (52a4393) into develop (64a1c87) will increase coverage by 0.04%.
The diff coverage is 66.00%.

@@              Coverage Diff              @@
##             develop    #1785      +/-   ##
=============================================
+ Coverage      53.46%   53.50%   +0.04%     
- Complexity      1512     1525      +13     
=============================================
  Files            960      965       +5     
  Lines          35713    35844     +131     
  Branches        3163     3171       +8     
=============================================
+ Hits           19094    19179      +85     
- Misses         15360    15399      +39     
- Partials        1259     1266       +7     

Copy link
Member

@vitorhugods vitorhugods left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern is that by making Client serializable and storing it as JSON we have to be super careful.

Our data classes in Logic weren't made to be persisted. We have Entities and all the tooling to detect breaking changes there.

Any change in the data class will break the stored JSON in a way won't notice, unlike with DB schema changes.

So, if it is possible to use the actual entities, that would be preferable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it simpler to add a isNew flag to the client column instead of storing a JSON client list in the Metadata table?

If we add a new field to the Client model, it can break the JSON blob that this PR is storing in the Metadata table.

Our migration tests will not catch this change, and we'd need to write complicated migrations using JSON functions in SQLite or whatever other solution.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a flag to the client table will have the issue if you register a client and delete, while other clients will miss the notification that a new client was added.

100% agree with moving the storing logic to persistence

How about adding a table to it? So, no JSON strings, and we can keep the data even if the client is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe i'll just add removing that new client from the DB, when we receive Event.User.ClientRemove ???

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did it, you can check it :)

@vitorhugods
Copy link
Member

Will this also be needed on release/candidate ?

deviceType = deviceType?.let { fromDeviceTypeEntity(deviceType) },
label = null,
model = model,
isVerified = true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't expect new clients to be verified by default, but I guess doesn't really matter for what you are using this for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true, it's not used anywhere in this flow, but I'll change it to false just in case :)

@borichellow
Copy link
Contributor Author

Will this also be needed on release/candidate ?

good question 🤔

@borichellow borichellow added this pull request to the merge queue Jun 19, 2023
Merged via the queue into develop with commit 0c00157 Jun 19, 2023
9 checks passed
@borichellow borichellow deleted the fix/new_client_dialog_flow branch June 19, 2023 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants