Skip to content
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

Remove warnings and set public event values. #189

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)"
}
}