add block/unblock toast

pull/1023/head
Ryan ZHAO 1 year ago
parent 1904a795b8
commit 1358bc2648

@ -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"

@ -7,7 +7,7 @@ import DifferenceKit
import SessionMessagingKit
import SessionUtilitiesKit
public class ConversationViewModel: OWSAudioPlayerDelegate {
public class ConversationViewModel: OWSAudioPlayerDelegate, NavigatableStateHolder {
public typealias SectionModel = ArraySection<Section, MessageViewModel>
// 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) {

@ -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
)
}
}
)
}
}

@ -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 <b>{time}</b> after they have been <b>{disappearing messages type}</b>?";
"disappearingMessagesFollowSettingOn" = "Set your messages to disappear <b>{time}</b> after they have been <b>{disappearingmessagestype}</b>?";
"disappearingMessagesFollowSettingOff" = "Messages you send will no longer disappear. Are you sure you want to turn <b>off</b> 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";

Loading…
Cancel
Save