Skip to content

Conversation

mcasimir
Copy link
Collaborator

@mcasimir mcasimir commented Mar 14, 2022

List of changes:

  • derive pre-sorted favorite and recent connections lists from loaded connections
  • on connect: delete the last recent if a new one was saved and 10 were already existing
  • use favoriteConncections and recentConnections in the connection list
  • isolate <ResizableSidebar> from <ConnectionList>

!connectionInfoToBeSaved.lastUsed &&
recentConnections.length >= MAX_RECENT_CONNECTIONS_LENGTH
) {
await removeConnection(recentConnections[recentConnections.length - 1]);
Copy link
Collaborator Author

@mcasimir mcasimir Mar 14, 2022

Choose a reason for hiding this comment

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

NOTE: this technically abuses a little the fact that recentConnections contains already all the recents ordered in the right way. This may change, for example, if we introduce some way to reorder or filter that list dynamically .. not really something we are planning for now, but I could easily extract a getRecentsByLastUsed(connections) and use it both here and in useMemo instead.

Let me know if you have some thoughts about it.


// this may cause a false negative, but there is no other reliable way to
// test this case. It would fail eventually if the functionality is broken.
await util.promisify(setTimeout)(100);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

anything better?

Copy link
Collaborator

Choose a reason for hiding this comment

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

You can write the test in onConnected and use done similar to how we usually test callback behavior, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If I understand it right, onConnected is called before any of this happens

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it make sense to move the callback and call it only after everything else finished there successfuly then maybe? Otherwise you're communicating that connection happened and then do a bunch of stuff that can fail in the same hook, is it sorta expected?

Copy link
Collaborator Author

@mcasimir mcasimir Mar 16, 2022

Choose a reason for hiding this comment

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

Yeah we could do something Iike that. I think is intentional that one doesn't wait for the other though.

Probably better to have a Promise.all() to make it clear, but yeah if saving "recent" won't work users should still be able to connect and move on to the next screen.

I could do

try { 
   await updateRecent()
} catch (e) {
   log(e);
};

onConnectionSucceded()

@Anemy what's your feedback on this?

To be clear that test won't flake and it would quite likely fail all the time if a recent gets removed, but is not technically guaranteed to be red if the feature is broken.

Copy link
Member

@Anemy Anemy Mar 16, 2022

Choose a reason for hiding this comment

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

I see what you mean it's a bit hard to test.
I think it makes sense not to wait for a file system access or entry before moving the user past the connect screen? Probably super fast on most machines but could cause some delay potentially and as a result we'd want to add a check if the user then cancelled the connection attempt and stop the flow here making things a bit more complicated then that probably need to be.
Can't think of a cleaner way without bringing in extra logic or debugs in the flow. I'm alright with the setTimeout here as it's only in one test and will probably never fail, can always improve it later if somehow it does flake. Would adding a debug log after this flow has completed and then monitoring debug logs in the test work?

Copy link
Collaborator Author

@mcasimir mcasimir Mar 16, 2022

Choose a reason for hiding this comment

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

this flow has completed and then monitoring debug logs in the test work

Seems convoluted, If we have to change the code for this test maybe we could add an optional callback like onConnectionProcessComplete or something? That we could do, not really useful outside the tests but is kinda clean.

@lerouxb
Copy link
Contributor

lerouxb commented Mar 16, 2022

The e2e test flake will hopefully go away if you merge in main: #2899

Or it will at least help us debug what's going on if it happens again.

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Nice, I really like the improvements in the resizable sidebar usage and connections-store.
One comment on the sidebar width which might not be intended? Other than that looks good to go

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

🔥

@mcasimir mcasimir merged commit 43d0f1f into main Mar 17, 2022
@mcasimir mcasimir deleted the truncate-recents branch March 17, 2022 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants