Merge remote-tracking branch 'upstream/dev' into feature/updated-user-config-handling

# Conflicts:
#	Session/Conversations/Settings/ThreadDisappearingMessagesSettingsViewModel.swift
This commit is contained in:
Morgan Pretty 2023-04-21 16:36:11 +10:00
commit 0e1dea8f62
12 changed files with 108 additions and 65 deletions

View File

@ -6365,7 +6365,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -6389,7 +6389,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.ShareExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -6437,7 +6437,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO;
@ -6466,7 +6466,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.ShareExtension";
PRODUCT_NAME = "$(TARGET_NAME)";
@ -6502,7 +6502,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
@ -6525,7 +6525,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.NotificationServiceExtension";
@ -6576,7 +6576,7 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = SUQ8J2PCT7;
ENABLE_NS_ASSERTIONS = NO;
@ -6604,7 +6604,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger.NotificationServiceExtension";
@ -7484,7 +7484,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -7522,7 +7522,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
OTHER_LDFLAGS = "$(inherited)";
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
@ -7555,7 +7555,7 @@
CODE_SIGN_ENTITLEMENTS = Session/Meta/Signal.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 401;
CURRENT_PROJECT_VERSION = 404;
DEVELOPMENT_TEAM = SUQ8J2PCT7;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -7593,7 +7593,7 @@
"$(SRCROOT)",
);
LLVM_LTO = NO;
MARKETING_VERSION = 2.2.12;
MARKETING_VERSION = 2.2.13;
OTHER_LDFLAGS = "$(inherited)";
PRODUCT_BUNDLE_IDENTIFIER = "com.loki-project.loki-messenger";
PRODUCT_NAME = Session;

View File

