Skip to content

Commit

Permalink
Add keyboard shortcut from Labels
Browse files Browse the repository at this point in the history
Keyboard shortcut for labels added in Key "L"

close #8007
  • Loading branch information
BijinDev committed Dec 2, 2024
1 parent 4418e4d commit 66ab2cf
Showing 1 changed file with 35 additions and 3 deletions.
38 changes: 35 additions & 3 deletions src/mail-app/mail/view/MailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Dialog } from "../../../common/gui/base/Dialog"
import { FeatureType, Keys, MailSetKind } from "../../../common/api/common/TutanotaConstants"
import { AppHeaderAttrs, Header } from "../../../common/gui/Header.js"
import type { Mail, MailBox, MailFolder } from "../../../common/api/entities/tutanota/TypeRefs.js"
import { noOp, ofClass } from "@tutao/tutanota-utils"
import { isEmpty, noOp, ofClass } from "@tutao/tutanota-utils"
import { MailListView } from "./MailListView"
import { assertMainOrNode, isApp } from "../../../common/api/common/Env"
import type { Shortcut } from "../../../common/misc/KeyManager"
Expand Down Expand Up @@ -70,6 +70,7 @@ import { ButtonSize } from "../../../common/gui/base/ButtonSize"
import { RowButton } from "../../../common/gui/base/buttons/RowButton"
import { getLabelColor } from "../../../common/gui/base/Label.js"
import { MAIL_PREFIX } from "../../../common/misc/RouteChange"
import { LabelsPopup } from "./LabelsPopup"

assertMainOrNode()

Expand Down Expand Up @@ -233,10 +234,9 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
this.viewSlider.focusedColumn = this.listColumn

const shortcuts = this.getShortcuts()

vnode.attrs.mailViewModel.init()

this.oncreate = () => {
this.oncreate = (vnode) => {
this.countersStream = mailLocator.mailModel.mailboxCounters.map(m.redraw)
keyManager.registerShortcuts(shortcuts)
this.cache.conversationViewPreference = deviceConfig.getConversationViewShowOnlySelectedMail()
Expand Down Expand Up @@ -473,6 +473,14 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
},
help: "move_action",
},
{
key: Keys.L,
exec: () => {
this.labels()
return true
},
help: "labels_label",
},
{
key: Keys.U,
exec: () => {
Expand Down Expand Up @@ -564,6 +572,30 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
showMoveMailsDropdown(locator.mailboxModel, mailLocator.mailModel, getMoveMailBounds(), selectedMails)
}

/**
*Shortcut Method to show Labels dropdown only when atleast one mail is selected.
*/
private labels() {
const mailList = this.mailViewModel.listModel
if (mailList == null) {
return
}

const selectedMails = mailList.getSelectedAsArray()
if (isEmpty(selectedMails)) {
return
}

const popup = new LabelsPopup(
document.activeElement as HTMLElement,
getMoveMailBounds(),
styles.isDesktopLayout() ? 300 : 200,
mailLocator.mailModel.getLabelStatesForMails(selectedMails),
(addedLabels, removedLabels) => mailLocator.mailModel.applyLabels(selectedMails, addedLabels, removedLabels),
)
popup.show()
}

private createFolderColumn(editingFolderForMailGroup: Id | null = null, drawerAttrs: DrawerMenuAttrs) {
return new ViewColumn(
{
Expand Down

0 comments on commit 66ab2cf

Please sign in to comment.