Skip to content

Conversation

gmaclennan
Copy link
Member

@gmaclennan gmaclennan commented Sep 25, 2025

This is a rework of #1123, because during review I realised it was not necessary to maintain a separate table because we already store project info in the keys table.

This changes how leaving a project is tracked: it is now written to the project keys table before clearing project data. Previously we determined whether a project was left based on whether the project settings index had a row for it, which was based on several assumptions about what leaving a project did, assumptions which could break in the future (e.g. joining a project without encryption keys as a blind peer). This change required adding a new migration functionality to run JS code based on migration steps. It adds a bit of maintenance overhead, but it will also help the core manager store migration in #1092, and could be useful in the future.

A previous fix to ensure data is cleared after leaving a project used the change of role to acertain if the project had been left, however because this check was made every time a project instance was created, including when adding a new project from an invite, it was actually creating a big delay, because a project instance would not be returned until getOwnRole returned, which waited for initial sync.

This adds a status prop to the manager.listProjects() function to be explicit about when a project is in the "joining" state, and adds an additional "left" status.

There is a change of behaviour here where $getProjectSettings() will still return the basic project info (name, description, color, sendStats) even after leaving a project, which makes it consistent with what is returned from listProjects().

The test for "partly-left projects" should be more robust now too - it doesn't "pretend" to partly leave a project, but instead prematurely exits the process to more realistically simulate what would happen in real usage if leave project fails.

Also fixes a small type bug for the projectInviteId column of the projectKeysTable, which was defined as unknown because it was defaulting to a JSON column I think.

@gmaclennan gmaclennan self-assigned this Sep 25, 2025
@awana-lockfile-bot
Copy link

package-lock.json changes

Click to toggle table visibility
Name Status Previous Current
@comapeo/core4.1.4 ADDED - 4.1.4

Copy link

socket-security bot commented Sep 25, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​comapeo/​core@​4.1.4781008495100

View full report

@gmaclennan gmaclennan marked this pull request as ready for review September 25, 2025 20:49
Copy link
Contributor

@RangerMauve RangerMauve left a comment

Choose a reason for hiding this comment

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

LGTM overall, cleaner than before

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.

2 participants