mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-24 18:42:47 +02:00
Code review fixes
This commit is contained in:
@@ -52,7 +52,6 @@ struct UserSessionCardView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack() {
|
|
||||||
VStack(alignment: .center, spacing: 12) {
|
VStack(alignment: .center, spacing: 12) {
|
||||||
DeviceAvatarView(viewData: viewData.deviceAvatarViewData)
|
DeviceAvatarView(viewData: viewData.deviceAvatarViewData)
|
||||||
|
|
||||||
@@ -125,7 +124,6 @@ struct UserSessionCardView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding(24)
|
.padding(24)
|
||||||
}
|
|
||||||
.frame(maxWidth: .infinity)
|
.frame(maxWidth: .infinity)
|
||||||
.background(theme.colors.background)
|
.background(theme.colors.background)
|
||||||
.clipShape(self.backgroundShape)
|
.clipShape(self.backgroundShape)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ struct UserSessionCardViewData {
|
|||||||
sessionDisplayName: String?,
|
sessionDisplayName: String?,
|
||||||
deviceType: DeviceType,
|
deviceType: DeviceType,
|
||||||
isVerified: Bool,
|
isVerified: Bool,
|
||||||
lastActivityDate: TimeInterval?,
|
lastActivityTimestamp: TimeInterval?,
|
||||||
lastSeenIP: String?,
|
lastSeenIP: String?,
|
||||||
isCurrentSessionDisplayMode: Bool = false) {
|
isCurrentSessionDisplayMode: Bool = false) {
|
||||||
self.sessionId = sessionId
|
self.sessionId = sessionId
|
||||||
@@ -60,8 +60,8 @@ struct UserSessionCardViewData {
|
|||||||
|
|
||||||
var lastActivityDateString: String?
|
var lastActivityDateString: String?
|
||||||
|
|
||||||
if let lastActivityDate = lastActivityDate {
|
if let lastActivityTimestamp = lastActivityTimestamp {
|
||||||
lastActivityDateString = Self.lastActivityDateFormatter.lastActivityDateString(from: lastActivityDate)
|
lastActivityDateString = Self.lastActivityDateFormatter.lastActivityDateString(from: lastActivityTimestamp)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.lastActivityDateString = lastActivityDateString
|
self.lastActivityDateString = lastActivityDateString
|
||||||
@@ -75,6 +75,6 @@ struct UserSessionCardViewData {
|
|||||||
extension UserSessionCardViewData {
|
extension UserSessionCardViewData {
|
||||||
|
|
||||||
init(userSessionInfo: UserSessionInfo, isCurrentSessionDisplayMode: Bool = false) {
|
init(userSessionInfo: UserSessionInfo, isCurrentSessionDisplayMode: Bool = false) {
|
||||||
self.init(sessionId: userSessionInfo.sessionId, sessionDisplayName: userSessionInfo.sessionName, deviceType: userSessionInfo.deviceType, isVerified: userSessionInfo.isVerified, lastActivityDate: userSessionInfo.lastSeenTimestamp, lastSeenIP: userSessionInfo.lastSeenIP, isCurrentSessionDisplayMode: isCurrentSessionDisplayMode)
|
self.init(sessionId: userSessionInfo.sessionId, sessionDisplayName: userSessionInfo.sessionName, deviceType: userSessionInfo.deviceType, isVerified: userSessionInfo.isVerified, lastActivityTimestamp: userSessionInfo.lastSeenTimestamp, lastSeenIP: userSessionInfo.lastSeenIP, isCurrentSessionDisplayMode: isCurrentSessionDisplayMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-32
@@ -24,39 +24,9 @@ struct UserSessionsOverview: View {
|
|||||||
|
|
||||||
@Environment(\.theme) private var theme: ThemeSwiftUI
|
@Environment(\.theme) private var theme: ThemeSwiftUI
|
||||||
|
|
||||||
// MARK: Public
|
@ViewBuilder
|
||||||
|
private var currentSessionsSection: some View {
|
||||||
@ObservedObject var viewModel: UserSessionsOverviewViewModel.Context
|
|
||||||
|
|
||||||
var body: some View {
|
|
||||||
ScrollView {
|
|
||||||
|
|
||||||
// Security recommendations section
|
|
||||||
if viewModel.viewState.unverifiedSessionsViewData.isEmpty == false || viewModel.viewState.inactiveSessionsViewData.isEmpty == false {
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
}
|
|
||||||
|
|
||||||
// Current session section
|
|
||||||
if let currentSessionViewData = viewModel.viewState.currentSessionViewData {
|
if let currentSessionViewData = viewModel.viewState.currentSessionViewData {
|
||||||
self.currentSessionsSection(currentSessionViewData: currentSessionViewData)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Other sessions section
|
|
||||||
if viewModel.viewState.otherSessionsViewData.isEmpty == false {
|
|
||||||
self.otherSessionsSection
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.background(theme.colors.system.ignoresSafeArea())
|
|
||||||
.frame(maxHeight: .infinity)
|
|
||||||
.navigationTitle(VectorL10n.userSessionsOverviewTitle)
|
|
||||||
.activityIndicator(show: viewModel.viewState.showLoadingIndicator)
|
|
||||||
.onAppear() {
|
|
||||||
viewModel.send(viewAction: .viewAppeared)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func currentSessionsSection(currentSessionViewData: UserSessionCardViewData) -> some View {
|
|
||||||
SwiftUI.Section {
|
SwiftUI.Section {
|
||||||
UserSessionCardView(viewData: currentSessionViewData, onVerifyAction: { _ in
|
UserSessionCardView(viewData: currentSessionViewData, onVerifyAction: { _ in
|
||||||
viewModel.send(viewAction: .verifyCurrentSession)
|
viewModel.send(viewAction: .verifyCurrentSession)
|
||||||
@@ -74,6 +44,37 @@ struct UserSessionsOverview: View {
|
|||||||
.padding(.bottom, 11)
|
.padding(.bottom, 11)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: Public
|
||||||
|
|
||||||
|
@ObservedObject var viewModel: UserSessionsOverviewViewModel.Context
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
ScrollView {
|
||||||
|
|
||||||
|
// Security recommendations section
|
||||||
|
if viewModel.viewState.unverifiedSessionsViewData.isEmpty == false || viewModel.viewState.inactiveSessionsViewData.isEmpty == false {
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current session section
|
||||||
|
currentSessionsSection
|
||||||
|
|
||||||
|
// Other sessions section
|
||||||
|
if viewModel.viewState.otherSessionsViewData.isEmpty == false {
|
||||||
|
self.otherSessionsSection
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.background(theme.colors.system.ignoresSafeArea())
|
||||||
|
.frame(maxHeight: .infinity)
|
||||||
|
.navigationTitle(VectorL10n.userSessionsOverviewTitle)
|
||||||
|
.activityIndicator(show: viewModel.viewState.showLoadingIndicator)
|
||||||
|
.onAppear() {
|
||||||
|
viewModel.send(viewAction: .viewAppeared)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var otherSessionsSection: some View {
|
private var otherSessionsSection: some View {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user