@@ -13,13 +13,16 @@ func getAttachmentsDirectoryPath() throws -> String {
1313
1414let logTag = " SystemManager "
1515
16+ /// We use the MainActor SupabaseConnector synchronously here, this requires specifying that SystemManager runs on the MainActor
17+ /// We don't actually block the MainActor with anything
1618@Observable
17- class SystemManager {
19+ @MainActor
20+ final class SystemManager {
1821 let connector = SupabaseConnector ( )
1922 let schema = AppSchema
2023 let db : PowerSyncDatabaseProtocol
2124
22- var attachments : AttachmentQueue ?
25+ let attachments : AttachmentQueue ?
2326
2427 init ( ) {
2528 db = PowerSyncDatabase (
@@ -226,25 +229,18 @@ class SystemManager {
226229 try await attachments. deleteFile (
227230 attachmentId: photoId
228231 ) { transaction, _ in
229- try self . deleteTodoInTX (
230- id : todo . id ,
231- tx : transaction
232+ try transaction . execute (
233+ sql : " DELETE FROM \( TODOS_TABLE ) WHERE id = ? " ,
234+ parameters : [ todo . id ]
232235 )
233236 }
234237 } else {
235- try await db. writeTransaction { transaction in
236- try self . deleteTodoInTX (
237- id : todo . id ,
238- tx : transaction
238+ _ = try await db. writeTransaction { transaction in
239+ try transaction . execute (
240+ sql : " DELETE FROM \( TODOS_TABLE ) WHERE id = ? " ,
241+ parameters : [ todo . id ]
239242 )
240243 }
241244 }
242245 }
243-
244- private func deleteTodoInTX( id: String , tx: ConnectionContext ) throws {
245- _ = try tx. execute (
246- sql: " DELETE FROM \( TODOS_TABLE) WHERE id = ? " ,
247- parameters: [ id]
248- )
249- }
250246}
0 commit comments