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 mute.themeBackgroundColor = .conversationButton_swipeSecondary
switch threadViewModel.threadVariant { switch (threadViewModel.threadVariant, threadViewModel.currentUserIsClosedGroupMember) {
case .contact: case (.contact, _):
let delete: UIContextualAction = UIContextualAction( let delete: UIContextualAction = UIContextualAction(
title: "TXT_DELETE_TITLE".localized(), title: "TXT_DELETE_TITLE".localized(),
icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)), 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 ]) return UISwipeActionsConfiguration(actions: [ delete, mute, pin ])
case .openGroup, .closedGroup: case (.closedGroup, false):
if threadViewModel.currentUserIsClosedGroupMember == false { let delete: UIContextualAction = UIContextualAction(
let delete: UIContextualAction = UIContextualAction( title: "TXT_DELETE_TITLE".localized(),
title: "TXT_DELETE_TITLE".localized(), icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)),
icon: UIImage(named: "icon_bin")?.resizedImage(to: CGSize(width: Values.mediumFontSize, height: Values.mediumFontSize)), iconHeight: Values.mediumFontSize,
iconHeight: Values.mediumFontSize, themeTintColor: .white,
themeTintColor: .white, themeBackgroundColor: .conversationButton_swipeDestructive,
themeBackgroundColor: .conversationButton_swipeDestructive, side: .trailing,
side: .trailing, actionIndex: 2,
actionIndex: 2, indexPath: indexPath,
indexPath: indexPath, tableView: tableView
tableView: tableView ) { [weak self] _, _, completionHandler in
) { [weak self] _, _, completionHandler in self?.viewModel.delete(
self?.viewModel.delete( threadId: threadViewModel.threadId,
threadId: threadViewModel.threadId, threadVariant: threadViewModel.threadVariant,
threadVariant: threadViewModel.threadVariant, force: true
force: true )
)
completionHandler(true)
}
return UISwipeActionsConfiguration(actions: [ delete, mute, pin ]) completionHandler(true)
} }
return UISwipeActionsConfiguration(actions: [ delete, mute, pin ])
default:
let leave: UIContextualAction = UIContextualAction( let leave: UIContextualAction = UIContextualAction(
title: "LEAVE_BUTTON_TITLE".localized(), title: "LEAVE_BUTTON_TITLE".localized(),
icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"), icon: UIImage(systemName: "rectangle.portrait.and.arrow.right"),

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

Loading…
Cancel
Save