mirror of
https://github.com/tutao/tutanota.git
synced 2025-10-19 07:53:47 +00:00
Lazy load inboxRuleHandel to prevent null mailModel
Close #9094 Co-authored-by: ivk <ivk@tutao.de>
This commit is contained in:
parent
a76562e5b8
commit
900bd4c16f
3 changed files with 10 additions and 9 deletions
|
@ -90,7 +90,7 @@ export class MailModel {
|
|||
private readonly logins: LoginController,
|
||||
private readonly mailFacade: MailFacade,
|
||||
private readonly connectivityModel: WebsocketConnectivityModel | null,
|
||||
private readonly inboxRuleHandler: InboxRuleHandler | null,
|
||||
private readonly inboxRuleHandler: () => InboxRuleHandler | null,
|
||||
) {}
|
||||
|
||||
// only init listeners once
|
||||
|
@ -175,7 +175,7 @@ export class MailModel {
|
|||
// We only apply rules on server if we are the leader in case of incoming messages
|
||||
return (
|
||||
mailboxDetail &&
|
||||
this.inboxRuleHandler?.findAndApplyMatchingRule(
|
||||
this.inboxRuleHandler()?.findAndApplyMatchingRule(
|
||||
mailboxDetail,
|
||||
mail,
|
||||
this.connectivityModel ? this.connectivityModel.isLeader() : false,
|
||||
|
@ -205,10 +205,11 @@ export class MailModel {
|
|||
}
|
||||
|
||||
async applyInboxRuleToMail(mail: Mail) {
|
||||
if (this.inboxRuleHandler) {
|
||||
const inboxRuleHandler = this.inboxRuleHandler()
|
||||
if (inboxRuleHandler) {
|
||||
const mailboxDetail = await this.getMailboxDetailsForMail(mail)
|
||||
if (mailboxDetail) {
|
||||
this.inboxRuleHandler.findAndApplyMatchingRule(mailboxDetail, mail, true, true)
|
||||
inboxRuleHandler.findAndApplyMatchingRule(mailboxDetail, mail, true, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ class MailLocator implements CommonLocator {
|
|||
conversationViewModelFactory,
|
||||
this.mailOpenedListener,
|
||||
deviceConfig,
|
||||
this.inboxRuleHanlder(),
|
||||
this.inboxRuleHandler(),
|
||||
router,
|
||||
await this.redraw(),
|
||||
)
|
||||
|
@ -282,9 +282,9 @@ class MailLocator implements CommonLocator {
|
|||
return new AffiliateViewModel()
|
||||
})
|
||||
|
||||
inboxRuleHanlder(): InboxRuleHandler {
|
||||
readonly inboxRuleHandler = lazyMemoized(() => {
|
||||
return new InboxRuleHandler(this.mailFacade, this.logins, this.mailModel)
|
||||
}
|
||||
})
|
||||
|
||||
async searchViewModelFactory(): Promise<() => SearchViewModel> {
|
||||
const { SearchViewModel } = await import("../mail-app/search/view/SearchViewModel.js")
|
||||
|
@ -800,7 +800,7 @@ class MailLocator implements CommonLocator {
|
|||
this.logins,
|
||||
this.mailFacade,
|
||||
this.connectivityModel,
|
||||
this.inboxRuleHanlder(),
|
||||
this.inboxRuleHandler,
|
||||
)
|
||||
this.operationProgressTracker = new OperationProgressTracker()
|
||||
this.infoMessageHandler = new InfoMessageHandler((state: SearchIndexStateInfo) => {
|
||||
|
|
|
@ -53,7 +53,7 @@ o.spec("MailModelTest", function () {
|
|||
logins,
|
||||
mailFacade,
|
||||
null,
|
||||
null,
|
||||
() => null,
|
||||
)
|
||||
// not pretty, but works
|
||||
// model.mailboxDetails(mailboxDetails as MailboxDetail[])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue