mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fixes #1102 - Crashes when opening the invites screen
This commit is contained in:
committed by
Stefan Ceriu
parent
ede4ab095c
commit
f624add018
@@ -19,7 +19,7 @@ enum InvitesScreenViewModelAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct InvitesScreenViewState: BindableState {
|
struct InvitesScreenViewState: BindableState {
|
||||||
var invites: [InvitesScreenRoomDetails]?
|
var invites: [InvitesScreenRoomDetails] = []
|
||||||
var bindings: InvitesScreenViewStateBindings = .init()
|
var bindings: InvitesScreenViewStateBindings = .init()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ struct InvitesScreenViewStateBindings {
|
|||||||
var alertInfo: AlertInfo<Bool>?
|
var alertInfo: AlertInfo<Bool>?
|
||||||
}
|
}
|
||||||
|
|
||||||
struct InvitesScreenRoomDetails {
|
struct InvitesScreenRoomDetails: Identifiable {
|
||||||
let roomDetails: RoomSummaryDetails
|
let roomDetails: RoomSummaryDetails
|
||||||
var inviter: RoomMemberProxyProtocol?
|
var inviter: RoomMemberProxyProtocol?
|
||||||
var isUnread: Bool
|
var isUnread: Bool
|
||||||
@@ -35,6 +35,10 @@ struct InvitesScreenRoomDetails {
|
|||||||
var isDirect: Bool {
|
var isDirect: Bool {
|
||||||
roomDetails.isDirect
|
roomDetails.isDirect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var id: String {
|
||||||
|
roomDetails.id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum InvitesScreenViewAction {
|
enum InvitesScreenViewAction {
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ class InvitesScreenViewModel: InvitesScreenViewModelType, InvitesScreenViewModel
|
|||||||
|
|
||||||
let inviter: RoomMemberProxyProtocol? = await room.inviter()
|
let inviter: RoomMemberProxyProtocol? = await room.inviter()
|
||||||
|
|
||||||
guard let inviter, let inviteIndex = state.invites?.firstIndex(where: { $0.roomDetails.id == roomID }) else {
|
guard let inviter, let inviteIndex = state.invites.firstIndex(where: { $0.roomDetails.id == roomID }) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
state.invites?[inviteIndex].inviter = inviter
|
state.invites[inviteIndex].inviter = inviter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,9 +21,9 @@ struct InvitesScreen: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
if let rooms = context.viewState.invites, !rooms.isEmpty {
|
if !context.viewState.invites.isEmpty {
|
||||||
LazyVStack(spacing: 0) {
|
LazyVStack(spacing: 0) {
|
||||||
ForEach(rooms, id: \.roomDetails.id) { invite in
|
ForEach(context.viewState.invites) { invite in
|
||||||
InvitesScreenCell(invite: invite,
|
InvitesScreenCell(invite: invite,
|
||||||
imageProvider: context.imageProvider,
|
imageProvider: context.imageProvider,
|
||||||
acceptAction: { context.send(viewAction: .accept(invite)) },
|
acceptAction: { context.send(viewAction: .accept(invite)) },
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
Fixed crashes when opening the invites screen
|
||||||
Reference in New Issue
Block a user