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

refactor: Split up MyAccounts component #4671

Merged
merged 9 commits into from
Dec 19, 2024
Merged

Conversation

usame-algan
Copy link
Member

@usame-algan usame-algan commented Dec 16, 2024

What it solves

Part of SW-647

How this PR fixes it

  • Renames AccountsList to MyAccounts
  • Creates a new component called AccountsList
  • Creates AllSafes, PinnedSafes, FilteredSafes components and moves logic
  • Creates AccountsFilter and AccountsHeader components and moves logic
  • Renames type AllSafesGrouped to AllSafeItemsGrouped
  • Creates new type callde AllSafeItems
  • Removes the sorting from filtered safe items
  • Changes QueueActions to be a button instead of an a element to resolve react error

ToDos

  • Revisit watchlist and pinned safes logic inside useTrackedSafesCount
  • Write tests for each component

How to test it

  1. Open the accounts page
  2. Connect a wallet
  3. Observe Safes are listed as before
  4. Pin and unpin should still work
  5. Pinned safes should be tracked
  6. Sidebar should still work as before

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

Copy link

github-actions bot commented Dec 16, 2024

Copy link

github-actions bot commented Dec 16, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

⚠️ Global Bundle Size Increased

Page Size (compressed)
global 1017.21 KB (🟡 +743 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Two Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/transactions/messages 58.41 KB (🟡 +14 B) 1.05 MB
/transactions/msg 54.57 KB (🟡 +13 B) 1.05 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link

github-actions bot commented Dec 16, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.98% (+0.07% 🔼)
14446/19526
🔴 Branches
51.63% (+0.17% 🔼)
3442/6667
🔴 Functions
57.02% (+0.16% 🔼)
2051/3597
🟡 Lines
75.51% (+0.06% 🔼)
13099/17348
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / index.tsx
100% 60% 100% 100%
🟡
... / index.tsx
58.82% 100% 0% 62.5%
🟡
... / index.tsx
72.22% 0% 0% 76.47%
🟢
... / index.tsx
100% 50% 100% 100%
🟢
... / index.tsx
100% 66.67% 100% 100%
🟡
... / index.tsx
70.59% 0% 0% 75%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / index.tsx
72.73% (-4.55% 🔻)
75% (-25% 🔻)
60%
71.43% (-4.76% 🔻)
🔴
... / useIsExpiredSwap.ts
50% (-50% 🔻)
25% (-75% 🔻)
40% (-60% 🔻)
45% (-55% 🔻)
🟢
... / index.tsx
95% (-0.45% 🔻)
85.71% 100% 100%
🟢
... / useTxPendingStatuses.ts
77.5% (-0.83% 🔻)
64.06% (-1.56% 🔻)
68.18%
86.41% (-0.97% 🔻)
🟡
... / index.tsx
63.16% (-3.51% 🔻)
0% 0%
66.67% (-4.76% 🔻)

Test suite run success

1721 tests passing in 234 suites.

Report generated by 🧪jest coverage report action from 43cee1d

Copy link
Member Author

Choose a reason for hiding this comment

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

@jmealy I remember we talked about how we handle pinned and watchlist safes. In this hook we say watchlist safes are safes that are not pinned and read-only. I think this doesn't work anymore since an unpinned safe that is not owned or undeployed is removed from the list so watchlist === pinned.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! It was a good idea to equate pinned and watchlist/added, having them as two separate concepts was confusing

@usame-algan usame-algan marked this pull request as ready for review December 17, 2024 12:28
Copy link
Contributor

@jmealy jmealy left a comment

Choose a reason for hiding this comment

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

Nice refactoring 🚀

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense! It was a good idea to equate pinned and watchlist/added, having them as two separate concepts was confusing

fullWidth
size="small"
/>
<OrderByButton orderBy={orderBy} onOrderByChange={handleOrderByChange} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Took me a minute to find the OrderByButton component here. To me AccountsFilter, suggests it only contains the search. Could we rename to reflect that it has both search and sort? AccountListFilters or something

@@ -46,6 +42,15 @@ const useTrackSafesCount = (
[safes, watchlistMultiChainSafes],
)

// TODO: This is computed here and inside PinnedSafes now. Find a way to optimize it
Copy link
Contributor

Choose a reason for hiding this comment

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

A small improvement could be to extract the calculations of allSafes and pinnedSafes into helper functions since they are both done twice, but nbd. IMO it's ok as is

@usame-algan usame-algan merged commit 011e808 into dev Dec 19, 2024
15 checks passed
@usame-algan usame-algan deleted the refactor-myaccounts branch December 19, 2024 08:47
@github-actions github-actions bot locked and limited conversation to collaborators Dec 19, 2024
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.

2 participants