Added missing accessibility id, added null C exception handling, improved build time

pull/894/head
Morgan Pretty 2 years ago
parent db633e69de
commit 0d4866b2c4

@ -131,185 +131,269 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
lazy var observation: TargetObservation = ObservationBuilder lazy var observation: TargetObservation = ObservationBuilder
.subject(configSubject) .subject(configSubject)
.map { [weak self, dependencies, threadVariant, isNoteToSelf, originalConfig, currentUserIsClosedGroupMember, currentUserIsClosedGroupAdmin] currentConfig -> [SectionModel] in .compactMap { [weak self] currentConfig -> [SectionModel]? in self?.content(currentConfig) }
switch (threadVariant, isNoteToSelf) {
case (.contact, false): private func content(_ currentConfig: DisappearingMessagesConfiguration) -> [SectionModel] {
return [ switch (threadVariant, isNoteToSelf) {
SectionModel( case (.contact, false):
model: .type, return [
elements: [ SectionModel(
SessionCell.Info( model: .type,
id: "DISAPPEARING_MESSAGES_OFF".localized(), elements: [
title: "DISAPPEARING_MESSAGES_OFF".localized(), SessionCell.Info(
trailingAccessory: .radio( id: "DISAPPEARING_MESSAGES_OFF".localized(),
isSelected: !currentConfig.isEnabled title: "DISAPPEARING_MESSAGES_OFF".localized(),
), trailingAccessory: .radio(
accessibility: Accessibility( isSelected: !currentConfig.isEnabled
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: {
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
)
)
}
), ),
(dependencies[feature: .updatedDisappearingMessages] ? nil : accessibility: Accessibility(
SessionCell.Info( identifier: "Disable disappearing messages (Off option)",
id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), label: "Disable disappearing messages (Off option)"
title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(), ),
subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(), onTap: { [weak self, dependencies] in
trailingAccessory: .radio( self?.configSubject.send(
isSelected: ( currentConfig.with(
currentConfig.isEnabled && isEnabled: false,
!dependencies[feature: .updatedDisappearingMessages] durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
) )
), )
onTap: {
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterRead): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
type: .disappearAfterRead, // Default for 1-1
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
)
)
}
}
) )
), }
),
(dependencies[feature: .updatedDisappearingMessages] ? nil :
SessionCell.Info( SessionCell.Info(
id: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(), id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
title: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(), title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_DESCRIPTION".localized(), subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(),
trailingAccessory: .radio( trailingAccessory: .radio(
isSelected: ( isSelected: (
currentConfig.isEnabled && currentConfig.isEnabled &&
currentConfig.type == .disappearAfterRead && !dependencies[feature: .updatedDisappearingMessages]
dependencies[feature: .updatedDisappearingMessages]
)
),
styling: SessionCell.StyleInfo(
tintColor: (dependencies[feature: .updatedDisappearingMessages] ?
.textPrimary :
.disabled
) )
), ),
isEnabled: dependencies[feature: .updatedDisappearingMessages], onTap: { [weak self, originalConfig, dependencies] in
accessibility: Accessibility(
identifier: "Disappear after read option",
label: "Disappear after read option"
),
onTap: {
switch (originalConfig.isEnabled, originalConfig.type) { switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterRead): self?.configSubject.send(originalConfig) case (true, .disappearAfterRead): self?.configSubject.send(originalConfig)
default: self?.configSubject.send( default: self?.configSubject.send(
currentConfig.with( currentConfig.with(
isEnabled: true, isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterRead.seconds, durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
type: .disappearAfterRead, type: .disappearAfterRead, // Default for 1-1
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
) )
) )
} }
} }
)
),
SessionCell.Info(
id: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(),
title: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_TITLE".localized(),
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_READ_DESCRIPTION".localized(),
trailingAccessory: .radio(
isSelected: (
currentConfig.isEnabled &&
currentConfig.type == .disappearAfterRead &&
dependencies[feature: .updatedDisappearingMessages]
)
), ),
SessionCell.Info( styling: SessionCell.StyleInfo(
id: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(), tintColor: (dependencies[feature: .updatedDisappearingMessages] ?
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(), .textPrimary :
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(), .disabled
trailingAccessory: .radio( )
isSelected: ( ),
currentConfig.isEnabled && isEnabled: dependencies[feature: .updatedDisappearingMessages],
currentConfig.type == .disappearAfterSend && accessibility: Accessibility(
dependencies[feature: .updatedDisappearingMessages] identifier: "Disappear after read option",
) label: "Disappear after read option"
), ),
styling: SessionCell.StyleInfo( onTap: { [weak self, originalConfig, dependencies] in
tintColor: (dependencies[feature: .updatedDisappearingMessages] ? switch (originalConfig.isEnabled, originalConfig.type) {
.textPrimary : case (true, .disappearAfterRead): self?.configSubject.send(originalConfig)
.disabled default: self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterRead.seconds,
type: .disappearAfterRead,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
) )
), }
isEnabled: dependencies[feature: .updatedDisappearingMessages], }
accessibility: Accessibility( ),
identifier: "Disappear after send option", SessionCell.Info(
label: "Disappear after send option" id: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
), title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
onTap: { subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
switch (originalConfig.isEnabled, originalConfig.type) { trailingAccessory: .radio(
case (true, .disappearAfterSend): self?.configSubject.send(originalConfig) isSelected: (
default: self?.configSubject.send( currentConfig.isEnabled &&
currentConfig.with( currentConfig.type == .disappearAfterSend &&
isEnabled: true, dependencies[feature: .updatedDisappearingMessages]
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterSend.seconds, )
type: .disappearAfterSend, ),
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() styling: SessionCell.StyleInfo(
tintColor: (dependencies[feature: .updatedDisappearingMessages] ?
.textPrimary :
.disabled
)
),
isEnabled: dependencies[feature: .updatedDisappearingMessages],
accessibility: Accessibility(
identifier: "Disappear after send option",
label: "Disappear after send option"
),
onTap: { [weak self, originalConfig, dependencies] in
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterSend): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterSend.seconds,
type: .disappearAfterSend,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
) )
) )
} )
} }
) }
].compactMap { $0 } )
), ].compactMap { $0 }
(!currentConfig.isEnabled ? nil : ),
SectionModel( (!currentConfig.isEnabled ? nil :
model: { SectionModel(
guard dependencies[feature: .updatedDisappearingMessages] else { return .timerLegacy } model: {
guard dependencies[feature: .updatedDisappearingMessages] else { return .timerLegacy }
return (currentConfig.type == .disappearAfterSend ? return (currentConfig.type == .disappearAfterSend ?
.timerDisappearAfterSend : .timerDisappearAfterSend :
.timerDisappearAfterRead .timerDisappearAfterRead
) )
}(), }(),
elements: DisappearingMessagesConfiguration elements: DisappearingMessagesConfiguration
.validDurationsSeconds({ .validDurationsSeconds({
guard dependencies[feature: .updatedDisappearingMessages] else { guard dependencies[feature: .updatedDisappearingMessages] else {
return .disappearAfterSend return .disappearAfterSend
} }
return (currentConfig.type ?? .disappearAfterSend) return (currentConfig.type ?? .disappearAfterSend)
}(), using: dependencies) }(), using: dependencies)
.map { duration in .map { duration in
let title: String = duration.formatted(format: .long) let title: String = duration.formatted(format: .long)
return SessionCell.Info( return SessionCell.Info(
id: title, id: title,
title: title, title: title,
trailingAccessory: .radio( trailingAccessory: .radio(
isSelected: ( isSelected: (
currentConfig.isEnabled && currentConfig.isEnabled &&
currentConfig.durationSeconds == duration currentConfig.durationSeconds == duration
) )
), ),
accessibility: Accessibility( accessibility: Accessibility(
identifier: "Time option", identifier: "Time option",
label: "Time option" label: "Time option"
), ),
onTap: { onTap: { [weak self, dependencies] in
self?.configSubject.send( self?.configSubject.send(
currentConfig.with( currentConfig.with(
durationSeconds: duration, durationSeconds: duration,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
) )
) )
} )
}
)
}
)
)
].compactMap { $0 }
case (.group, _):
return [
SectionModel(
model: .group,
elements: [
SessionCell.Info(
id: "DISAPPEARING_MESSAGES_OFF".localized(),
title: "DISAPPEARING_MESSAGES_OFF".localized(),
trailingAccessory: .radio(
isSelected: !currentConfig.isEnabled
),
isEnabled: (currentUserIsClosedGroupAdmin == true),
accessibility: Accessibility(
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
) )
} )
}
) )
]
.appending(
contentsOf: DisappearingMessagesConfiguration
.validDurationsSeconds(.disappearAfterSend, using: dependencies)
.map { duration in
let title: String = duration.formatted(format: .long)
return SessionCell.Info(
id: title,
title: title,
trailingAccessory: .radio(
isSelected: (
currentConfig.isEnabled &&
currentConfig.durationSeconds == duration
)
),
isEnabled: (currentUserIsClosedGroupAdmin == true),
accessibility: Accessibility(
identifier: "Time option",
label: "Time option"
),
onTap: { [weak self, dependencies] in
// If the new disappearing messages config feature flag isn't
// enabled then the 'isEnabled' and 'type' values are set via
// the first section so pass `nil` values to keep the existing
// setting
self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: duration,
type: .disappearAfterSend,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
)
}
) )
].compactMap { $0 } )
]
case (.group, _):
return [ case (.legacyGroup, _), (_, true):
return [
(dependencies[feature: .updatedDisappearingMessages] ? nil :
SectionModel( SectionModel(
model: .group, model: .type,
elements: [ elements: [
SessionCell.Info( SessionCell.Info(
id: "DISAPPEARING_MESSAGES_OFF".localized(), id: "DISAPPEARING_MESSAGES_OFF".localized(),
@ -317,70 +401,81 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
trailingAccessory: .radio( trailingAccessory: .radio(
isSelected: !currentConfig.isEnabled isSelected: !currentConfig.isEnabled
), ),
isEnabled: (currentUserIsClosedGroupAdmin == true), isEnabled: (
isNoteToSelf ||
currentUserIsClosedGroupMember == true
),
accessibility: Accessibility( accessibility: Accessibility(
identifier: "Disable disappearing messages (Off option)", identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)" label: "Disable disappearing messages (Off option)"
), ),
onTap: { onTap: { [weak self, dependencies] in
self?.configSubject.send( self?.configSubject.send(
currentConfig.with( currentConfig.with(
isEnabled: false, isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds, durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
) )
) )
} }
) ),
] SessionCell.Info(
.appending( id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
contentsOf: DisappearingMessagesConfiguration title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
.validDurationsSeconds(.disappearAfterSend, using: dependencies) subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(),
.map { duration in trailingAccessory: .radio(
let title: String = duration.formatted(format: .long) isSelected: (
currentConfig.isEnabled &&
return SessionCell.Info( !dependencies[feature: .updatedDisappearingMessages]
id: title, )
title: title, ),
trailingAccessory: .radio( isEnabled: (
isSelected: ( isNoteToSelf ||
currentConfig.isEnabled && currentUserIsClosedGroupMember == true
currentConfig.durationSeconds == duration ),
) onTap: { [weak self, originalConfig, dependencies] in
), switch (originalConfig.isEnabled, originalConfig.type) {
isEnabled: (currentUserIsClosedGroupAdmin == true), case (true, .disappearAfterSend): self?.configSubject.send(originalConfig)
accessibility: Accessibility( default: self?.configSubject.send(
identifier: "Time option", currentConfig.with(
label: "Time option" isEnabled: true,
), durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
onTap: { type: .disappearAfterSend, // Default for closed group & note to self
// If the new disappearing messages config feature flag isn't lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
// enabled then the 'isEnabled' and 'type' values are set via using: dependencies
// the first section so pass `nil` values to keep the existing
// setting
self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: duration,
type: .disappearAfterSend,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
) )
) )
} )
) }
} }
) ),
SessionCell.Info(
id: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
trailingAccessory: .radio(isSelected: false),
styling: SessionCell.StyleInfo(tintColor: .disabled),
isEnabled: false
)
]
) )
] ),
(!dependencies[feature: .updatedDisappearingMessages] && !currentConfig.isEnabled ? nil :
SectionModel(
model: {
guard dependencies[feature: .updatedDisappearingMessages] else {
return (currentConfig.type == .disappearAfterSend ?
.timerDisappearAfterSend :
.timerDisappearAfterRead
)
}
case (.legacyGroup, _), (_, true): return (isNoteToSelf ? .noteToSelf : .group)
return [ }(),
(dependencies[feature: .updatedDisappearingMessages] ? nil : elements: [
SectionModel( (!dependencies[feature: .updatedDisappearingMessages] ? nil :
model: .type,
elements: [
SessionCell.Info( SessionCell.Info(
id: "DISAPPEARING_MESSAGES_OFF".localized(), id: "DISAPPEARING_MESSAGES_OFF".localized(),
title: "DISAPPEARING_MESSAGES_OFF".localized(), title: "DISAPPEARING_MESSAGES_OFF".localized(),
@ -395,150 +490,77 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disable disappearing messages (Off option)", identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)" label: "Disable disappearing messages (Off option)"
), ),
onTap: { onTap: { [weak self, dependencies] in
self?.configSubject.send( self?.configSubject.send(
currentConfig.with( currentConfig.with(
isEnabled: false, isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds, durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
) using: dependencies
)
}
),
SessionCell.Info(
id: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
title: "DISAPPEARING_MESSAGES_TYPE_LEGACY_TITLE".localized(),
subtitle: "DISAPPEARING_MESSAGES_TYPE_LEGACY_DESCRIPTION".localized(),
trailingAccessory: .radio(
isSelected: (
currentConfig.isEnabled &&
!dependencies[feature: .updatedDisappearingMessages]
)
),
isEnabled: (
isNoteToSelf ||
currentUserIsClosedGroupMember == true
),
onTap: {
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterSend): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
currentConfig.with(
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
type: .disappearAfterSend, // Default for closed group & note to self
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
) )
) )
} )
} }
),
SessionCell.Info(
id: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
title: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_TITLE".localized(),
subtitle: "DISAPPERING_MESSAGES_TYPE_AFTER_SEND_DESCRIPTION".localized(),
trailingAccessory: .radio(isSelected: false),
styling: SessionCell.StyleInfo(tintColor: .disabled),
isEnabled: false
) )
] )
) ]
), .compactMap { $0 }
(!dependencies[feature: .updatedDisappearingMessages] && !currentConfig.isEnabled ? nil : .appending(
SectionModel( contentsOf: DisappearingMessagesConfiguration
model: { .validDurationsSeconds(.disappearAfterSend, using: dependencies)
guard dependencies[feature: .updatedDisappearingMessages] else { .map { duration in
return (currentConfig.type == .disappearAfterSend ? let title: String = duration.formatted(format: .long)
.timerDisappearAfterSend :
.timerDisappearAfterRead
)
}
return (isNoteToSelf ? .noteToSelf : .group) return SessionCell.Info(
}(), id: title,
elements: [ title: title,
(!dependencies[feature: .updatedDisappearingMessages] ? nil :
SessionCell.Info(
id: "DISAPPEARING_MESSAGES_OFF".localized(),
title: "DISAPPEARING_MESSAGES_OFF".localized(),
trailingAccessory: .radio( trailingAccessory: .radio(
isSelected: !currentConfig.isEnabled isSelected: (
currentConfig.isEnabled &&
currentConfig.durationSeconds == duration
)
), ),
isEnabled: ( isEnabled: (
isNoteToSelf || isNoteToSelf ||
currentUserIsClosedGroupMember == true currentUserIsClosedGroupMember == true
), ),
accessibility: Accessibility( accessibility: Accessibility(
identifier: "Disable disappearing messages (Off option)", identifier: "Time option",
label: "Disable disappearing messages (Off option)" label: "Time option"
), ),
onTap: { onTap: { [weak self, dependencies] in
// If the new disappearing messages config feature flag isn't
// enabled then the 'isEnabled' and 'type' values are set via
// the first section so pass `nil` values to keep the existing
// setting
self?.configSubject.send( self?.configSubject.send(
currentConfig.with( currentConfig.with(
isEnabled: false, isEnabled: (dependencies[feature: .updatedDisappearingMessages] ?
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds, true :
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs() nil
),
durationSeconds: duration,
type: (dependencies[feature: .updatedDisappearingMessages] ?
.disappearAfterSend :
nil
),
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
) )
) )
} }
) )
) }
]
.compactMap { $0 }
.appending(
contentsOf: DisappearingMessagesConfiguration
.validDurationsSeconds(.disappearAfterSend, using: dependencies)
.map { duration in
let title: String = duration.formatted(format: .long)
return SessionCell.Info(
id: title,
title: title,
trailingAccessory: .radio(
isSelected: (
currentConfig.isEnabled &&
currentConfig.durationSeconds == duration
)
),
isEnabled: (
isNoteToSelf ||
currentUserIsClosedGroupMember == true
),
accessibility: Accessibility(
identifier: "Time option",
label: "Time option"
),
onTap: {
// If the new disappearing messages config feature flag isn't
// enabled then the 'isEnabled' and 'type' values are set via
// the first section so pass `nil` values to keep the existing
// setting
self?.configSubject.send(
currentConfig.with(
isEnabled: (dependencies[feature: .updatedDisappearingMessages] ?
true :
nil
),
durationSeconds: duration,
type: (dependencies[feature: .updatedDisappearingMessages] ?
.disappearAfterSend :
nil
),
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
)
)
}
)
}
)
) )
) )
].compactMap { $0 } )
].compactMap { $0 }
case (.community, _): case (.community, _):
return [] // Should not happen return [] // Should not happen
}
} }
}
// MARK: - Functions // MARK: - Functions

