From 57c7dcb32fd529674700cc773fd71280d564ea6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=EC=A0=95=EA=B7=A0?= Date: Wed, 28 Aug 2024 21:27:11 +0900 Subject: [PATCH] Remove warnings and set public event values. --- Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift | 4 ++-- .../TextEditorApp/TextEditor/TextViewModel.swift | 4 ++-- Sources/Document/DocEvent.swift | 4 ++-- Sources/Document/Json/JSONArray.swift | 4 ++-- Sources/Document/Json/JSONCounter.swift | 6 ++++++ 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift b/Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift index c90c83d8..556c2866 100644 --- a/Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift +++ b/Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift @@ -45,9 +45,9 @@ class KanbanViewModel: ObservableObject { Task { [weak self] in guard let self else { return } - await self.document.subscribe { _, _ in + await self.document.subscribe { _, document in Task { @MainActor [weak self] in - guard let self, let lists = await self.document.getRoot().lists as? JSONArray else { return } + guard let self, let lists = document.getRoot().lists as? JSONArray else { return } self.columns = lists.compactMap { each -> KanbanColumn? in guard let column = each as? JSONObject, diff --git a/Examples/TextEditorApp/TextEditorApp/TextEditor/TextViewModel.swift b/Examples/TextEditorApp/TextEditorApp/TextEditor/TextViewModel.swift index e18a8f38..d0a4dbea 100644 --- a/Examples/TextEditorApp/TextEditorApp/TextEditor/TextViewModel.swift +++ b/Examples/TextEditorApp/TextEditorApp/TextEditor/TextViewModel.swift @@ -66,13 +66,13 @@ class TextViewModel { } } - await self.document.subscribePresence(.others) { [weak self] event, _ in + await self.document.subscribePresence(.others) { [weak self] event, document in if let event = event as? PresenceChangedEvent { if let fromPos: TextPosStruct = self?.decodePresence(event.value.presence["from"]), let toPos: TextPosStruct = self?.decodePresence(event.value.presence["to"]) { Task { [weak self] in - if let (fromIdx, toIdx) = try? await(self?.document.getRoot().content as? JSONText)?.posRangeToIndexRange((fromPos, toPos)) { + if let (fromIdx, toIdx) = try? (document.getRoot().content as? JSONText)?.posRangeToIndexRange((fromPos, toPos)) { let range: NSRange if fromIdx <= toIdx { diff --git a/Sources/Document/DocEvent.swift b/Sources/Document/DocEvent.swift index e9a90e38..40402a09 100644 --- a/Sources/Document/DocEvent.swift +++ b/Sources/Document/DocEvent.swift @@ -120,7 +120,7 @@ public struct ConnectionChangedEvent: DocEvent { /** * ConnectionChanged type */ - var value: StreamConnectionStatus + public var value: StreamConnectionStatus } /** @@ -146,7 +146,7 @@ public struct SyncStatusChangedEvent: DocEvent { /** * SyncStatusChangedEvent type */ - var value: DocumentSyncStatus + public var value: DocumentSyncStatus } /** diff --git a/Sources/Document/Json/JSONArray.swift b/Sources/Document/Json/JSONArray.swift index 0301155e..b59d07d0 100644 --- a/Sources/Document/Json/JSONArray.swift +++ b/Sources/Document/Json/JSONArray.swift @@ -20,7 +20,7 @@ import Foundation * `JSONArray` represents JSON array, but unlike regular JSON, it has time * tickets created by a logical clock to resolve conflicts. */ -public class JSONArray { +public class JSONArray: CustomDebugStringConvertible { static let notAppend = -1 static let notFound = -1 @@ -606,7 +606,7 @@ public class JSONArray { return Self.notFound } - var debugDescription: String { + public var debugDescription: String { self.target.debugDescription } } diff --git a/Sources/Document/Json/JSONCounter.swift b/Sources/Document/Json/JSONCounter.swift index bfe834be..589b6746 100644 --- a/Sources/Document/Json/JSONCounter.swift +++ b/Sources/Document/Json/JSONCounter.swift @@ -103,3 +103,9 @@ public class JSONCounter { self.increase(value: T(value)) } } + +extension JSONCounter: CustomDebugStringConvertible { + public var debugDescription: String { + "\(self._value)" + } +}