Skip to content

Commit

Permalink
Communication: Fix disappearing messages and toolbar (#176)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
anian03 authored Sep 20, 2024
1 parent 9b2e3e3 commit eca0a18
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,24 @@ 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)
} else {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit eca0a18

Please sign in to comment.