Skip to content

Commit

Permalink
Move usageTestController initialization to before nativeInterfaces
Browse files Browse the repository at this point in the history
We were using usageTestController before it was being initialized, and
this broke some things that depend on usage tests, such as the
App Password unlock method (when setting a password).

Fixes #7377
  • Loading branch information
paw-hub committed Aug 13, 2024
1 parent aa69fa5 commit f17b8c0
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
42 changes: 21 additions & 21 deletions src/calendar-app/calendarLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,27 @@ class CalendarLocator {
noOp()
})

this.usageTestModel = new UsageTestModel(
{
[StorageBehavior.Persist]: deviceConfig,
[StorageBehavior.Ephemeral]: new EphemeralUsageTestStorage(),
},
{
now(): number {
return Date.now()
},
timeZone(): string {
throw new Error("Not implemented by this provider")
},
},
this.serviceExecutor,
this.entityClient,
this.logins,
this.eventController,
() => this.usageTestController,
)
this.usageTestController = new UsageTestController(this.usageTestModel)

this.Const = Const
if (!isBrowser()) {
const { WebDesktopFacade } = await import("../common/native/main/WebDesktopFacade")
Expand Down Expand Up @@ -632,26 +653,6 @@ class CalendarLocator {
this.loginListener = new PageContextLoginListener(this.secondFactorHandler, this.credentialsProvider)
this.random = random

this.usageTestModel = new UsageTestModel(
{
[StorageBehavior.Persist]: deviceConfig,
[StorageBehavior.Ephemeral]: new EphemeralUsageTestStorage(),
},
{
now(): number {
return Date.now()
},
timeZone(): string {
throw new Error("Not implemented by this provider")
},
},
this.serviceExecutor,
this.entityClient,
this.logins,
this.eventController,
() => this.usageTestController,
)

this.newsModel = new NewsModel(this.serviceExecutor, deviceConfig, async (name: string) => {
switch (name) {
case "usageOptIn":
Expand Down Expand Up @@ -686,7 +687,6 @@ class CalendarLocator {

const { ContactModel } = await import("../common/contactsFunctionality/ContactModel.js")
this.contactModel = new ContactModel(this.searchFacade, this.entityClient, this.logins, this.eventController)
this.usageTestController = new UsageTestController(this.usageTestModel)
this.appStorePaymentPicker = new AppStorePaymentPicker()

// THEME
Expand Down
43 changes: 21 additions & 22 deletions src/mail-app/mailLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,27 @@ class MailLocator {
mailLocator.search.indexState(state)
})

this.usageTestModel = new UsageTestModel(
{
[StorageBehavior.Persist]: deviceConfig,
[StorageBehavior.Ephemeral]: new EphemeralUsageTestStorage(),
},
{
now(): number {
return Date.now()
},
timeZone(): string {
throw new Error("Not implemented by this provider")
},
},
this.serviceExecutor,
this.entityClient,
this.logins,
this.eventController,
() => this.usageTestController,
)
this.usageTestController = new UsageTestController(this.usageTestModel)

this.Const = Const
if (!isBrowser()) {
const { WebDesktopFacade } = await import("../common/native/main/WebDesktopFacade")
Expand Down Expand Up @@ -740,7 +761,6 @@ class MailLocator {
this.webAuthn = new WebauthnClient(new WebAuthnFacadeSendDispatcher(this.native), this.domainConfigProvider(), isApp())
}
}

if (this.webAuthn == null) {
this.webAuthn = new WebauthnClient(
new BrowserWebauthn(navigator.credentials, this.domainConfigProvider().getCurrentDomainConfig()),
Expand All @@ -759,26 +779,6 @@ class MailLocator {
this.loginListener = new PageContextLoginListener(this.secondFactorHandler, this.credentialsProvider)
this.random = random

this.usageTestModel = new UsageTestModel(
{
[StorageBehavior.Persist]: deviceConfig,
[StorageBehavior.Ephemeral]: new EphemeralUsageTestStorage(),
},
{
now(): number {
return Date.now()
},
timeZone(): string {
throw new Error("Not implemented by this provider")
},
},
this.serviceExecutor,
this.entityClient,
this.logins,
this.eventController,
() => this.usageTestController,
)

this.newsModel = new NewsModel(this.serviceExecutor, deviceConfig, async (name: string) => {
switch (name) {
case "usageOptIn":
Expand Down Expand Up @@ -811,7 +811,6 @@ class MailLocator {
const { ContactModel } = await import("../common/contactsFunctionality/ContactModel.js")
this.contactModel = new ContactModel(this.searchFacade, this.entityClient, this.logins, this.eventController)
this.minimizedMailModel = new MinimizedMailEditorViewModel()
this.usageTestController = new UsageTestController(this.usageTestModel)
this.appStorePaymentPicker = new AppStorePaymentPicker()

// THEME
Expand Down

0 comments on commit f17b8c0

Please sign in to comment.