@ -97,8 +97,13 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel<ThreadD
/// this is due to the behaviour of `ValueConcurrentObserver.asyncStartObservation` which triggers it's own
/// fetch (after the ones in `ValueConcurrentObserver.asyncStart`/`ValueConcurrentObserver.syncStart`)
/// just in case the database has changed between the two reads - unfortunately it doesn't look like there is a way to prevent this
private lazy var _observableTableData: ObservableData = ValueObservation
.trackingConstantRegion { [weak self, config] db -> [SectionModel] in
private lazy var _observableSettingsData: ObservableData = ValueObservation
.trackingConstantRegion { [weak self, config, dependencies, threadId = self.threadId] db -> [SectionModel] in
let userPublicKey: String = getUserHexEncodedPublicKey(db, dependencies: dependencies)
let maybeThreadViewModel: SessionThreadViewModel? = try SessionThreadViewModel
.conversationSettingsQuery(threadId: threadId, userPublicKey: userPublicKey)
.fetchOne(db)
return [
SectionModel(
model: .content,
@ -109,6 +114,10 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel<ThreadD
rightAccessory: .radio(
isSelected: { (self?.currentSelection.value == 0) }
),
isEnabled: (
maybeThreadViewModel?.threadVariant != .closedGroup ||
maybeThreadViewModel?.currentUserIsClosedGroupMember == true
),
onTap: { self?.currentSelection.send(0) }
)
].appending(
@ -122,6 +131,10 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel<ThreadD
rightAccessory: .radio(
isSelected: { (self?.currentSelection.value == duration) }
),
isEnabled: (
maybeThreadViewModel?.threadVariant != .closedGroup ||
maybeThreadViewModel?.currentUserIsClosedGroupMember == true
),
onTap: { self?.currentSelection.send(duration) }
)
}

View File

@ -84,21 +84,19 @@
</dict>
</dict>
<key>NSAppleMusicUsageDescription</key>
<string>Signal needs to use Apple Music to play media attachments.</string>
<string>Session needs to use Apple Music to play media attachments.</string>
<key>NSCameraUsageDescription</key>
<string>Session needs camera access to take pictures and scan QR codes.</string>
<key>NSContactsUsageDescription</key>
<string>Signal uses your contacts to find users you know. We do not store your contacts on the server.</string>
<key>NSFaceIDUsageDescription</key>
<string>Session's Screen Lock feature uses Face ID.</string>
<key>NSHumanReadableCopyright</key>
<string>com.loki-project.loki-messenger</string>
<key>NSMicrophoneUsageDescription</key>
<string>Session needs access to your microphone to record media.</string>
<string>Session needs access to your microphone for calls and to send to audio messages.</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Session needs access to your library to save photos.</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Session needs access to your library to send photos.</string>
<string>Session needs access to your library to update your avatar and send photos.</string>
<key>PHPhotoLibraryPreventAutomaticLimitedAccessAlert</key>
<true/>
<key>UIAppFonts</key>

View File

@ -4,19 +4,6 @@
<dict>
<key>aps-environment</key>
<string>production</string>
<key>com.apple.developer.icloud-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>
</array>
<key>com.apple.developer.icloud-services</key>
<array>
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.$(CFBundleIdentifier)</string>
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.loki-project.loki-messenger</string>

View File

@ -408,20 +408,34 @@ extension SessionCell {
let wasOldSelection: Bool = (!isSelected && storedSelection)
radioBorderView.isHidden = false
radioBorderView.themeBorderColor = (isSelected ?
.radioButton_selectedBorder :
.radioButton_unselectedBorder
)
radioBorderView.themeBorderColor = {
guard isEnabled else { return .radioButton_disabledBorder }
return (isSelected ?
.radioButton_selectedBorder :
.radioButton_unselectedBorder
)
}()
radioBorderView.layer.cornerRadius = (size.borderSize / 2)
radioView.accessibilityIdentifier = accessibility?.identifier
radioView.accessibilityLabel = accessibility?.label
radioView.alpha = (wasOldSelection ? 0.3 : 1)
radioView.isHidden = (!isSelected && !storedSelection)
radioView.themeBackgroundColor = (isSelected || wasOldSelection ?
.radioButton_selectedBackground :
.radioButton_unselectedBackground
)
radioView.themeBackgroundColor = {
guard isEnabled else {
return (isSelected || wasOldSelection ?
.radioButton_disabledSelectedBackground :
.radioButton_disabledUnselectedBackground
)
}
return (isSelected || wasOldSelection ?
.radioButton_selectedBackground :
.radioButton_unselectedBackground
)
}()
radioView.layer.cornerRadius = (size.selectionSize / 2)
radioViewWidthConstraint.constant = size.selectionSize

View File

@ -639,11 +639,11 @@ public extension SessionThreadViewModel {
WHERE (
\(recipientState[.interactionId]) = \(interaction[.id]) AND
-- Ignore 'skipped' states
\(SQL("\(recipientState[.state]) = \(RecipientState.State.sending)"))
\(SQL("\(recipientState[.state]) != \(RecipientState.State.skipped)"))
)
LIMIT 1
), 0) AS \(ViewModel.interactionStateKey),
), \(SQL("\(RecipientState.State.sending)"))) AS \(ViewModel.interactionStateKey),
(\(readReceiptTableLiteral).\(readReceiptReadTimestampMsColumnLiteral) IS NOT NULL) AS \(ViewModel.interactionHasAtLeastOneReadReceiptKey),
(\(linkPreview[.url]) IS NOT NULL) AS \(ViewModel.interactionIsOpenGroupInvitationKey),
@ -967,10 +967,6 @@ public extension SessionThreadViewModel {
let profileIdColumnLiteral: SQL = SQL(stringLiteral: Profile.Columns.id.name)
let groupMemberProfileIdColumnLiteral: SQL = SQL(stringLiteral: GroupMember.Columns.profileId.name)
let groupMemberRoleColumnLiteral: SQL = SQL(stringLiteral: GroupMember.Columns.role.name)
let groupMemberGroupIdColumnLiteral: SQL = SQL(stringLiteral: GroupMember.Columns.groupId.name)
/// **Note:** The `numColumnsBeforeProfiles` value **MUST** match the number of fields before
/// the `ViewModel.contactProfileKey` entry below otherwise the query will fail to
/// parse and might throw
@ -997,8 +993,27 @@ public extension SessionThreadViewModel {
\(ViewModel.closedGroupProfileBackFallbackKey).*,
\(closedGroup[.name]) AS \(ViewModel.closedGroupNameKey),
(\(ViewModel.currentUserIsClosedGroupMemberKey).profileId IS NOT NULL) AS \(ViewModel.currentUserIsClosedGroupMemberKey),
(\(ViewModel.currentUserIsClosedGroupAdminKey).profileId IS NOT NULL) AS \(ViewModel.currentUserIsClosedGroupAdminKey),
EXISTS (
SELECT 1
FROM \(GroupMember.self)
WHERE (
\(groupMember[.groupId]) = \(closedGroup[.threadId]) AND
\(SQL("\(groupMember[.role]) != \(GroupMember.Role.zombie)")) AND
\(SQL("\(groupMember[.profileId]) = \(userPublicKey)"))
)
) AS \(ViewModel.currentUserIsClosedGroupMemberKey),
EXISTS (
SELECT 1
FROM \(GroupMember.self)
WHERE (
\(groupMember[.groupId]) = \(closedGroup[.threadId]) AND
\(SQL("\(groupMember[.role]) = \(GroupMember.Role.admin)")) AND
\(SQL("\(groupMember[.profileId]) = \(userPublicKey)"))
)
) AS \(ViewModel.currentUserIsClosedGroupAdminKey),
\(openGroup[.name]) AS \(ViewModel.openGroupNameKey),
\(openGroup[.server]) AS \(ViewModel.openGroupServerKey),
\(openGroup[.roomToken]) AS \(ViewModel.openGroupRoomTokenKey),
@ -1012,16 +1027,6 @@ public extension SessionThreadViewModel {
LEFT JOIN \(Profile.self) AS \(ViewModel.contactProfileKey) ON \(ViewModel.contactProfileKey).\(profileIdColumnLiteral) = \(thread[.id])
LEFT JOIN \(OpenGroup.self) ON \(openGroup[.threadId]) = \(thread[.id])
LEFT JOIN \(ClosedGroup.self) ON \(closedGroup[.threadId]) = \(thread[.id])
LEFT JOIN \(GroupMember.self) AS \(ViewModel.currentUserIsClosedGroupMemberKey) ON (
\(SQL("\(ViewModel.currentUserIsClosedGroupMemberKey).\(groupMemberRoleColumnLiteral) != \(GroupMember.Role.zombie)")) AND
\(ViewModel.currentUserIsClosedGroupMemberKey).\(groupMemberGroupIdColumnLiteral) = \(closedGroup[.threadId]) AND
\(SQL("\(ViewModel.currentUserIsClosedGroupMemberKey).\(groupMemberProfileIdColumnLiteral) = \(userPublicKey)"))
)
LEFT JOIN \(GroupMember.self) AS \(ViewModel.currentUserIsClosedGroupAdminKey) ON (
\(SQL("\(ViewModel.currentUserIsClosedGroupAdminKey).\(groupMemberRoleColumnLiteral) = \(GroupMember.Role.admin)")) AND
\(ViewModel.currentUserIsClosedGroupAdminKey).\(groupMemberGroupIdColumnLiteral) = \(closedGroup[.threadId]) AND
\(SQL("\(ViewModel.currentUserIsClosedGroupAdminKey).\(groupMemberProfileIdColumnLiteral) = \(userPublicKey)"))
)
LEFT JOIN \(Profile.self) AS \(ViewModel.closedGroupProfileFrontKey) ON (
\(ViewModel.closedGroupProfileFrontKey).\(profileIdColumnLiteral) = (
@ -1029,8 +1034,8 @@ public extension SessionThreadViewModel {
FROM \(GroupMember.self)
JOIN \(Profile.self) ON \(profile[.id]) = \(groupMember[.profileId])
WHERE (
\(SQL("\(groupMember[.role]) = \(GroupMember.Role.standard)")) AND
\(groupMember[.groupId]) = \(closedGroup[.threadId]) AND
\(SQL("\(groupMember[.role]) = \(GroupMember.Role.standard)")) AND
\(SQL("\(groupMember[.profileId]) != \(userPublicKey)"))
)
)
@ -1042,8 +1047,8 @@ public extension SessionThreadViewModel {
FROM \(GroupMember.self)
JOIN \(Profile.self) ON \(profile[.id]) = \(groupMember[.profileId])
WHERE (
\(SQL("\(groupMember[.role]) = \(GroupMember.Role.standard)")) AND
\(groupMember[.groupId]) = \(closedGroup[.threadId]) AND
\(SQL("\(groupMember[.role]) = \(GroupMember.Role.standard)")) AND
\(SQL("\(groupMember[.profileId]) != \(userPublicKey)"))
)
)
@ -1683,6 +1688,7 @@ public extension SessionThreadViewModel {
let profile: TypedTableAlias<Profile> = TypedTableAlias()
let interaction: TypedTableAlias<Interaction> = TypedTableAlias()
let aggregateInteractionLiteral: SQL = SQL(stringLiteral: "aggregateInteraction")
let profileIdColumnLiteral: SQL = SQL(stringLiteral: Profile.Columns.id.name)
/// **Note:** The `numColumnsBeforeProfiles` value **MUST** match the number of fields before
@ -1716,11 +1722,21 @@ public extension SessionThreadViewModel {
FROM \(SessionThread.self)
LEFT JOIN \(Contact.self) ON \(contact[.id]) = \(thread[.id])
LEFT JOIN (
SELECT \(interaction[.threadId]), MAX(\(interaction[.timestampMs]))
SELECT
\(interaction[.id]) AS \(ViewModel.interactionIdKey),
\(interaction[.threadId]) AS \(ViewModel.threadIdKey),
MAX(\(interaction[.timestampMs]))
FROM \(Interaction.self)
WHERE \(SQL("\(interaction[.variant]) != \(Interaction.Variant.standardIncomingDeleted)"))
GROUP BY \(interaction[.threadId])
) AS \(Interaction.self) ON \(interaction[.threadId]) = \(thread[.id])
) AS \(aggregateInteractionLiteral) ON \(aggregateInteractionLiteral).\(ViewModel.threadIdKey) = \(thread[.id])
LEFT JOIN \(Interaction.self) ON (
\(interaction[.threadId]) = \(thread[.id]) AND
\(interaction[.id]) = \(aggregateInteractionLiteral).\(ViewModel.interactionIdKey)
)
LEFT JOIN \(Profile.self) AS \(ViewModel.contactProfileKey) ON \(ViewModel.contactProfileKey).\(profileIdColumnLiteral) = \(thread[.id])
LEFT JOIN \(ClosedGroup.self) ON \(closedGroup[.threadId]) = \(thread[.id])
LEFT JOIN \(OpenGroup.self) ON \(openGroup[.threadId]) = \(thread[.id])

View File

@ -48,6 +48,9 @@ internal enum Theme_ClassicDark: ThemeColors {
.radioButton_unselectedBackground: .clear,
.radioButton_selectedBorder: .classicDark6,
.radioButton_unselectedBorder: .classicDark6,
.radioButton_disabledSelectedBackground: .disabledDark,
.radioButton_disabledUnselectedBackground: .clear,
.radioButton_disabledBorder: .disabledDark,
// SessionButton
.sessionButton_text: .primary,

View File

@ -48,6 +48,9 @@ internal enum Theme_ClassicLight: ThemeColors {
.radioButton_unselectedBackground: .clear,
.radioButton_selectedBorder: .classicLight0,
.radioButton_unselectedBorder: .classicLight0,
.radioButton_disabledSelectedBackground: .disabledLight,
.radioButton_disabledUnselectedBackground: .clear,
.radioButton_disabledBorder: .disabledLight,
// OutlineButton
.sessionButton_text: .classicLight0,

View File

@ -44,8 +44,8 @@ internal extension UIColor {
static let warning: UIColor = #colorLiteral(red: 0.9882352941, green: 0.6941176471, blue: 0.3490196078, alpha: 1) // #FCB159
static let dangerDark: UIColor = #colorLiteral(red: 1, green: 0.2274509804, blue: 0.2274509804, alpha: 1) // #FF3A3A
static let dangerLight: UIColor = #colorLiteral(red: 0.8823529412, green: 0.1764705882, blue: 0.09803921569, alpha: 1) // #E12D19
static let disabledDark: UIColor = #colorLiteral(red: 0.631372549, green: 0.6352941176, blue: 0.631372549, alpha: 1) // #A1A2A1
static let disabledLight: UIColor = #colorLiteral(red: 0.4274509804, green: 0.4274509804, blue: 0.4274509804, alpha: 1) // #6D6D6D
static let disabledDark: UIColor = #colorLiteral(red: 0.4274509804, green: 0.4274509804, blue: 0.4274509804, alpha: 1 ) // #6D6D6D
static let disabledLight: UIColor = #colorLiteral(red: 0.631372549, green: 0.6352941176, blue: 0.631372549, alpha: 1) // #A1A2A1
static let black_06: UIColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0.06) // #000000
static let pathConnected: UIColor = #colorLiteral(red: 0.1921568627, green: 0.9450980392, blue: 0.5882352941, alpha: 1) // #31F196

View File

@ -48,6 +48,9 @@ internal enum Theme_OceanDark: ThemeColors {
.radioButton_unselectedBackground: .clear,
.radioButton_selectedBorder: .oceanDark7,
.radioButton_unselectedBorder: .oceanDark7,
.radioButton_disabledSelectedBackground: .disabledDark,
.radioButton_disabledUnselectedBackground: .clear,
.radioButton_disabledBorder: .disabledDark,
// SessionButton
.sessionButton_text: .primary,

View File

@ -48,6 +48,9 @@ internal enum Theme_OceanLight: ThemeColors {
.radioButton_unselectedBackground: .clear,
.radioButton_selectedBorder: .oceanLight1,
.radioButton_unselectedBorder: .oceanLight3,
.radioButton_disabledSelectedBackground: .disabledLight,
.radioButton_disabledUnselectedBackground: .clear,
.radioButton_disabledBorder: .disabledLight,
// SessionButton
.sessionButton_text: .oceanLight1,

View File

@ -136,6 +136,9 @@ public indirect enum ThemeValue: Hashable {
case radioButton_unselectedBackground
case radioButton_selectedBorder
case radioButton_unselectedBorder
case radioButton_disabledSelectedBackground
case radioButton_disabledUnselectedBackground
case radioButton_disabledBorder
// SessionButton
case sessionButton_text