From 596ae8453a979f4e04f93427bcab4c58e28b4080 Mon Sep 17 00:00:00 2001 From: morethanwords Date: Fri, 29 Oct 2021 16:05:55 +0300 Subject: [PATCH] Build --- .env | 4 ++-- src/components/chat/bubbles.ts | 10 ++++------ src/lib/langPack.ts | 29 +++++++++++++++++------------ src/lib/mediaPlayer.ts | 1 + 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/.env b/.env index 107665b0..ad8a5a85 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ API_ID=1025907 API_HASH=452b0359b988148995f22ff0f4229750 VERSION=0.9.1 -VERSION_FULL=0.9.1 (14) -BUILD=14 +VERSION_FULL=0.9.1 (15) +BUILD=15 diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index d7e26980..b95d742f 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -32,7 +32,7 @@ import animationIntersector from "../animationIntersector"; import RichTextProcessor from "../../lib/richtextprocessor"; import mediaSizes from "../../helpers/mediaSizes"; import { IS_ANDROID, IS_APPLE, IS_MOBILE, IS_SAFARI } from "../../environment/userAgent"; -import I18n, { i18n, langPack } from "../../lib/langPack"; +import I18n, { FormatterArguments, i18n, langPack } from "../../lib/langPack"; import AvatarElement from "../avatar"; import { ripple } from "../ripple"; import { wrapAlbum, wrapPhoto, wrapVideo, wrapDocument, wrapSticker, wrapPoll, wrapGroupedDocuments } from "../wrappers"; @@ -3088,13 +3088,11 @@ export default class ChatBubbles { } else { /* const fromTitle = message.fromId === this.myID || appPeersManager.isBroadcast(message.fwdFromId || message.fromId) ? '' : `
${appPeersManager.getPeerTitle(message.fromId)}
`; nameDiv.innerHTML = fromTitle + 'Forwarded from ' + title; */ + const args: FormatterArguments = [title]; if(isStandaloneMedia) { - const fragment = document.createDocumentFragment(); - fragment.append(document.createElement('br')); - fragment.append(title); - title = fragment; + args.unshift(document.createElement('br')); } - nameDiv.append(i18n('ForwardedFrom', [title])); + nameDiv.append(i18n('ForwardedFrom', [args])); if(savedFrom) { nameDiv.dataset.savedFrom = savedFrom; diff --git a/src/lib/langPack.ts b/src/lib/langPack.ts index 1a817956..d1447f9d 100644 --- a/src/lib/langPack.ts +++ b/src/lib/langPack.ts @@ -62,7 +62,7 @@ export const langPack: {[actionType: string]: LangPackKey} = { export type LangPackKey = /* string | */keyof typeof lang | keyof typeof langSign; -export type FormatterArgument = string | Node; +export type FormatterArgument = string | number | Node | FormatterArgument[]; export type FormatterArguments = FormatterArgument[]; namespace I18n { @@ -264,8 +264,8 @@ namespace I18n { }); } - export function superFormatter(input: string, args?: FormatterArguments, indexHolder = {i: 0}) { - let out: FormatterArguments = []; + export function superFormatter(input: string, args?: FormatterArguments, indexHolder = {i: 0}): Exclude[] { + let out: ReturnType = []; const regExp = /(\*\*)(.+?)\1|(\n)|(\[.+?\]\(.*?\))|un\d|%\d\$.|%./g; let lastIndex = 0; @@ -279,7 +279,7 @@ namespace I18n { switch(p1) { case '**': { const b = document.createElement('b'); - b.append(...superFormatter(p2, args, indexHolder)); + b.append(...superFormatter(p2, args, indexHolder) as any); out.push(b); break; } @@ -291,7 +291,7 @@ namespace I18n { const idx = p4.lastIndexOf(']'); const text = p4.slice(1, idx); - a.append(...superFormatter(text, args, indexHolder)); + a.append(...superFormatter(text, args, indexHolder) as any); const url = p4.slice(idx + 2, p4.length - 1); if(url) { @@ -303,7 +303,12 @@ namespace I18n { out.push(a); } else if(args) { - out.push(args[indexHolder.i++]); + const arg = args[indexHolder.i++]; + if(Array.isArray(arg)) { + out.push(...arg as any); + } else { + out.push(arg); + } } lastIndex = offset + match.length; @@ -317,9 +322,9 @@ namespace I18n { return out; } - export function format(key: LangPackKey, plain: true, args?: any[]): string; - export function format(key: LangPackKey, plain?: false, args?: any[]): FormatterArguments; - export function format(key: LangPackKey, plain = false, args?: any[]): FormatterArguments | string { + export function format(key: LangPackKey, plain: true, args?: FormatterArguments): string; + export function format(key: LangPackKey, plain?: false, args?: FormatterArguments): ReturnType; + export function format(key: LangPackKey, plain = false, args?: FormatterArguments): ReturnType | string { const str = strings.get(key); let input: string; if(str) { @@ -390,7 +395,7 @@ namespace I18n { if(this.property === 'innerHTML') { this.element.textContent = ''; - this.element.append(...format(this.key, false, this.args)); + this.element.append(...format(this.key, false, this.args) as any); } else { // @ts-ignore const v = this.element[this.property]; @@ -423,7 +428,7 @@ namespace I18n { } } - export function i18n(key: LangPackKey, args?: any[]) { + export function i18n(key: LangPackKey, args?: FormatterArguments) { return new IntlElement({key, args}).element; } @@ -431,7 +436,7 @@ namespace I18n { return new IntlElement(options).element; } - export function _i18n(element: HTMLElement, key: LangPackKey, args?: any[], property?: IntlElementOptions['property']) { + export function _i18n(element: HTMLElement, key: LangPackKey, args?: FormatterArguments, property?: IntlElementOptions['property']) { return new IntlElement({element, key, args, property}).element; } } diff --git a/src/lib/mediaPlayer.ts b/src/lib/mediaPlayer.ts index ae2e27fa..bcd590e0 100644 --- a/src/lib/mediaPlayer.ts +++ b/src/lib/mediaPlayer.ts @@ -334,6 +334,7 @@ export default class VideoPlayer extends EventListenerBase<{ const volumeSelector = new VolumeSelector(this.listenerSetter); const leftControls = player.querySelector('.left-controls'); + volumeSelector.btn.classList.remove('btn-icon'); leftControls.insertBefore(volumeSelector.btn, timeElapsed.parentElement); Array.from(toggle).forEach((button) => {