-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add a device setting to configure what to sync #680
Comments
this part makes sense to me, but I don't agree with this at the moment:
It's not immediately clear why this is necessary. My initial thought was that this should be stored this in the backend via a table in the "client" database that isn't the
for this, i would lean towards projects being configured to sync everything by default, and exposing an option to determine the sync setting upon creation. The usage I'm imagining when creating the project looks something like this: const manager = new MapeoManager({ ... })
// Case 1: Create a project with the default sync configuration, which is to sync everything:
manager.createProject({ ... })
// Case 2: Create a project that explicitly sets the sync setting (option name tbd)
manager.createProject({ ..., syncConfiguration: ... }) As for updating a project's sync setting, I'm wondering if the method needs to live in the manager instance instead of the project instance. Depending on how storage of this setting works (e.g. in the client database in core), it might be easier to expose this as a manager method that accepts the project id and sync setting. For example, these are the two approaches that are coming to mind: // Approach 1: Expose a manager instance method (name and interface tbd)
manager.updateProjectConfiguration(projectId, { sync: ... })
// Approach 2: Expose a project instance method (name and interface tbd)
project.setSyncConfiguration(...) I have a slight preference for the manager approach since this is a device-specific setting to begin with, which is usually more of a concern handled by the manager.
I guess my thoughts on this depend on where the method lives.
EDIT: Also wondering if it would be helpful to name non-synced project-related settings using the "configuration" nomenclature. I find using the "settings" wording confusing because that's something that gets stored and sync across projects, whereas the feature in question is not that, but still a "setting" of some kind. I updated the naming in the example to use the "configuration" wording, to see how it feels :) EDIT 2: I realize that I'm using the "manager" naming instead of "api" because I'm thinking about the backend implementation, which gets reflected to the client side. Just a matter of naming in this case, so replace any reference of |
Default sync setting? I agree with Andrew: default to syncing everything. Make it easy to change at any time. What is the method attached to? What is the method signature? I think you want to be able to specify simple filters like "download everything" or "download nothing", but also more complex queries like "only download photos" or "only download thumbnails". This is my dream API, which I think (1) best expresses developer intent, and (2) offers the most flexibility: // Download everything
myProject.$sync.setBlobDownloadFilters(() => true)
// Download nothing
myProject.$sync.setBlobDownloadFilters(() => false)
// Only download audio
myProject.$sync.setBlobDownloadFilters((blob) => blob.type === "audio")
// Download audio, photo previews, and photo thumbnails
myProject.$sync.setBlobDownloadFilters((blob) =>
blob.type === "audio" ||
(blob.type === "photo" &&
(blob.variant === "preview" || blob.variant === "thumbnail"))
) However, I don't know if this dream is actually possible. Is something like this fast enough? Do we need to persist filters? Does this break for some other reason? |
I'm realizing that we'll need to expose a method in the project instance one way or another, so we can dismiss the fake distinction I created in terms of where the update method lives 😅 |
Thanks all. For terminology, I suggest calling this "blob download filters", or "blob filters" for short. Persistence: backend or frontend? If we persist on the front-end, then we need a method If we persist on the back-end, then we need two methods I think persisting in the backend will reduce complexity / logic needed in the front-end, so I tentatively propose we persist in the back-end Persistence: storage location
We could create a new sqlite table for storing this information. Alternatively we could start persisting "app config" data separately, using something like Options:
For anything that we use, we should consider handling migrations (e.g. changing of config structure). Given all of this we might want to consider using the front-end for persistence which maybe already handles migrations of config structure? |
We need to persist a users's choice about what they want to sync (current options are "previews only" and "everything"). This is a device-based setting, which might be scoped to project (e.g. support different settings for each project). It shouldn't be written to the project settings of the database, which syncs with other devices.
I think this makes sense to implement on the frontend, and add an API method to change this setting.
Choices to make:
a. All new project instances start with "previews only" until configured otherwise.
b. All new project instances start with "everything" until configured otherwise.
c. We add a new option to
api.getProject
for configuring what to syncd. Combination of above (option + default)
a.
project.configureSync('previews' | 'everything')
b.
project.setArchiver(true | false)
c.
project.setBlobDownloadFilter({ variants: Array<'preview' | 'thumbnail' | 'original'> })
d. Other ideas welcome!
The text was updated successfully, but these errors were encountered: