Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

(Bugfix) - #1246 Addressbook entries removed when reloading page#1300

Merged
Agupane merged 36 commits intodevelopmentfrom
1246-addressbook-entries-removed
Sep 22, 2020
Merged

(Bugfix) - #1246 Addressbook entries removed when reloading page#1300
Agupane merged 36 commits intodevelopmentfrom
1246-addressbook-entries-removed

Conversation

@Agupane
Copy link
Contributor

@Agupane Agupane commented Aug 28, 2020

Closes #1246
Also closes #558

Description

  • Add types, removes duplicated code
  • Simplifies the addressBook state, previously was like: {addressBook:{addressBook:[]}}, now it just: {addressBook: []}
  • The error was caused basically because we were saving an empty addressBook even if the addressBook was empty

@Agupane Agupane self-assigned this Aug 28, 2020
@github-actions
Copy link

CLA Assistant Lite All Contributors have signed the CLA.

@github-actions
Copy link

github-actions bot commented Aug 28, 2020

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 10 0
Ignored 0 N/A
  • Result: ✅ success

  • Annotations: 10 total


[warning] @typescript-eslint/explicit-module-boundary-types

Require explicit return and argument types on exported functions' and classes' public class methods


Report generated by eslint-plus-action

@ghost
Copy link

ghost commented Aug 28, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@Agupane Agupane requested review from francovenica and mmv08 August 28, 2020 13:52
@mmv08
Copy link
Contributor

mmv08 commented Aug 28, 2020

Simplifies the addressBook state, previously was like: {addressBook:{addressBook:[]}}, now it just: {addressBook: []}

What happens to users who have old structure in their storage?

@Agupane
Copy link
Contributor Author

Agupane commented Aug 28, 2020

Simplifies the addressBook state, previously was like: {addressBook:{addressBook:[]}}, now it just: {addressBook: []}

What happens to users who have old structure in their storage?

That's not a problem, I updated how we are managing the state on redux, not how we are storing it on localStorage, you can do the test using this preview branch and another one if you like

@francovenica
Copy link
Contributor

The address book starts empty (normal behavior), and I started to add names to it and they were saved correctly.
But after refreshing the page a couple of times the list suddenly filled itself with all the owner of that safe, but without their name, probably because they are called all "Owner#N" and there is a condition to hide those names and the "UNKNOWN" ones as well

Chances are that this are 2 different issues, one is the address book being filled on its own and the other is not showing the name for being a name by default

image.png

Steps:
Enter in the address book. If a safe was never load in the PR the address book will be empty
Create an entry in the address book
Go to send funds and use the recipient field to search for the entry created.
Close the form and go back to the address book
If you refresh the page, it loads all the owners of the safe as shown in the snapshot

https://pr1300--safereact.review.gnosisdev.com/app/#/safes/0x9913B9180C20C6b0F21B6480c84422F6ebc4B808/address-book

@fernandomg fernandomg self-requested a review August 31, 2020 18:14
Copy link
Contributor

@fernandomg fernandomg left a comment

Choose a reason for hiding this comment

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

Aside from what Franco pointed out, another use case is that it fails to persist the already stored names across Safes. That is:

  1. Load an existing Safe and set some names for the owners
  2. Create a new Safe, with one owner (this is irrelevant, I guess, but it's what I did)
  3. Switch to the previously loaded Safe
  4. Switch back to the newly created Safe, go to address book tab (you'll see all the previously loaded Safe owners, but without a name being listed)
  5. Obviously, if you set a name in the newly created Safe, it will overwrite the name for the previously loaded one.

@Agupane
Copy link
Contributor Author

Agupane commented Sep 1, 2020

As fas as I investigated, most of this issues are related to a race condition between the load of the safe and the load of the address book, we are currently syncing the owners of each of the safes and there are times in which the safe is loaded before the addressBook. I think that the best solution should be the implementation of this refactor in order to have an unique source of truth and avoid this sync of owners between safes. What do you think? @lukasschor

…to 801-address-book-refactor

# Conflicts:
#	src/logic/addressBook/store/actions/addAddressBook.js
#	src/logic/addressBook/store/actions/addAddressBookEntry.js
#	src/logic/addressBook/store/actions/addOrUpdateAddressBookEntry.js
#	src/logic/addressBook/store/actions/loadAddressBookFromStorage.js
#	src/logic/addressBook/store/actions/removeAddressBookEntry.js
#	src/logic/addressBook/store/actions/updateAddressBookEntry.js
#	src/logic/addressBook/store/reducer/addressBook.ts
#	src/logic/addressBook/store/selectors/index.js
#	src/routes/safe/components/AddressBook/index.tsx
#	src/routes/safe/components/Settings/ManageOwners/AddOwnerModal/index.tsx
#	src/routes/safe/components/Settings/ManageOwners/EditOwnerModal/index.tsx
#	src/routes/safe/components/Settings/ManageOwners/ReplaceOwnerModal/index.tsx
#	src/routes/safe/container/Hooks/useLoadSafe.jsx
#	src/routes/safe/container/index.jsx
#	src/routes/safe/store/middleware/safeStorage.js
Remove unused saveAndUpdateAddressBook action
Add types
Removes unused addAddressBook action
Let the user remove owners users without adding them again each time the safe loads
@Agupane
Copy link
Contributor Author

Agupane commented Sep 15, 2020

I'm not sure if the current behavior.

  • I opened this locally, with already stored addresses in the AddressBook, nothing was listed. So I assume this is a destructive change?

  • After cleaning the storage, no address was preloaded. As I loaded the Safe using the URL (not the Load Storage form), owners weren't loaded either.

    • This last item makes the thing a bit hard to handle.
    • I'm not being told what should I do to have the owners loaded.
  • I added a migration function together with tests to avoid the destruction of the old addressBook, please check it out

@Agupane Agupane requested a review from fernandomg September 15, 2020 15:29
@ghost
Copy link

ghost commented Sep 15, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Sep 16, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Sep 18, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Sep 18, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Sep 18, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

1 similar comment
@ghost
Copy link

ghost commented Sep 18, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@ghost
Copy link

ghost commented Sep 21, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@francovenica
Copy link
Contributor

The issues reported in #1246 and #558 were solved

There is an inconsistency how address book is working regarding the unknown names, and addresses being added automatically sometimes. This is going to be discussion on when and how implement it.

But since the 2 main issues are solved here I'll approve the PR

@ghost
Copy link

ghost commented Sep 21, 2020

Travis automatic deployment:
https://pr1300--safereact.review.gnosisdev.com/app

@Agupane Agupane merged commit 59dc1f7 into development Sep 22, 2020
@Agupane Agupane deleted the 1246-addressbook-entries-removed branch September 22, 2020 12:31
@github-actions github-actions bot locked and limited conversation to collaborators Sep 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Address book - New entries are erased when reloading the page Address book - "Send" button in read only mode

6 participants