Browse Source

Build

master
morethanwords 3 years ago
parent
commit
596ae8453a
  1. 4
      .env
  2. 10
      src/components/chat/bubbles.ts
  3. 29
      src/lib/langPack.ts
  4. 1
      src/lib/mediaPlayer.ts

4
.env

@ -1,5 +1,5 @@ @@ -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

10
src/components/chat/bubbles.ts

@ -32,7 +32,7 @@ import animationIntersector from "../animationIntersector"; @@ -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 { @@ -3088,13 +3088,11 @@ export default class ChatBubbles {
} else {
/* const fromTitle = message.fromId === this.myID || appPeersManager.isBroadcast(message.fwdFromId || message.fromId) ? '' : `<div class="name" data-peer-id="${message.fromId}" style="color: ${appPeersManager.getPeerColorByID(message.fromId, false)};">${appPeersManager.getPeerTitle(message.fromId)}</div>`;
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;

29
src/lib/langPack.ts

@ -62,7 +62,7 @@ export const langPack: {[actionType: string]: LangPackKey} = { @@ -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 { @@ -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<FormatterArgument, FormatterArgument[]>[] {
let out: ReturnType<typeof superFormatter> = [];
const regExp = /(\*\*)(.+?)\1|(\n)|(\[.+?\]\(.*?\))|un\d|%\d\$.|%./g;
let lastIndex = 0;
@ -279,7 +279,7 @@ namespace I18n { @@ -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 { @@ -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 { @@ -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 { @@ -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<typeof superFormatter>;
export function format(key: LangPackKey, plain = false, args?: FormatterArguments): ReturnType<typeof superFormatter> | string {
const str = strings.get(key);
let input: string;
if(str) {
@ -390,7 +395,7 @@ namespace I18n { @@ -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 { @@ -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 { @@ -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;
}
}

1
src/lib/mediaPlayer.ts

@ -334,6 +334,7 @@ export default class VideoPlayer extends EventListenerBase<{ @@ -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) => {

Loading…
Cancel
Save