diff --git a/ArtemisKit/Sources/Messages/ViewModels/ConversationViewModels/ConversationViewModel.swift b/ArtemisKit/Sources/Messages/ViewModels/ConversationViewModels/ConversationViewModel.swift index 46a24440..fad5f768 100644 --- a/ArtemisKit/Sources/Messages/ViewModels/ConversationViewModels/ConversationViewModel.swift +++ b/ArtemisKit/Sources/Messages/ViewModels/ConversationViewModels/ConversationViewModel.swift @@ -323,7 +323,9 @@ private extension ConversationViewModel { func subscribeToConversationTopic() { let topic: String - if conversation.baseConversation.type == .channel { + if conversation.baseConversation.type == .channel, + let channel = conversation.baseConversation as? Channel, + channel.isCourseWide == true { topic = WebSocketTopic.makeChannelNotifications(courseId: course.id) } else if let id = userSession.user?.id { topic = WebSocketTopic.makeConversationNotifications(userId: id) @@ -331,6 +333,14 @@ private extension ConversationViewModel { return } if stompClient.didSubscribeTopic(topic) { + /// These web socket topics are the same across multiple channels. + /// We might need to wait until a previously open conversation has unsubscribed + /// before we can subscribe again + Timer.scheduledTimer(withTimeInterval: 5, repeats: false) { [weak self] _ in + DispatchQueue.main.async { [weak self] in + self?.subscribeToConversationTopic() + } + } return } subscription = Task { [weak self] in diff --git a/ArtemisKit/Sources/Messages/Views/SendMessageViews/SendMessageView.swift b/ArtemisKit/Sources/Messages/Views/SendMessageViews/SendMessageView.swift index f84d2d6c..61a91ec4 100644 --- a/ArtemisKit/Sources/Messages/Views/SendMessageViews/SendMessageView.swift +++ b/ArtemisKit/Sources/Messages/Views/SendMessageViews/SendMessageView.swift @@ -33,7 +33,7 @@ struct SendMessageView: View { } textField .padding(isFocused ? [.horizontal, .bottom] : .all, .l) - if viewModel.isEditing && isFocused { + if isFocused { keyboardToolbarContent .padding(.horizontal, .l) .padding(.vertical, .m) @@ -101,13 +101,6 @@ private extension SendMessageView { .textFieldStyle(.roundedBorder) .lineLimit(10) .focused($isFocused) - .toolbar { - if isFocused && !viewModel.isEditing { - ToolbarItem(placement: .keyboard) { - keyboardToolbarContent - } - } - } if !isFocused { sendButton } diff --git a/ArtemisKit/Sources/Notifications/Services/NotificationWebsocketServiceImpl.swift b/ArtemisKit/Sources/Notifications/Services/NotificationWebsocketServiceImpl.swift index 96515ad3..54478d1e 100644 --- a/ArtemisKit/Sources/Notifications/Services/NotificationWebsocketServiceImpl.swift +++ b/ArtemisKit/Sources/Notifications/Services/NotificationWebsocketServiceImpl.swift @@ -64,10 +64,11 @@ class NotificationWebsocketServiceImpl: NotificationWebsocketService { await subscribeToTutorialGroupNotificationUpdates() } addTask(subscribeToTutorialGroupNotificationUpdatesTask) - let subscribeToConversationNotificationUpdatesTask = Task { - await subscribeToConversationNotificationUpdates() - } - addTask(subscribeToConversationNotificationUpdatesTask) +#warning("We can't subscribe to this here and in the conversation simultaneously") +// let subscribeToConversationNotificationUpdatesTask = Task { +// await subscribeToConversationNotificationUpdates() +// } +// addTask(subscribeToConversationNotificationUpdatesTask) return stream }