Skip to content

Commit eca0a18

Browse files
authored
Communication: Fix disappearing messages and toolbar (#176)
* Fix message toolbar not showing up on iOS 18 * Use correct topic for websocket in non course-wide channels * Fix websocket connection for non course wide channels
1 parent 9b2e3e3 commit eca0a18

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

ArtemisKit/Sources/Messages/ViewModels/ConversationViewModels/ConversationViewModel.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,24 @@ private extension ConversationViewModel {
323323

324324
func subscribeToConversationTopic() {
325325
let topic: String
326-
if conversation.baseConversation.type == .channel {
326+
if conversation.baseConversation.type == .channel,
327+
let channel = conversation.baseConversation as? Channel,
328+
channel.isCourseWide == true {
327329
topic = WebSocketTopic.makeChannelNotifications(courseId: course.id)
328330
} else if let id = userSession.user?.id {
329331
topic = WebSocketTopic.makeConversationNotifications(userId: id)
330332
} else {
331333
return
332334
}
333335
if stompClient.didSubscribeTopic(topic) {
336+
/// These web socket topics are the same across multiple channels.
337+
/// We might need to wait until a previously open conversation has unsubscribed
338+
/// before we can subscribe again
339+
Timer.scheduledTimer(withTimeInterval: 5, repeats: false) { [weak self] _ in
340+
DispatchQueue.main.async { [weak self] in
341+
self?.subscribeToConversationTopic()
342+
}
343+
}
334344
return
335345
}
336346
subscription = Task { [weak self] in

ArtemisKit/Sources/Messages/Views/SendMessageViews/SendMessageView.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct SendMessageView: View {
3333
}
3434
textField
3535
.padding(isFocused ? [.horizontal, .bottom] : .all, .l)
36-
if viewModel.isEditing && isFocused {
36+
if isFocused {
3737
keyboardToolbarContent
3838
.padding(.horizontal, .l)
3939
.padding(.vertical, .m)
@@ -101,13 +101,6 @@ private extension SendMessageView {
101101
.textFieldStyle(.roundedBorder)
102102
.lineLimit(10)
103103
.focused($isFocused)
104-
.toolbar {
105-
if isFocused && !viewModel.isEditing {
106-
ToolbarItem(placement: .keyboard) {
107-
keyboardToolbarContent
108-
}
109-
}
110-
}
111104
if !isFocused {
112105
sendButton
113106
}

ArtemisKit/Sources/Notifications/Services/NotificationWebsocketServiceImpl.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ class NotificationWebsocketServiceImpl: NotificationWebsocketService {
6464
await subscribeToTutorialGroupNotificationUpdates()
6565
}
6666
addTask(subscribeToTutorialGroupNotificationUpdatesTask)
67-
let subscribeToConversationNotificationUpdatesTask = Task {
68-
await subscribeToConversationNotificationUpdates()
69-
}
70-
addTask(subscribeToConversationNotificationUpdatesTask)
67+
#warning("We can't subscribe to this here and in the conversation simultaneously")
68+
// let subscribeToConversationNotificationUpdatesTask = Task {
69+
// await subscribeToConversationNotificationUpdates()
70+
// }
71+
// addTask(subscribeToConversationNotificationUpdatesTask)
7172

7273
return stream
7374
}

0 commit comments

Comments
 (0)