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 @@
API_ID=1025907 API_ID=1025907
API_HASH=452b0359b988148995f22ff0f4229750 API_HASH=452b0359b988148995f22ff0f4229750
VERSION=0.9.1 VERSION=0.9.1
VERSION_FULL=0.9.1 (14) VERSION_FULL=0.9.1 (15)
BUILD=14 BUILD=15

10
src/components/chat/bubbles.ts

@ -32,7 +32,7 @@ import animationIntersector from "../animationIntersector";
import RichTextProcessor from "../../lib/richtextprocessor"; import RichTextProcessor from "../../lib/richtextprocessor";
import mediaSizes from "../../helpers/mediaSizes"; import mediaSizes from "../../helpers/mediaSizes";
import { IS_ANDROID, IS_APPLE, IS_MOBILE, IS_SAFARI } from "../../environment/userAgent"; 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 AvatarElement from "../avatar";
import { ripple } from "../ripple"; import { ripple } from "../ripple";
import { wrapAlbum, wrapPhoto, wrapVideo, wrapDocument, wrapSticker, wrapPoll, wrapGroupedDocuments } from "../wrappers"; import { wrapAlbum, wrapPhoto, wrapVideo, wrapDocument, wrapSticker, wrapPoll, wrapGroupedDocuments } from "../wrappers";
@ -3088,13 +3088,11 @@ export default class ChatBubbles {
} else { } 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>`; /* 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; */ nameDiv.innerHTML = fromTitle + 'Forwarded from ' + title; */
const args: FormatterArguments = [title];
if(isStandaloneMedia) { if(isStandaloneMedia) {
const fragment = document.createDocumentFragment(); args.unshift(document.createElement('br'));
fragment.append(document.createElement('br'));
fragment.append(title);
title = fragment;
} }
nameDiv.append(i18n('ForwardedFrom', [title])); nameDiv.append(i18n('ForwardedFrom', [args]));
if(savedFrom) { if(savedFrom) {
nameDiv.dataset.savedFrom = savedFrom; nameDiv.dataset.savedFrom = savedFrom;

29
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 LangPackKey = /* string | */keyof typeof lang | keyof typeof langSign;
export type FormatterArgument = string | Node; export type FormatterArgument = string | number | Node | FormatterArgument[];
export type FormatterArguments = FormatterArgument[]; export type FormatterArguments = FormatterArgument[];
namespace I18n { namespace I18n {
@ -264,8 +264,8 @@ namespace I18n {
}); });
} }
export function superFormatter(input: string, args?: FormatterArguments, indexHolder = {i: 0}) { export function superFormatter(input: string, args?: FormatterArguments, indexHolder = {i: 0}): Exclude<FormatterArgument, FormatterArgument[]>[] {
let out: FormatterArguments = []; let out: ReturnType<typeof superFormatter> = [];
const regExp = /(\*\*)(.+?)\1|(\n)|(\[.+?\]\(.*?\))|un\d|%\d\$.|%./g; const regExp = /(\*\*)(.+?)\1|(\n)|(\[.+?\]\(.*?\))|un\d|%\d\$.|%./g;
let lastIndex = 0; let lastIndex = 0;
@ -279,7 +279,7 @@ namespace I18n {
switch(p1) { switch(p1) {
case '**': { case '**': {
const b = document.createElement('b'); const b = document.createElement('b');
b.append(...superFormatter(p2, args, indexHolder)); b.append(...superFormatter(p2, args, indexHolder) as any);
out.push(b); out.push(b);
break; break;
} }
@ -291,7 +291,7 @@ namespace I18n {
const idx = p4.lastIndexOf(']'); const idx = p4.lastIndexOf(']');
const text = p4.slice(1, idx); 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); const url = p4.slice(idx + 2, p4.length - 1);
if(url) { if(url) {
@ -303,7 +303,12 @@ namespace I18n {
out.push(a); out.push(a);
} else if(args) { } 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; lastIndex = offset + match.length;
@ -317,9 +322,9 @@ namespace I18n {
return out; return out;
} }
export function format(key: LangPackKey, plain: true, args?: any[]): string; export function format(key: LangPackKey, plain: true, args?: FormatterArguments): string;
export function format(key: LangPackKey, plain?: false, args?: any[]): FormatterArguments; export function format(key: LangPackKey, plain?: false, args?: FormatterArguments): ReturnType<typeof superFormatter>;
export function format(key: LangPackKey, plain = false, args?: any[]): FormatterArguments | string { export function format(key: LangPackKey, plain = false, args?: FormatterArguments): ReturnType<typeof superFormatter> | string {
const str = strings.get(key); const str = strings.get(key);
let input: string; let input: string;
if(str) { if(str) {
@ -390,7 +395,7 @@ namespace I18n {
if(this.property === 'innerHTML') { if(this.property === 'innerHTML') {
this.element.textContent = ''; this.element.textContent = '';
this.element.append(...format(this.key, false, this.args)); this.element.append(...format(this.key, false, this.args) as any);
} else { } else {
// @ts-ignore // @ts-ignore
const v = this.element[this.property]; 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; return new IntlElement({key, args}).element;
} }
@ -431,7 +436,7 @@ namespace I18n {
return new IntlElement(options).element; 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; return new IntlElement({element, key, args, property}).element;
} }
} }

1
src/lib/mediaPlayer.ts

@ -334,6 +334,7 @@ export default class VideoPlayer extends EventListenerBase<{
const volumeSelector = new VolumeSelector(this.listenerSetter); const volumeSelector = new VolumeSelector(this.listenerSetter);
const leftControls = player.querySelector('.left-controls'); const leftControls = player.querySelector('.left-controls');
volumeSelector.btn.classList.remove('btn-icon');
leftControls.insertBefore(volumeSelector.btn, timeElapsed.parentElement); leftControls.insertBefore(volumeSelector.btn, timeElapsed.parentElement);
Array.from(toggle).forEach((button) => { Array.from(toggle).forEach((button) => {

Loading…
Cancel
Save