From da6c407e9fdeeb0cacb341524dd6e68d625d5e5c Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Tue, 14 May 2024 09:51:16 +1000 Subject: [PATCH] Minor tweaks --- Scripts/LintLocalizableStrings.swift | 7 ++++++- ...isappearingMessagesSettingsViewModel.swift | 12 +++++------ .../ConversationTitleView.swift | 20 +++++++++---------- .../MessageReceiver+ExpirationTimers.swift | 9 --------- ...eadDisappearingMessagesViewModelSpec.swift | 17 ++++------------ .../Components/TopBannerController.swift | 4 ++-- 6 files changed, 27 insertions(+), 42 deletions(-) diff --git a/Scripts/LintLocalizableStrings.swift b/Scripts/LintLocalizableStrings.swift index 1eeec6f77..11513fb68 100755 --- a/Scripts/LintLocalizableStrings.swift +++ b/Scripts/LintLocalizableStrings.swift @@ -82,7 +82,8 @@ extension ProjectState { .contains("SQL(", caseSensitive: false), .regex(".*static var databaseTableName: String"), .regex("case .* = "), - .regex("Error.*\\(") + .regex("Error.*\\("), + .belowLineContaining("PreviewProvider") ] } @@ -550,6 +551,7 @@ indirect enum MatchType: Hashable { case containsAnd(String, caseSensitive: Bool, MatchType) case regex(String) case previousLine(numEarlier: Int, MatchType) + case belowLineContaining(String) func matches(_ value: String, _ index: Int, _ lines: [String]) -> Bool { switch self { @@ -583,6 +585,9 @@ indirect enum MatchType: Hashable { let targetIndex: Int = (index - numEarlier) return type.matches(lines[targetIndex], targetIndex, lines) + + case .belowLineContaining(let other): + return lines[0.. = shouldShowConfirmButton @@ -155,7 +156,6 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga (self?.currentSelection.value.type == .disappearAfterRead) } ), - styling: SessionCell.StyleInfo(tintColor: .textPrimary), accessibility: Accessibility( identifier: "Disappear after read option", label: "Disappear after read option" @@ -186,7 +186,6 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga (self?.currentSelection.value.type == .disappearAfterSend) } ), - styling: SessionCell.StyleInfo(tintColor: .textPrimary), accessibility: Accessibility( identifier: "Disappear after send option", label: "Disappear after send option" @@ -302,6 +301,7 @@ class ThreadDisappearingMessagesSettingsViewModel: SessionTableViewModel, Naviga // setting let updatedConfig: DisappearingMessagesConfiguration = currentSelection .with( + isEnabled: true, durationSeconds: duration, type: .disappearAfterSend ) diff --git a/Session/Conversations/Views & Modals/ConversationTitleView.swift b/Session/Conversations/Views & Modals/ConversationTitleView.swift index 068dd6fce..715de9a09 100644 --- a/Session/Conversations/Views & Modals/ConversationTitleView.swift +++ b/Session/Conversations/Views & Modals/ConversationTitleView.swift @@ -228,19 +228,17 @@ final class ConversationTitleView: UIView { height: Values.miniFontSize ) - let disappearingMessageSettingLabelString: NSAttributedString = NSAttributedString(attachment: imageAttachment) - .appending(string: " ") - .appending(string: String( - format: (config.type == .disappearAfterRead ? - "DISAPPERING_MESSAGES_SUMMARY_READ".localized() : - "DISAPPERING_MESSAGES_SUMMARY_SEND".localized() - ), - floor(config.durationSeconds).formatted(format: .short) - )) - labelInfos.append( SessionLabelCarouselView.LabelInfo( - attributedText: disappearingMessageSettingLabelString, + attributedText: NSAttributedString(attachment: imageAttachment) + .appending(string: " ") + .appending(string: String( + format: (config.type == .disappearAfterRead ? + "DISAPPERING_MESSAGES_SUMMARY_READ".localized() : + "DISAPPERING_MESSAGES_SUMMARY_SEND".localized() + ), + floor(config.durationSeconds).formatted(format: .short) + )), accessibility: Accessibility( identifier: "Disappearing messages type and time", label: "Disappearing messages type and time" diff --git a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift index 3be0818ad..44f2c0f5b 100644 --- a/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift +++ b/SessionMessagingKit/Sending & Receiving/Message Handling/MessageReceiver+ExpirationTimers.swift @@ -99,14 +99,5 @@ extension MessageReceiver { db, Contact.Columns.lastKnownClientVersion.set(to: version) ) - - if contactId == getUserHexEncodedPublicKey(db) { - switch version { - case .legacyDisappearingMessages: - TopBannerController.show(warning: .outdatedUserConfig) - case .newDisappearingMessages: - TopBannerController.hide() - } - } } } diff --git a/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift b/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift index 9306d9e13..8ab33f1bf 100644 --- a/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift +++ b/SessionTests/Conversations/Settings/ThreadDisappearingMessagesViewModelSpec.swift @@ -71,18 +71,10 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec { // Should only show one section of Disappearing Messages Type expect(viewModel.tableData.count).to(equal(1)) - if Features.useNewDisappearingMessagesConfig { - // Off - // Disappear After Read - // Disappear After Send - expect(viewModel.tableData.first?.elements.count).to(equal(3)) - } else { - // Off - // Legacy - // Disappear After Read - // Disappear After Send - expect(viewModel.tableData.first?.elements.count).to(equal(4)) - } + // Off + // Disappear After Read + // Disappear After Send + expect(viewModel.tableData.first?.elements.count).to(equal(3)) } // MARK: -- has the correct default state @@ -117,7 +109,6 @@ class ThreadDisappearingMessagesSettingsViewModelSpec: QuickSpec { rightAccessory: .radio( isSelected: { false } ), - isEnabled: Features.useNewDisappearingMessagesConfig, accessibility: Accessibility( identifier: "Disappear after send option", label: "Disappear after send option" diff --git a/SessionUIKit/Components/TopBannerController.swift b/SessionUIKit/Components/TopBannerController.swift index 545171759..9c836884a 100644 --- a/SessionUIKit/Components/TopBannerController.swift +++ b/SessionUIKit/Components/TopBannerController.swift @@ -5,11 +5,11 @@ import SessionUtilitiesKit public class TopBannerController: UIViewController { public enum Warning: String, Codable { - case outdatedUserConfig + case invalid var text: String { switch self { - case .outdatedUserConfig: return "USER_CONFIG_OUTDATED_WARNING".localized() + case .invalid: return "" } } }