pull/799/head
ryanzhao 2 years ago
parent 60b931b32a
commit c101f61473

@ -708,8 +708,8 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi
}
mute.themeBackgroundColor = .conversationButton_swipeSecondary
switch threadViewModel.threadVariant {
case .contact:
switch (threadViewModel.threadVariant, threadViewModel.currentUserIsClosedGroupMember) {
case (.contact, _):
let delete: UIContextualAction = UIContextualAction(
title: "TXT_DELETE_TITLE".localized(),
icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)),
@ -763,31 +763,30 @@ final class HomeVC: BaseVC, UITableViewDataSource, UITableViewDelegate, SeedRemi
return UISwipeActionsConfiguration(actions: [ delete, mute, pin ])
case .openGroup, .closedGroup:
if threadViewModel.currentUserIsClosedGroupMember == false {
let delete: UIContextualAction = UIContextualAction(
title: "TXT_DELETE_TITLE".localized(),
icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)),
iconHeight: Values.mediumFontSize,
themeTintColor: .white,
themeBackgroundColor: .conversationButton_swipeDestructive,
side: .trailing,
actionIndex: 2,
indexPath: indexPath,
tableView: tableView
) { [weak self] _, _, completionHandler in
self?.viewModel.delete(
threadId: threadViewModel.threadId,
threadVariant: threadViewModel.threadVariant,
force: true
)
completionHandler(true)
}
case (.closedGroup, false):
let delete: UIContextualAction = UIContextualAction(
title: "TXT_DELETE_TITLE".localized(),
icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)),
iconHeight: Values.mediumFontSize,
themeTintColor: .white,
themeBackgroundColor: .conversationButton_swipeDestructive,
side: .trailing,
actionIndex: 2,
indexPath: indexPath,
tableView: tableView
) { [weak self] _, _, completionHandler in
self?.viewModel.delete(
threadId: threadViewModel.threadId,
threadVariant: threadViewModel.threadVariant,
force: true
)
return UISwipeActionsConfiguration(actions: [ delete, mute, pin ])
completionHandler(true)
}
return UISwipeActionsConfiguration(actions: [ delete, mute, pin ])
default:
let leave: UIContextualAction = UIContextualAction(
title: "LEAVE_BUTTON_TITLE".localized(),
icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"),

@ -310,21 +310,16 @@ public class HomeViewModel {
}
Storage.shared.writeAsync { db in
switch threadVariant {
case .closedGroup:
if force {
try delete(db, threadId: threadId)
} else {
try MessageSender.leave(
db,
groupPublicKey: threadId,
deleteThread: true
)
}
switch (threadVariant, force) {
case (.closedGroup, false):
try MessageSender.leave(
db,
groupPublicKey: threadId,
deleteThread: true
)
case .openGroup:
case (.openGroup, _):
OpenGroupManager.shared.delete(db, openGroupId: threadId)
try delete(db, threadId: threadId)
default:
try delete(db, threadId: threadId)

Loading…
Cancel
Save