Skip to content

Commit

Permalink
Fix location is not defined error on desktop build
Browse files Browse the repository at this point in the history
  • Loading branch information
rezbyte committed Nov 21, 2024
1 parent fdd64a8 commit 4a1be82
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 33 deletions.
2 changes: 1 addition & 1 deletion buildSrc/DevBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function runDevBuild({ stage, host, desktop, clean, ignoreMigration
u2fAppId: `${protocol}//${hostname}:${port}/u2f-appid.json`,
giftCardBaseUrl: `${protocol}//${hostname}:${port}/giftcard`,
referralBaseUrl: `${protocol}//${hostname}:${port}/signup`,
websiteBaseUrl: "https://tuta.com",
websiteBaseUrl: domainConfigs[hostname].websiteBaseUrl ?? "https://tuta.com",
},
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/calendar-app/calendar-app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from "../common/misc/ClientDetector.js"
import m from "mithril"
import Mithril, { Children, ClassComponent, Component, RouteDefs, RouteResolver, Vnode, VnodeDOM } from "mithril"
import { lang, languageCodeToTag, languages } from "../common/misc/LanguageViewModel.js"
import { lang, languageCodeToTag, languages, setInfoLinks } from "../common/misc/LanguageViewModel.js"
import { root } from "../RootView.js"
import { disableErrorHandlingDuringLogout, handleUncaughtError } from "../common/misc/ErrorHandler.js"
import { assertMainOrNodeBoot, bootFinished, isApp, isDesktop, isOfflineStorageAvailable } from "../common/api/common/Env.js"
Expand Down Expand Up @@ -397,6 +397,8 @@ import("../mail-app/translations/en.js")
const serviceworker = await import("../common/serviceworker/ServiceWorkerClient.js")
serviceworker.init(domainConfig)

setInfoLinks(domainConfig.websiteBaseUrl)

printJobsMessage(domainConfig)
})

Expand Down
92 changes: 62 additions & 30 deletions src/common/misc/LanguageViewModel.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { assertNotNull, downcast, lazy, typedEntries } from "@tutao/tutanota-utils"
import { downcast, lazy, typedEntries } from "@tutao/tutanota-utils"
import type { TranslationKeyType } from "./TranslationKey"
import { getWhitelabelCustomizations, WhitelabelCustomizations } from "./WhitelabelCustomizations"
import { assertMainOrNodeBoot } from "../api/common/Env"
import { DomainConfigProvider } from "../api/common/DomainConfigProvider.js"

export type TranslationKey = TranslationKeyType
export type TranslationText = TranslationKey | lazy<string>
Expand Down Expand Up @@ -194,38 +193,71 @@ export const languageNative: ReadonlyArray<{
}
})

const websiteUrl = env.staticUrl == null ? "https://tuta.com" : new DomainConfigProvider().getCurrentDomainConfig().websiteBaseUrl // env.staticUrl is null on Electron
export const InfoLinks = Object.freeze({
HomePage: websiteUrl,
About: `${websiteUrl}/imprint`,
// Modifiable so `app.js` can initialize it to the website urls in the domain config
export let InfoLinks = {
HomePage: "https://tuta.com",
About: `https://tuta.com/imprint`,
//terms
Terms: `${websiteUrl}/terms`,
Privacy: `${websiteUrl}/privacy-policy`,
GiftCardsTerms: `${websiteUrl}/giftCardsTerms`,
Terms: `https://tuta.com/terms`,
Privacy: `https://tuta.com/privacy-policy`,
GiftCardsTerms: `https://tuta.com/giftCardsTerms`,
//faq
RecoverCode: `${websiteUrl}/faq#reset`,
SecondFactor: `${websiteUrl}/faq#2fa`,
SpamRules: `${websiteUrl}/faq#spam`,
DomainInfo: `${websiteUrl}/faq#custom-domain`,
Whitelabel: `${websiteUrl}/faq#whitelabel`,
ReferralLink: `${websiteUrl}/faq#refer-a-friend`,
Webview: `${websiteUrl}/faq#webview`,
Phishing: `${websiteUrl}/faq#phishing`,
MailAuth: `${websiteUrl}/faq#mail-auth`,
RunInBackground: `${websiteUrl}/faq#tray-desktop`,
LoadImages: `${websiteUrl}/faq#load-images`,
Usage: `${websiteUrl}/faq#usage`,
Download: `${websiteUrl}/#download`,
SharedMailboxes: `${websiteUrl}/support/#shared-mailboxes`,
InactiveAccounts: `${websiteUrl}/faq/#inactive-accounts`,
AppStorePaymentChange: `${websiteUrl}/support/#appstore-payment-change`,
AppStorePayment: `${websiteUrl}/support/#appstore-payments`,
AppStoreDowngrade: `${websiteUrl}/support/#appstore-subscription-downgrade`,
PasswordGenerator: `${websiteUrl}/faq#passphrase-generator`,
HomePageFreeSignup: `${websiteUrl}/free-email`,
})
RecoverCode: `https://tuta.com/faq#reset`,
SecondFactor: `https://tuta.com/faq#2fa`,
SpamRules: `https://tuta.com/faq#spam`,
DomainInfo: `https://tuta.com/faq#custom-domain`,
Whitelabel: `https://tuta.com/faq#whitelabel`,
ReferralLink: `https://tuta.com/faq#refer-a-friend`,
Webview: `https://tuta.com/faq#webview`,
Phishing: `https://tuta.com/faq#phishing`,
MailAuth: `https://tuta.com/faq#mail-auth`,
RunInBackground: `https://tuta.com/faq#tray-desktop`,
LoadImages: `https://tuta.com/faq#load-images`,
Usage: `https://tuta.com/faq#usage`,
Download: `https://tuta.com/#download`,
SharedMailboxes: `https://tuta.com/support/#shared-mailboxes`,
InactiveAccounts: `https://tuta.com/faq/#inactive-accounts`,
AppStorePaymentChange: `https://tuta.com/support/#appstore-payment-change`,
AppStorePayment: `https://tuta.com/support/#appstore-payments`,
AppStoreDowngrade: `https://tuta.com/support/#appstore-subscription-downgrade`,
PasswordGenerator: `https://tuta.com/faq#passphrase-generator`,
HomePageFreeSignup: `https://tuta.com/free-email`,
}
export type InfoLink = (typeof InfoLinks)[keyof typeof InfoLinks]

