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

pull/894/head
Morgan Pretty 1 year ago
parent db633e69de
commit 0d4866b2c4

@ -131,7 +131,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
lazy var observation: TargetObservation = ObservationBuilder
.subject(configSubject)
.map { [weak self, dependencies, threadVariant, isNoteToSelf, originalConfig, currentUserIsClosedGroupMember, currentUserIsClosedGroupAdmin] currentConfig -> [SectionModel] in
.compactMap { [weak self] currentConfig -> [SectionModel]? in self?.content(currentConfig) }
private func content(_ currentConfig: DisappearingMessagesConfiguration) -> [SectionModel] {
switch (threadVariant, isNoteToSelf) {
case (.contact, false):
return [
@ -148,12 +150,14 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: {
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -169,7 +173,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
!dependencies[feature: .updatedDisappearingMessages]
)
),
onTap: {
onTap: { [weak self, originalConfig, dependencies] in
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterRead): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
@ -177,7 +181,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
type: .disappearAfterRead, // Default for 1-1
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -206,7 +212,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disappear after read option",
label: "Disappear after read option"
),
onTap: {
onTap: { [weak self, originalConfig, dependencies] in
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterRead): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
@ -214,7 +220,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterRead.seconds,
type: .disappearAfterRead,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -242,7 +250,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disappear after send option",
label: "Disappear after send option"
),
onTap: {
onTap: { [weak self, originalConfig, dependencies] in
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterSend): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
@ -250,7 +258,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.disappearAfterSend.seconds,
type: .disappearAfterSend,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -292,11 +302,13 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Time option",
label: "Time option"
),
onTap: {
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
durationSeconds: duration,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -322,12 +334,14 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: {
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -353,7 +367,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Time 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
@ -395,12 +409,14 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: {
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -419,7 +435,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
isNoteToSelf ||
currentUserIsClosedGroupMember == true
),
onTap: {
onTap: { [weak self, originalConfig, dependencies] in
switch (originalConfig.isEnabled, originalConfig.type) {
case (true, .disappearAfterSend): self?.configSubject.send(originalConfig)
default: self?.configSubject.send(
@ -427,7 +443,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
isEnabled: true,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.legacy.seconds,
type: .disappearAfterSend, // Default for closed group & note to self
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -472,12 +490,14 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Disable disappearing messages (Off option)",
label: "Disable disappearing messages (Off option)"
),
onTap: {
onTap: { [weak self, dependencies] in
self?.configSubject.send(
currentConfig.with(
isEnabled: false,
durationSeconds: DisappearingMessagesConfiguration.DefaultDuration.off.seconds,
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}
@ -508,7 +528,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
identifier: "Time 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
@ -524,7 +544,9 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga
.disappearAfterSend :
nil
),
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs()
lastChangeTimestampMs: SnodeAPI.currentOffsetTimestampMs(
using: dependencies
)
)
)
}

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

@ -22,8 +22,15 @@
}
catch (std::exception& e) {
NSString* what = [NSString stringWithUTF8String: e.what()];
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;
}
catch(...) {

Loading…
Cancel
Save