Skip to content

Commit

Permalink
Show mails with currently selected label
Browse files Browse the repository at this point in the history
Close #7760

Co-authored-by: paw-hub <paw-hub@users.noreply.github.com>
  • Loading branch information
hrb-hub and paw-hub committed Nov 6, 2024
1 parent 98c4428 commit ab0ab70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/mail-app/mail/model/MailModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,13 +601,18 @@ export class MailModel {
await this.mailFacade.deleteLabel(label)
}

async getFolderById(folderElementId: Id): Promise<MailFolder | null> {
async getSetById(folderElementId: Id): Promise<MailFolder | null> {
const folderStructures = await this.loadMailSets()
for (const folders of folderStructures.values()) {
const folder = folders.folders.getFolderById(folderElementId)
if (folder) {
return folder
}

const label = folders.labels.get(folderElementId)
if (label) {
return label
}
}
return null
}
Expand Down
13 changes: 8 additions & 5 deletions src/mail-app/mail/view/MailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import { attachDropdown } from "../../../common/gui/base/Dropdown"
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"

assertMainOrNode()

Expand Down Expand Up @@ -695,7 +696,7 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
}

private showMail(args: Record<string, any>) {
this.mailViewModel.showMailWithFolderId(args.folderId, args.mailId)
this.mailViewModel.showMailWithSetId(args.folderId, args.mailId)
if (styles.isSingleColumnLayout() && !args.mailId && this.viewSlider.focusedColumn === this.mailColumn) {
this.viewSlider.focus(this.listColumn)
}
Expand Down Expand Up @@ -811,10 +812,12 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
icon: Icons.Label,
iconColor: getLabelColor(label.color),
label: () => label.name,
// FIXME
path: "#",
// FIXME
onClick: noOp,
path: `${MAIL_PREFIX}/${getElementId(label)}`,
onClick: () => {
if (!inEditMode) {
this.viewSlider.focus(this.listColumn)
}
},
alwaysShowMoreButton: inEditMode,
moreButton: attachDropdown({
mainButtonAttrs: {
Expand Down
10 changes: 5 additions & 5 deletions src/mail-app/mail/view/MailViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ export class MailViewModel {
this.listModel?.setFilter(getMailFilterForType(filter))
}

async showMailWithFolderId(folderId?: Id, mailId?: Id): Promise<void> {
if (folderId) {
const folder = await this.mailModel.getFolderById(folderId)
if (folder) {
return this.showMail(folder, mailId)
async showMailWithSetId(mailsetId?: Id, mailId?: Id): Promise<void> {
if (mailsetId) {
const mailset = await this.mailModel.getSetById(mailsetId)
if (mailset) {
return this.showMail(mailset, mailId)
}
}
return this.showMail(null, mailId)
Expand Down
2 changes: 1 addition & 1 deletion src/mail-app/search/view/SearchViewModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ export class SearchViewModel {
const selectedMailFolder = this._selectedMailFolder

if (selectedMailFolder[0]) {
const mailFolder = await mailLocator.mailModel.getFolderById(selectedMailFolder[0])
const mailFolder = await mailLocator.mailModel.getSetById(selectedMailFolder[0])
if (!mailFolder) {
const folderSystem = assertNotNull(mailLocator.mailModel.getFolderSystemByGroupId(mailboxes[0].mailGroup._id))
this._selectedMailFolder = [getElementId(assertNotNull(folderSystem.getSystemFolderByType(MailSetKind.INBOX)))]
Expand Down

0 comments on commit ab0ab70

Please sign in to comment.