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

Basic account import #1347

Merged
merged 16 commits into from
Dec 15, 2023
Merged

Basic account import #1347

merged 16 commits into from
Dec 15, 2023

Conversation

robknight
Copy link
Member

@robknight robknight commented Dec 11, 2023

Closes #1272

@robknight robknight requested a review from artwyman December 11, 2023 17:28
Copy link
Member

@artwyman artwyman left a comment

Choose a reason for hiding this comment

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

Review of the core PCD-handling logic, and some thoughts on the user experience. I didn't review the UI integration in detail.

This simple version is probably fine, though I raised some questions in comments to think about where it might cause confusing situations.

I think what I'll need for sync merge is going to be somewhat more complex than this. Depending on where things go from comments, this code converge with that need, or could be kept separate. I'm less concerned about duplicated effort than I was, because this code is less complex than I feared.

setImportState({
valid: true,
imported: false,
pcds,
Copy link
Member

Choose a reason for hiding this comment

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

This is explicitly importing only PCDs, not subscriptions, and not other user data which is in the blob. I think that's a valid choice for this feature, though maybe different from what I want for sync merge.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes - I'm not sure whether restoring subscriptions makes sense or not, or whether it would be a desirable feature.

Copy link
Member

Choose a reason for hiding this comment

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

Depends on whether the user sees this as importing a set of PCDs, or rolling back their account to a known good state. Feeds are likely not hard to reconstruct, but they are technically user data which could be lost in a conflict.

for (const pcd of importState.pcds) {
if (!pcdCollection.hasPCDWithId(pcd.id)) {
try {
pcdCollection.add(pcd);
Copy link
Member

Choose a reason for hiding this comment

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

This works fine for import. Given I recently realized that PCD ordering is a user-visible piece of state, let me think through that here. This logic doesn't attempt to preserve PCD ordering but puts imported ones at the end of the folder order as if they were new. Doing otherwise would be complicated, so I'm not recommending it, just pointing it out.

@artwyman
Copy link
Member

I reviewed the latest changes and resolved one conversation based on it, but others remain TBD.

Copy link
Member

@artwyman artwyman left a comment

Choose a reason for hiding this comment

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

Looking great! A few more suggestions inline. I also think you planned to investigate single-folder import before calling this done

apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
packages/pcd-collection/src/PCDCollection.ts Outdated Show resolved Hide resolved

this.addAll(pcds, { upsert: true });

// If the caller wants folders to be merged too
Copy link
Member

Choose a reason for hiding this comment

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

Not your fault, but it's super weird to me that setting folders is a separate operation from adding the PCDs. Should probably be unified into add/addAll someday.

packages/pcd-collection/test/PCDCollection.spec.ts Outdated Show resolved Hide resolved
@robknight robknight force-pushed the rob/import-backup branch 2 times, most recently from da05221 to d788104 Compare December 13, 2023 14:53
Copy link
Member

@artwyman artwyman left a comment

Choose a reason for hiding this comment

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

A few more things to consider or discuss.

collection: PCDCollection,
pcdsToMergeIds: Set<PCD["id"]>
) {
const userHasExistingSemaphoreIdentityPCD =
Copy link
Member

Choose a reason for hiding this comment

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

It would be nice if this filtering logic (special-case for identity, email, and the decision never to replace the same ID) were in a helper function defined once rather than duplicated both here and in the UI.

apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
imported: pcds.getAll().length - pcdCountBeforeMerge
}
});
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

Log the error to console. Actually in general a few console log statements in this function in normal path would be welcome.

Copy link
Member

Choose a reason for hiding this comment

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

I'd still like to see some console logging in here, both for errors and normal cases.

Copy link
Member

Choose a reason for hiding this comment

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

Ping that this still remains to be done, though I'm not going to hold back the review just for logging.

apps/passport-client/src/state.ts Outdated Show resolved Hide resolved
apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
packages/pcd-collection/src/PCDCollection.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@ichub ichub left a comment

Choose a reason for hiding this comment

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

bug report

I exported pcds from one account, after having added a new eddsa signature pcd via consumer-client. then, I logged out, and logged in with a new account. attempting to import my pcds from the 1st account resulted in the following error:

Screenshot 2023-12-13 at 12 54 20 PM

However, after reloading the page, the eddsa signature PCD is indeed imported.


Opinions - everyone's got 'em, including me :3 Sorry to be so pedantic in my review, but it's what I think based on the information I have.

apps/passport-client/src/dispatch.ts Show resolved Hide resolved
apps/passport-client/src/state.ts Outdated Show resolved Hide resolved
packages/pcd-collection/src/PCDCollection.ts Outdated Show resolved Hide resolved
packages/pcd-collection/src/PCDCollection.ts Outdated Show resolved Hide resolved
apps/passport-client/src/dispatch.ts Show resolved Hide resolved
@robknight
Copy link
Member Author

The modal is now a screen, which makes the UI nicer, and also removes the sync problem: sync only runs when you're on a screen with the useSyncE2EEStorage() hook, and by not including that here we can ensure that the sync process will not interfere with the import.

Copy link
Contributor

@ichub ichub left a comment

Choose a reason for hiding this comment

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

tested locally and it seemed to work.

<LinkButton $primary={true} to="/import" onClick={close}>
Import Account Data
</LinkButton>
<Spacer h={16} />
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this spacer made a difference as the modal is still the same size for me. I wonder if its height is hard-coded somewhere.

apps/passport-client/pages/index.tsx Outdated Show resolved Hide resolved
apps/passport-client/src/state.ts Show resolved Hide resolved
Copy link
Member

@artwyman artwyman left a comment

Choose a reason for hiding this comment

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

I like the new functionality, but a few more requests to make on the latest state.

apps/passport-client/src/dispatch.ts Outdated Show resolved Hide resolved
imported: pcds.getAll().length - pcdCountBeforeMerge
}
});
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

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

I'd still like to see some console logging in here, both for errors and normal cases.


/**
* Merges another PCD collection into this one.
* There are two options:
Copy link
Member

Choose a reason for hiding this comment

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

There aren't two of these anymore.

artwyman added a commit that referenced this pull request Dec 15, 2023
@robknight robknight added this pull request to the merge queue Dec 15, 2023
Merged via the queue into main with commit 98d39d9 Dec 15, 2023
1 check passed
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.

import PCDs feature
3 participants