forked from MapComplete/MapComplete
Performance hacks
This commit is contained in:
parent
686fb29ed3
commit
7090a5ceb8
15 changed files with 167 additions and 93 deletions
|
@ -7,7 +7,7 @@ export class Translation extends BaseUIElement {
|
|||
public static forcedLanguage = undefined;
|
||||
|
||||
public readonly translations: object
|
||||
|
||||
|
||||
constructor(translations: object, context?: string) {
|
||||
super()
|
||||
if (translations === undefined) {
|
||||
|
@ -33,6 +33,11 @@ export class Translation extends BaseUIElement {
|
|||
get txt(): string {
|
||||
return this.textFor(Translation.forcedLanguage ?? Locale.language.data)
|
||||
}
|
||||
|
||||
Destroy() {
|
||||
super.Destroy();
|
||||
this.isDestroyed = true;
|
||||
}
|
||||
|
||||
static ExtractAllTranslationsFrom(object: any, context = ""): { context: string, tr: Translation }[] {
|
||||
const allTranslations: { context: string, tr: Translation }[] = []
|
||||
|
@ -90,7 +95,11 @@ export class Translation extends BaseUIElement {
|
|||
|
||||
InnerConstructElement(): HTMLElement {
|
||||
const el = document.createElement("span")
|
||||
const self = this
|
||||
Locale.language.addCallbackAndRun(_ => {
|
||||
if(self.isDestroyed){
|
||||
return true
|
||||
}
|
||||
el.innerHTML = this.txt
|
||||
})
|
||||
return el;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue