From 8b8bade25cec783b6f2be5c4e3113826272ff40d Mon Sep 17 00:00:00 2001 From: Jamie Pine Date: Tue, 25 Nov 2025 09:15:20 -0800 Subject: [PATCH] Add device-owned space models to sync registry --- core/src/infra/sync/registry.rs | 80 ++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/core/src/infra/sync/registry.rs b/core/src/infra/sync/registry.rs index 068aa412d..ea558da3c 100644 --- a/core/src/infra/sync/registry.rs +++ b/core/src/infra/sync/registry.rs @@ -180,7 +180,8 @@ pub async fn register_shared( fn initialize_registry() -> HashMap { use crate::infra::db::entities::{ audit_log, collection, collection_entry, content_identity, device, entry, location, sidecar, - tag, tag_relationship, user_metadata, user_metadata_tag, volume, + space, space_group, space_item, tag, tag_relationship, user_metadata, user_metadata_tag, + volume, }; let mut registry = HashMap::new(); @@ -475,6 +476,83 @@ fn initialize_registry() -> HashMap { ), ); + // Space models (device-owned) + registry.insert( + "space".to_string(), + SyncableModelRegistration::device_owned( + "space", + "spaces", + |data, db| { + Box::pin(async move { space::Model::apply_state_change(data, db.as_ref()).await }) + }, + |device_id, since, cursor, batch_size, db| { + Box::pin(async move { + space::Model::query_for_sync(device_id, since, cursor, batch_size, db.as_ref()) + .await + }) + }, + Some(|uuid, db| { + Box::pin(async move { space::Model::apply_deletion(uuid, db.as_ref()).await }) + }), + ), + ); + + registry.insert( + "space_group".to_string(), + SyncableModelRegistration::device_owned( + "space_group", + "space_groups", + |data, db| { + Box::pin(async move { + space_group::Model::apply_state_change(data, db.as_ref()).await + }) + }, + |device_id, since, cursor, batch_size, db| { + Box::pin(async move { + space_group::Model::query_for_sync( + device_id, + since, + cursor, + batch_size, + db.as_ref(), + ) + .await + }) + }, + Some(|uuid, db| { + Box::pin(async move { space_group::Model::apply_deletion(uuid, db.as_ref()).await }) + }), + ), + ); + + registry.insert( + "space_item".to_string(), + SyncableModelRegistration::device_owned( + "space_item", + "space_items", + |data, db| { + Box::pin(async move { + space_item::Model::apply_state_change(data, db.as_ref()).await + }) + }, + |device_id, since, cursor, batch_size, db| { + Box::pin(async move { + space_item::Model::query_for_sync( + device_id, + since, + cursor, + batch_size, + db.as_ref(), + ) + .await + }) + }, + Some(|uuid, db| { + Box::pin(async move { space_item::Model::apply_deletion(uuid, db.as_ref()).await }) + }), + ), + ); + registry }