Skip to content

Commit

Permalink
Remove selectNone from attributes and inject directly in onDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
murilopereirame authored and charlag committed Feb 26, 2024
1 parent ccd2ffa commit 00c2c7f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/contacts/view/ContactView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,8 @@ export class ContactView extends BaseTopLevelView implements TopLevelView<Contac
contacts,
onEdit: (c) => this.editContact(c),
onExport: exportContacts,
onDelete: deleteContacts,
onDelete: (contacts: Contact[]) => deleteContacts(contacts, () => this.contactViewModel.listModel.selectNone()),
onMerge: confirmMerge,
selectNone: () => this.contactViewModel.listModel.selectNone(),
})
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/contacts/view/ContactViewerActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import { Keys } from "../../api/common/TutanotaConstants.js"
export interface ContactViewToolbarAttrs {
contacts: Contact[]
onEdit: (contact: Contact) => unknown
onDelete: (contacts: Contact[], onConfirm: () => void) => unknown
onDelete: (contacts: Contact[]) => unknown
onMerge: (left: Contact, right: Contact) => unknown
onExport: (contacts: Contact[]) => unknown
selectNone: () => unknown
}

/**
Expand Down Expand Up @@ -55,7 +54,7 @@ export class ContactViewerActions implements Component<ContactViewToolbarAttrs>
actionButtons.push(
m(IconButton, {
title: "delete_action",
click: () => onDelete(contacts, attrs.selectNone),
click: () => onDelete(contacts),
icon: Icons.Trash,
}),
)
Expand Down
6 changes: 2 additions & 4 deletions src/search/view/SearchView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ export class SearchView extends BaseTopLevelView implements TopLevelView<SearchV
onDelete: deleteContacts,
onMerge: confirmMerge,
onExport: exportContacts,
selectNone: noOp,
})
const isMultiselect = this.searchViewModel.listModel?.state.inMultiselect || selectedContacts.length === 0
return m(BackgroundColumnLayout, {
Expand Down Expand Up @@ -480,7 +479,7 @@ export class SearchView extends BaseTopLevelView implements TopLevelView<SearchV
return m(
".flex.col.fill-absolute",
// Using contactViewToolbar because it will display empty
m(ContactViewerActions, { contacts: [], onExport: noOp, onMerge: noOp, onDelete: noOp, onEdit: noOp, selectNone: noOp }),
m(ContactViewerActions, { contacts: [], onExport: noOp, onMerge: noOp, onDelete: noOp, onEdit: noOp }),
m(
".flex-grow.rel.overflow-hidden",
m(ColumnEmptyMessageBox, {
Expand Down Expand Up @@ -600,10 +599,9 @@ export class SearchView extends BaseTopLevelView implements TopLevelView<SearchV
m(ContactViewerActions, {
contacts: this.searchViewModel.getSelectedContacts(),
onEdit: () => new ContactEditor(locator.entityClient, getFirstOrThrow(this.searchViewModel.getSelectedContacts())).show(),
onDelete: deleteContacts,
onDelete: (contacts: Contact[]) => deleteContacts(contacts, () => this.searchViewModel.listModel.selectNone()),
onMerge: confirmMerge,
onExport: exportContacts,
selectNone: () => this.searchViewModel.listModel.selectNone(),
}),
)
}
Expand Down

0 comments on commit 00c2c7f

Please sign in to comment.