// Updates the website links in `InfoLinks` to use `websiteUrl` as the root
export function setInfoLinks(websiteUrl: string) {
InfoLinks = {
HomePage: websiteUrl,
About: `${websiteUrl}/imprint`,
//terms
Terms: `${websiteUrl}/terms`,
Privacy: `${websiteUrl}/privacy-policy`,
GiftCardsTerms: `${websiteUrl}/giftCardsTerms`,
//faq
RecoverCode: `${websiteUrl}/faq#reset`,
SecondFactor: `${websiteUrl}/faq#2fa`,
SpamRules: `${websiteUrl}/faq#spam`,
DomainInfo: `${websiteUrl}/faq#custom-domain`,
Whitelabel: `${websiteUrl}/faq#whitelabel`,
ReferralLink: `${websiteUrl}/faq#refer-a-friend`,
Webview: `${websiteUrl}/faq#webview`,
Phishing: `${websiteUrl}/faq#phishing`,
MailAuth: `${websiteUrl}/faq#mail-auth`,
RunInBackground: `${websiteUrl}/faq#tray-desktop`,
LoadImages: `${websiteUrl}/faq#load-images`,
Usage: `${websiteUrl}/faq#usage`,
Download: `${websiteUrl}/#download`,
SharedMailboxes: `${websiteUrl}/support/#shared-mailboxes`,
InactiveAccounts: `${websiteUrl}/faq/#inactive-accounts`,
AppStorePaymentChange: `${websiteUrl}/support/#appstore-payment-change`,
AppStorePayment: `${websiteUrl}/support/#appstore-payments`,
AppStoreDowngrade: `${websiteUrl}/support/#appstore-subscription-downgrade`,
PasswordGenerator: `${websiteUrl}/faq#passphrase-generator`,
HomePageFreeSignup: `${websiteUrl}/free-email`,
}
}

/**
* Provides all localizations of strings on our gui.
*
Expand Down
4 changes: 3 additions & 1 deletion src/mail-app/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { client } from "../common/misc/ClientDetector.js"
import m from "mithril"
import Mithril, { Children, ClassComponent, Component, RouteDefs, RouteResolver, Vnode, VnodeDOM } from "mithril"
import { lang, languageCodeToTag, languages } from "../common/misc/LanguageViewModel.js"
import { lang, languageCodeToTag, languages, setInfoLinks } from "../common/misc/LanguageViewModel.js"
import { root } from "../RootView.js"
import { assertNotNull, neverNull } from "@tutao/tutanota-utils"
import { windowFacade } from "../common/misc/WindowFacade.js"
Expand Down Expand Up @@ -552,6 +552,8 @@ import("./translations/en.js")
const serviceworker = await import("../common/serviceworker/ServiceWorkerClient.js")
serviceworker.init(domainConfig)

setInfoLinks(domainConfig.websiteBaseUrl)

printJobsMessage(domainConfig)
})

Expand Down

0 comments on commit 4a1be82

Please sign in to comment.