Skip to content

Commit e3afbd8

Browse files
committed
Replaces presence based Typing Indicators with Ephemeral Typing Indicators as per [1].
Co-authored-by: Lawrence Forooghian <lawrence@forooghian.com> [1] - All commits up to and including ably/specification@2aa9fc2
1 parent 89fb190 commit e3afbd8

24 files changed

+1132
-231
lines changed

AblyChat.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/AblyChatExample/ContentView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ struct ContentView: View {
413413
if newMessage.isEmpty {
414414
try await room().typing.stop()
415415
} else {
416-
try await room().typing.start()
416+
try await room().typing.keystroke()
417417
}
418418
}
419419
}

Example/AblyChatExample/Mocks/MockClients.swift

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,10 +247,13 @@ class MockTyping: Typing {
247247

248248
private func createSubscription() -> MockSubscription<TypingEvent> {
249249
mockSubscriptions.create(randomElement: {
250-
TypingEvent(currentlyTyping: [
251-
MockStrings.names.randomElement()!,
252-
MockStrings.names.randomElement()!,
253-
])
250+
TypingEvent(
251+
currentlyTyping: [
252+
MockStrings.names.randomElement()!,
253+
MockStrings.names.randomElement()!,
254+
],
255+
change: .init(clientId: MockStrings.names.randomElement()!, type: .started)
256+
)
254257
}, interval: 2)
255258
}
256259

@@ -262,12 +265,12 @@ class MockTyping: Typing {
262265
Set(MockStrings.names.shuffled().prefix(2))
263266
}
264267

265-
func start() async throws(ARTErrorInfo) {
266-
mockSubscriptions.emit(TypingEvent(currentlyTyping: [clientID]))
268+
func keystroke() async throws(ARTErrorInfo) {
269+
mockSubscriptions.emit(TypingEvent(currentlyTyping: [clientID], change: .init(clientId: clientID, type: .started)))
267270
}
268271

269272
func stop() async throws(ARTErrorInfo) {
270-
mockSubscriptions.emit(TypingEvent(currentlyTyping: []))
273+
mockSubscriptions.emit(TypingEvent(currentlyTyping: [], change: .init(clientId: clientID, type: .stopped)))
271274
}
272275

273276
func onDiscontinuity(bufferingPolicy _: BufferingPolicy) -> Subscription<DiscontinuityEvent> {

Package.resolved

Lines changed: 37 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ let package = Package(
3838
url: "https://github.com/apple/swift-docc-plugin",
3939
from: "1.0.0"
4040
),
41+
.package(
42+
url: "https://github.com/groue/Semaphore",
43+
from: "0.1.0"
44+
),
45+
.package(
46+
url: "https://github.com/pointfreeco/swift-clocks",
47+
from: "1.0.0"
48+
),
4149
],
4250
targets: [
4351
.target(
@@ -51,6 +59,10 @@ let package = Package(
5159
name: "AsyncAlgorithms",
5260
package: "swift-async-algorithms"
5361
),
62+
.product(
63+
name: "Semaphore",
64+
package: "Semaphore"
65+
),
5466
]
5567
),
5668
.testTarget(
@@ -61,6 +73,10 @@ let package = Package(
6173
name: "AsyncAlgorithms",
6274
package: "swift-async-algorithms"
6375
),
76+
.product(
77+
name: "Clocks",
78+
package: "swift-clocks"
79+
),
6480
],
6581
resources: [
6682
.copy("ably-common"),
@@ -81,6 +97,10 @@ let package = Package(
8197
name: "Table",
8298
package: "Table"
8399
),
100+
.product(
101+
name: "Semaphore",
102+
package: "Semaphore"
103+
),
84104
]
85105
),
86106
]

0 commit comments

Comments
 (0)