Skip to content

Commit

Permalink
Handle PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Feb 5, 2024
1 parent 4e8dae8 commit 6e0409e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
32 changes: 20 additions & 12 deletions ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,30 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
actionsSubject.send(.presentGlobalSearch)
case .markRoomAsUnread(let roomIdentifier):
Task {
if let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) {
if case .failure(let error) = await roomProxy.markAsUnread() {
MXLog.error("Failed marking room \(roomIdentifier) as unread with error: \(error)")
} else {
ServiceLocator.shared.analytics.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle)
}
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else {
MXLog.error("Failed retrieving room for identifier: \(roomIdentifier)")
return
}

switch await roomProxy.markAsUnread() {
case .success:
ServiceLocator.shared.analytics.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle)
case .failure(let error):
MXLog.error("Failed marking room \(roomIdentifier) as unread with error: \(error)")
}
}
case .markRoomAsRead(let roomIdentifier):
Task {
if let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) {
if case .failure(let error) = await roomProxy.markAsRead(sendReadReceipts: true, receiptType: appSettings.sendReadReceiptsEnabled ? .read : .readPrivate) {
MXLog.error("Failed marking room \(roomIdentifier) as read with error: \(error)")
} else {
ServiceLocator.shared.analytics.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle)
}
guard let roomProxy = await userSession.clientProxy.roomForIdentifier(roomIdentifier) else {
MXLog.error("Failed retrieving room for identifier: \(roomIdentifier)")
return
}

switch await roomProxy.markAsRead(sendReadReceipts: true, receiptType: appSettings.sendReadReceiptsEnabled ? .read : .readPrivate) {
case .success:
ServiceLocator.shared.analytics.trackInteraction(name: .MobileRoomListRoomContextMenuUnreadToggle)
case .failure(let error):
MXLog.error("Failed marking room \(roomIdentifier) as read with error: \(error)")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-2408.api
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove unnecessary analytics abstraction levels, directly create analytics events in the analytics service

0 comments on commit 6e0409e

Please sign in to comment.