Skip to content

Commit

Permalink
Remove warnings and set public event values.
Browse files Browse the repository at this point in the history
  • Loading branch information
humdrum committed Aug 28, 2024
1 parent 8ba1b4c commit 57c7dcb
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Examples/KanbanApp/KanbanApp/Kanban/KanbanViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Document/DocEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public struct ConnectionChangedEvent: DocEvent {
/**
* ConnectionChanged type
*/
var value: StreamConnectionStatus
public var value: StreamConnectionStatus
}

/**
Expand All @@ -146,7 +146,7 @@ public struct SyncStatusChangedEvent: DocEvent {
/**
* SyncStatusChangedEvent type
*/
var value: DocumentSyncStatus
public var value: DocumentSyncStatus
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Sources/Document/Json/JSONArray.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -606,7 +606,7 @@ public class JSONArray {
return Self.notFound
}

var debugDescription: String {
public var debugDescription: String {
self.target.debugDescription
}
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/Document/Json/JSONCounter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,9 @@ public class JSONCounter<T: YorkieCountable> {
self.increase(value: T(value))
}
}

extension JSONCounter: CustomDebugStringConvertible {
public var debugDescription: String {
"\(self._value)"
}
}

0 comments on commit 57c7dcb

Please sign in to comment.