diff --git a/Session/Conversations/ConversationVC+Interaction.swift b/Session/Conversations/ConversationVC+Interaction.swift index 4b3184632..7a673251e 100644 --- a/Session/Conversations/ConversationVC+Interaction.swift +++ b/Session/Conversations/ConversationVC+Interaction.swift @@ -147,9 +147,6 @@ extension ConversationVC: self.viewModel.threadData.threadIsBlocked == true else { return false } - let message = "blockUnblockDescription" - .put(key: "name", value: self.viewModel.threadData.displayName) - .localized() let confirmationModal: ConfirmationModal = ConfirmationModal( info: ConfirmationModal.Info( title: String( @@ -157,11 +154,9 @@ extension ConversationVC: self.viewModel.threadData.displayName ), body: .attributedText( - NSAttributedString(string: message) - .adding( - attributes: [ .font: UIFont.boldSystemFont(ofSize: Values.smallFontSize) ], - range: (message as NSString).range(of: self.viewModel.threadData.displayName) - ) + "blockUnblockDescription" + .put(key: "name", value: self.viewModel.threadData.displayName) + .localizedFormatted(baseFont: .systemFont(ofSize: Values.smallFontSize)) ), confirmTitle: "blockUnblock".localized(), confirmAccessibility: Accessibility(identifier: "Confirm block"), @@ -904,7 +899,7 @@ extension ConversationVC: if messageDisappearingConfig.isEnabled { return "disappearingMessagesFollowSettingOn" .put(key: "time", value: expirationTimerString) - .put(key: "disappearing messages type", value: expirationTypeString) + .put(key: "disappearingmessagestype", value: expirationTypeString) .localized() } else { return "disappearingMessagesFollowSettingOff" diff --git a/Session/Conversations/ConversationViewModel.swift b/Session/Conversations/ConversationViewModel.swift index 46b8258db..a25c8693c 100644 --- a/Session/Conversations/ConversationViewModel.swift +++ b/Session/Conversations/ConversationViewModel.swift @@ -7,7 +7,7 @@ import DifferenceKit import SessionMessagingKit import SessionUtilitiesKit -public class ConversationViewModel: OWSAudioPlayerDelegate { +public class ConversationViewModel: OWSAudioPlayerDelegate, NavigatableStateHolder { public typealias SectionModel = ArraySection // MARK: - FocusBehaviour @@ -46,6 +46,8 @@ public class ConversationViewModel: OWSAudioPlayerDelegate { public static let pageSize: Int = 50 + public let navigatableState: NavigatableState = NavigatableState() + private var threadId: String public let initialThreadVariant: SessionThread.Variant public var sentMessageBeforeUpdate: Bool = false @@ -851,12 +853,23 @@ public class ConversationViewModel: OWSAudioPlayerDelegate { guard self._threadData.wrappedValue.threadVariant == .contact else { return } let threadId: String = self.threadId + let displayName: String = self._threadData.wrappedValue.displayName - Storage.shared.writeAsync { db in - try Contact - .filter(id: threadId) - .updateAllAndConfig(db, Contact.Columns.isBlocked.set(to: false)) - } + Storage.shared.writeAsync( + updates: { db in + try Contact + .filter(id: threadId) + .updateAllAndConfig(db, Contact.Columns.isBlocked.set(to: false)) + }, + completion: { [weak self] _, _ in + self?.showToast( + text: "blockUnblockedUser" + .put(key: "name", value: displayName) + .localized(), + backgroundColor: .backgroundSecondary + ) + } + ) } public func expandReactions(for interactionId: Int64) { diff --git a/Session/Conversations/Settings/ThreadSettingsViewModel.swift b/Session/Conversations/Settings/ThreadSettingsViewModel.swift index 94146bb1b..09c299ab9 100644 --- a/Session/Conversations/Settings/ThreadSettingsViewModel.swift +++ b/Session/Conversations/Settings/ThreadSettingsViewModel.swift @@ -695,10 +695,10 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi ) }(), body: (threadViewModel.threadIsBlocked == true ? .none : - .text( + .attributedText( "blockDescription" .put(key: "name", value: threadViewModel.displayName) - .localized() + .localizedFormatted(baseFont: .systemFont(ofSize: Values.smallFontSize)) ) ), confirmTitle: (threadViewModel.threadIsBlocked == true ? @@ -826,13 +826,29 @@ class ThreadSettingsViewModel: SessionTableViewModel, NavigationItemSource, Navi ) { guard oldBlockedState != isBlocked else { return } - dependencies.storage.writeAsync{ db in - try Contact - .filter(id: threadId) - .updateAllAndConfig( - db, - Contact.Columns.isBlocked.set(to: isBlocked) + dependencies.storage.writeAsync( + updates: { db in + try Contact + .filter(id: threadId) + .updateAllAndConfig( + db, + Contact.Columns.isBlocked.set(to: isBlocked) + ) + }, + completion: { [weak self] _, _ in + self?.showToast( + text: ( + isBlocked ? + "blockBlockedUser" + .put(key: "name", value: displayName) + .localized() : + "blockUnblockedUser" + .put(key: "name", value: displayName) + .localized() + ), + backgroundColor: .backgroundSecondary ) - } + } + ) } } diff --git a/Session/Meta/Translations/en.lproj/Localizable.strings b/Session/Meta/Translations/en.lproj/Localizable.strings index 1e51e6adf..d4e7f6907 100644 --- a/Session/Meta/Translations/en.lproj/Localizable.strings +++ b/Session/Meta/Translations/en.lproj/Localizable.strings @@ -624,11 +624,12 @@ "emojiReactsCoolDown" = "Slow down! You've sent too many emoji reacts. Try again soon."; "disappearingMessagesDescription1" = "This setting applies to messages you send in this conversation."; "disappearingMessagesFollowSetting" = "Follow Setting"; -"disappearingMessagesFollowSettingOn" = "Set your messages to disappear {time} after they have been {disappearing messages type}?"; +"disappearingMessagesFollowSettingOn" = "Set your messages to disappear {time} after they have been {disappearingmessagestype}?"; "disappearingMessagesFollowSettingOff" = "Messages you send will no longer disappear. Are you sure you want to turn off disappearing messages?"; "groupInviteVersion" = "Users must have version {version} or higher to receive invitations"; "blockBlockedUser" = "Blocked {name}"; "blockUnblockedUser" = "Unblocked {name}"; +"contentDescriptionCamera" = "Camera"; // NOT IN THE LIST YET "APP_STARTUP_EXIT" = "Exit";