Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanceriu committed Aug 20, 2024
1 parent 1396140 commit 3b85234
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
20 changes: 10 additions & 10 deletions ElementX/Sources/Screens/HomeScreen/HomeScreenViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
case .showRoomDetails(roomIdentifier: let roomIdentifier):
actionsSubject.send(.presentRoomDetails(roomIdentifier: roomIdentifier))
case .leaveRoom(roomIdentifier: let roomIdentifier):
startLeaveRoomProcess(roomId: roomIdentifier)
startLeaveRoomProcess(roomID: roomIdentifier)
case .confirmLeaveRoom(roomIdentifier: let roomIdentifier):
leaveRoom(roomId: roomIdentifier)
leaveRoom(roomID: roomIdentifier)
case .showSettings:
actionsSubject.send(.presentSettingsScreen)
case .confirmRecoveryKey:
Expand Down Expand Up @@ -382,38 +382,38 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol

private static let leaveRoomLoadingID = "LeaveRoomLoading"

private func startLeaveRoomProcess(roomId: String) {
private func startLeaveRoomProcess(roomID: String) {
Task {
defer {
userIndicatorController.retractIndicatorWithId(Self.leaveRoomLoadingID)
}
userIndicatorController.submitIndicator(UserIndicator(id: Self.leaveRoomLoadingID, type: .modal, title: L10n.commonLoading, persistent: true))

guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomId) else {
guard case let .joined(roomProxy) = await userSession.clientProxy.roomForIdentifier(roomID) else {
state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown)
return
}

if roomProxy.isPublic {
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomID: roomId, isDM: roomProxy.isEncryptedOneToOneRoom, state: .public)
state.bindings.leaveRoomAlertItem = LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .public)
} else {
state.bindings.leaveRoomAlertItem = if roomProxy.joinedMembersCount > 1 {
LeaveRoomAlertItem(roomID: roomId, isDM: roomProxy.isEncryptedOneToOneRoom, state: .private)
LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .private)
} else {
LeaveRoomAlertItem(roomID: roomId, isDM: roomProxy.isEncryptedOneToOneRoom, state: .empty)
LeaveRoomAlertItem(roomID: roomID, isDM: roomProxy.isEncryptedOneToOneRoom, state: .empty)
}
}
}
}

private func leaveRoom(roomId: String) {
private func leaveRoom(roomID: String) {
Task {
defer {
userIndicatorController.retractIndicatorWithId(Self.leaveRoomLoadingID)
}
userIndicatorController.submitIndicator(UserIndicator(id: Self.leaveRoomLoadingID, type: .modal, title: L10n.commonLeavingRoom, persistent: true))

guard case .joined = await userSession.clientProxy.roomForIdentifier(roomId) else {
guard case .joined = await userSession.clientProxy.roomForIdentifier(roomID) else {
state.bindings.alertInfo = AlertInfo(id: UUID(), title: L10n.errorUnknown)
return
}
Expand All @@ -422,7 +422,7 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
type: .toast,
title: L10n.commonCurrentUserLeftRoom,
iconName: "checkmark"))
actionsSubject.send(.roomLeft(roomIdentifier: roomId))
actionsSubject.send(.roomLeft(roomIdentifier: roomID))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class JoinRoomScreenViewModel: JoinRoomScreenViewModelType, JoinRoomScreenViewMo

userIndicatorController.submitIndicator(UserIndicator(id: roomID, type: .modal, title: L10n.commonLoading, persistent: true))

guard case let .invited(roomProxy) = await clientProxy.roomForIdentifier(roomID) else {
guard case let .invited(roomProxy) = room else {
userIndicatorController.submitIndicator(.init(title: L10n.errorUnknown))
return
}
Expand Down
2 changes: 2 additions & 0 deletions ElementX/Sources/Services/Room/InvitedRoomProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class InvitedRoomProxy: InvitedRoomProxyProtocol {
private let roomListItem: RoomListItemProtocol
private let room: RoomProtocol

// A room identifier is constant and lazy stops it from being fetched
// multiple times over FFI
lazy var id: String = room.id()

var canonicalAlias: String? {
Expand Down
2 changes: 2 additions & 0 deletions ElementX/Sources/Services/Room/JoinedRoomProxy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class JoinedRoomProxy: JoinedRoomProxyProtocol {
actionsSubject.eraseToAnyPublisher()
}

// A room identifier is constant and lazy stops it from being fetched
// multiple times over FFI
lazy var id: String = room.id()

var canonicalAlias: String? {
Expand Down

0 comments on commit 3b85234

Please sign in to comment.