@ -118,6 +118,10 @@ class UserListViewModel<T: ProfileAssociated & FetchableRecord>: SessionTableVie
let finalAction: OnTapAction = finalAction(for: onTapAction) let finalAction: OnTapAction = finalAction(for: onTapAction)
let trailingAccessory: SessionCell.Accessory? = generateAccessory(finalAction) let trailingAccessory: SessionCell.Accessory? = generateAccessory(finalAction)
let title: String = (
userInfo.profile?.displayName() ??
Profile.truncated(id: userInfo.profileId, truncating: .middle)
)
return SessionCell.Info( return SessionCell.Info(
id: .user(userInfo.profileId), id: .user(userInfo.profileId),
@ -126,10 +130,7 @@ class UserListViewModel<T: ProfileAssociated & FetchableRecord>: SessionTableVie
profile: userInfo.profile, profile: userInfo.profile,
profileIcon: (showProfileIcons ? userInfo.value.profileIcon : .none) profileIcon: (showProfileIcons ? userInfo.value.profileIcon : .none)
), ),
title: ( title: title,
userInfo.profile?.displayName() ??
Profile.truncated(id: userInfo.profileId, truncating: .middle)
),
subtitle: userInfo.itemDescription(using: dependencies), subtitle: userInfo.itemDescription(using: dependencies),
trailingAccessory: trailingAccessory, trailingAccessory: trailingAccessory,
styling: SessionCell.StyleInfo( styling: SessionCell.StyleInfo(
@ -141,6 +142,10 @@ class UserListViewModel<T: ProfileAssociated & FetchableRecord>: SessionTableVie
), ),
backgroundStyle: .noBackgroundEdgeToEdge backgroundStyle: .noBackgroundEdgeToEdge
), ),
accessibility: Accessibility(
identifier: "Contact",
label: title
),
onTap: { onTap: {
// Trigger any 'onTap' actions // Trigger any 'onTap' actions
switch finalAction { switch finalAction {

@ -22,8 +22,15 @@
} }
catch (std::exception& e) { catch (std::exception& e) {
NSString* what = [NSString stringWithUTF8String: e.what()]; NSString* what = [NSString stringWithUTF8String: e.what()];
NSDictionary* userInfo = @{NSLocalizedDescriptionKey : what};
*error = [[NSError alloc] initWithDomain:@"cpp_exception" code:-2 userInfo:userInfo]; if (what != nil) {
NSDictionary* userInfo = @{NSLocalizedDescriptionKey : what};
*error = [[NSError alloc] initWithDomain:@"cpp_exception" code:-2 userInfo:userInfo];
}
else {
NSDictionary* userInfo = @{NSLocalizedDescriptionKey : @"unknown exception"};
*error = [[NSError alloc] initWithDomain:@"cpp_exception" code:-2 userInfo:userInfo];
}
return NO; return NO;
} }
catch(...) { catch(...) {

Loading…
Cancel
Save