Browse Source

Fix navigation stuck after hashchange

Fix iOS video upload
Fix some translations
master
Eduard Kuzmenko 4 years ago
parent
commit
a43a0357bc
  1. 2
      src/components/appMediaPlaybackController.ts
  2. 15
      src/components/appNavigationController.ts
  3. 2
      src/components/appSelectPeers.ts
  4. 2
      src/components/chat/bubbles.ts
  5. 2
      src/components/emoticonsDropdown/index.ts
  6. 2
      src/components/misc.ts
  7. 2
      src/components/peerTitle.ts
  8. 6
      src/components/popups/newMedia.ts
  9. 2
      src/components/sidebarLeft/index.ts
  10. 2
      src/components/sidebarRight/index.ts
  11. 2
      src/components/wrappers.ts
  12. 19
      src/config/debug.ts
  13. 2
      src/countries.ts
  14. 2
      src/helpers/date.ts
  15. 8
      src/helpers/dom.ts
  16. 2
      src/helpers/eventListenerBase.ts
  17. 2
      src/helpers/mediaSizes.ts
  18. 8
      src/lang.ts
  19. 2
      src/lib/appManagers/apiUpdatesManager.ts
  20. 2
      src/lib/appManagers/appChatsManager.ts
  21. 2
      src/lib/appManagers/appDialogsManager.ts
  22. 2
      src/lib/appManagers/appDocsManager.ts
  23. 2
      src/lib/appManagers/appDraftsManager.ts
  24. 112
      src/lib/appManagers/appImManager.ts
  25. 62
      src/lib/appManagers/appMessagesManager.ts
  26. 2
      src/lib/appManagers/appNotificationsManager.ts
  27. 2
      src/lib/appManagers/appPeersManager.ts
  28. 2
      src/lib/appManagers/appPhotosManager.ts
  29. 2
      src/lib/appManagers/appPollsManager.ts
  30. 2
      src/lib/appManagers/appPrivacyManager.ts
  31. 2
      src/lib/appManagers/appStateManager.ts
  32. 2
      src/lib/appManagers/appStickersManager.ts
  33. 2
      src/lib/appManagers/appUsersManager.ts
  34. 2
      src/lib/cacheStorage.ts
  35. 2
      src/lib/config.ts
  36. 2
      src/lib/crypto/cryptoworker.ts
  37. 2
      src/lib/langPack.ts
  38. 2
      src/lib/lottieLoader.ts
  39. 2
      src/lib/mtproto/apiFileManager.ts
  40. 6
      src/lib/mtproto/apiManager.ts
  41. 2
      src/lib/mtproto/mtproto.service.ts
  42. 2
      src/lib/mtproto/mtprotoworker.ts
  43. 2
      src/lib/mtproto/passwordManager.ts
  44. 2
      src/lib/mtproto/referenceDatabase.ts
  45. 2
      src/lib/mtproto/timeManager.ts
  46. 4
      src/lib/mtproto/tl_utils.ts
  47. 2
      src/lib/opusDecodeController.ts
  48. 2
      src/lib/richtextprocessor.ts
  49. 2
      src/lib/rootScope.ts
  50. 2
      src/lib/sessionStorage.ts
  51. 2
      src/lib/webp/webpWorkerController.ts
  52. 2
      src/pages/pagesManager.ts
  53. 8
      src/scss/partials/_chat.scss

2
src/components/appMediaPlaybackController.ts

@ -265,5 +265,5 @@ class AppMediaPlaybackController { @@ -265,5 +265,5 @@ class AppMediaPlaybackController {
}
const appMediaPlaybackController = new AppMediaPlaybackController();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appMediaPlaybackController = appMediaPlaybackController);
MOUNT_CLASS_TO.appMediaPlaybackController = appMediaPlaybackController;
export default appMediaPlaybackController;

15
src/components/appNavigationController.ts

@ -17,14 +17,23 @@ export class AppNavigationController { @@ -17,14 +17,23 @@ export class AppNavigationController {
private manual = false;
private log = logger('NC');
private debug = true;
private currentHash = window.location.hash;
public onHashChange: () => void;
constructor() {
let isPossibleSwipe = false;
window.addEventListener('popstate', (e) => {
this.debug && this.log('popstate', e, isPossibleSwipe);
if(window.location.hash !== this.currentHash) {
this.onHashChange && this.onHashChange();
this.replaceState();
return;
}
this.currentHash = window.location.hash;
const id: number = e.state;
if(id !== this.id) {
if(id !== this.id/* && !this.navigations.length */) {
this.pushState();
return;
}
@ -148,7 +157,7 @@ export class AppNavigationController { @@ -148,7 +157,7 @@ export class AppNavigationController {
}
public replaceState() {
history.replaceState(this.id, '');
history.replaceState(this.id, '', location.origin + location.pathname);
}
public removeItem(item: NavigationItem) {
@ -170,5 +179,5 @@ export class AppNavigationController { @@ -170,5 +179,5 @@ export class AppNavigationController {
}
const appNavigationController = new AppNavigationController();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appNavigationController = appNavigationController);
MOUNT_CLASS_TO.appNavigationController = appNavigationController;
export default appNavigationController;

2
src/components/appSelectPeers.ts

@ -101,7 +101,7 @@ export default class AppSelectPeers { @@ -101,7 +101,7 @@ export default class AppSelectPeers {
if(this.placeholder) {
_i18n(this.input, this.placeholder, undefined, 'placeholder');
} else {
_i18n(this.input, !this.peerType.includes('dialogs') ? 'SendMessageTo' : 'SelectChat', undefined, 'placeholder');
_i18n(this.input, 'SendMessageTo', undefined, 'placeholder');
}
this.input.type = 'text';

2
src/components/chat/bubbles.ts

@ -2356,7 +2356,7 @@ export default class ChatBubbles { @@ -2356,7 +2356,7 @@ export default class ChatBubbles {
default:
bubble.classList.remove('is-message-empty');
messageDiv.innerHTML = 'unrecognized media type: ' + message.media._;
messageDiv.innerHTML = '<i class="media-not-supported">This message is currently not supported on Telegram Web. Try <a href="https://desktop.telegram.org/" target="_blank">desktop.telegram.org</a></i>';
messageDiv.append(timeSpan);
this.log.warn('unrecognized media type:', message.media._, message);
break;

2
src/components/emoticonsDropdown/index.ts

@ -424,5 +424,5 @@ export class EmoticonsDropdown { @@ -424,5 +424,5 @@ export class EmoticonsDropdown {
}
const emoticonsDropdown = new EmoticonsDropdown();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.emoticonsDropdown = emoticonsDropdown);
MOUNT_CLASS_TO.emoticonsDropdown = emoticonsDropdown;
export default emoticonsDropdown;

2
src/components/misc.ts

@ -77,7 +77,7 @@ export function putPreloader(elem: Element, returnDiv = false): HTMLElement { @@ -77,7 +77,7 @@ export function putPreloader(elem: Element, returnDiv = false): HTMLElement {
return elem.lastElementChild as HTMLElement;
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.putPreloader = putPreloader);
MOUNT_CLASS_TO.putPreloader = putPreloader;
export function setButtonLoader(elem: HTMLButtonElement, icon = 'check') {
elem.classList.remove('tgico-' + icon);

2
src/components/peerTitle.ts

@ -11,7 +11,7 @@ export type PeerTitleOptions = { @@ -11,7 +11,7 @@ export type PeerTitleOptions = {
const weakMap: WeakMap<HTMLElement, PeerTitle> = new WeakMap();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.peerTitleWeakMap = weakMap);
MOUNT_CLASS_TO.peerTitleWeakMap = weakMap;
rootScope.on('peer_title_edit', (peerId) => {
const elements = Array.from(document.querySelectorAll(`.peer-title[data-peer-id="${peerId}"]`)) as HTMLElement[];

6
src/components/popups/newMedia.ts

@ -238,11 +238,15 @@ export default class PopupNewMedia extends PopupElement { @@ -238,11 +238,15 @@ export default class PopupNewMedia extends PopupElement {
const video = document.createElement('video');
const source = document.createElement('source');
source.src = params.objectURL = URL.createObjectURL(file);
video.autoplay = false;
video.autoplay = true;
video.controls = false;
video.muted = true;
video.setAttribute('playsinline', 'true');
video.addEventListener('timeupdate', () => {
video.pause();
}, {once: true});
onVideoLoad(video).then(() => {
params.width = video.videoWidth;
params.height = video.videoHeight;

2
src/components/sidebarLeft/index.ts

@ -499,5 +499,5 @@ export const generateSection = (appendTo: Scrollable, name?: LangPackKey, captio @@ -499,5 +499,5 @@ export const generateSection = (appendTo: Scrollable, name?: LangPackKey, captio
};
const appSidebarLeft = new AppSidebarLeft();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appSidebarLeft = appSidebarLeft);
MOUNT_CLASS_TO.appSidebarLeft = appSidebarLeft;
export default appSidebarLeft;

2
src/components/sidebarRight/index.ts

@ -125,5 +125,5 @@ export class AppSidebarRight extends SidebarSlider { @@ -125,5 +125,5 @@ export class AppSidebarRight extends SidebarSlider {
}
const appSidebarRight = new AppSidebarRight();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appSidebarRight = appSidebarRight);
MOUNT_CLASS_TO.appSidebarRight = appSidebarRight;
export default appSidebarRight;

2
src/components/wrappers.ts

@ -303,7 +303,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai @@ -303,7 +303,7 @@ export function wrapVideo({doc, container, message, boxWidth, boxHeight, withTai
} else if(doc.supportsStreaming) {
if(noAutoDownload) {
loadPromise = Promise.reject();
} else {
} else if(!doc.downloaded) { // * check for uploading video
preloader.attach(container, false, null);
video.addEventListener(isSafari ? 'timeupdate' : 'canplay', () => {
preloader.detach();

19
src/config/debug.ts

@ -1,9 +1,24 @@ @@ -1,9 +1,24 @@
import Modes from "./modes";
export const DEBUG = process.env.NODE_ENV !== 'production' || Modes.debug;
export const MOUNT_CLASS_TO: any = DEBUG ? (typeof(window) !== 'undefined' ? window : self) : null;
const ctx: any = typeof(window) !== 'undefined' ? window : self;
export const MOUNT_CLASS_TO: any = DEBUG/* && false */ ? ctx : {};
export default DEBUG;
//let m = DEBUG;
if(!DEBUG/* || true */) {
ctx.sandpitTurtle = () => {
//if(!m) {
for(let i in MOUNT_CLASS_TO) {
ctx[i] = MOUNT_CLASS_TO[i];
}
//m = true;
//}
//DEBUG = !DEBUG;
};
}
/* export const superDebug = (object: any, key: string) => {
var d = object[key];
var beforeStr = '', afterStr = '';
@ -32,4 +47,4 @@ export default DEBUG; @@ -32,4 +47,4 @@ export default DEBUG;
dada(key + '_' + 'after', afterStr);
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.superDebug = superDebug); */
MOUNT_CLASS_TO.superDebug = superDebug; */

2
src/countries.ts

@ -39,7 +39,7 @@ arr.forEach((el, idx) => { @@ -39,7 +39,7 @@ arr.forEach((el, idx) => {
});
*/
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.Countries = Countries);
MOUNT_CLASS_TO.Countries = Countries;
export default Countries;
export {PhoneCodesMain};

2
src/helpers/date.ts

@ -454,4 +454,4 @@ function getDayOfWeek(q: string) { @@ -454,4 +454,4 @@ function getDayOfWeek(q: string) {
return -1;
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.fillTipDates = fillTipDates);
MOUNT_CLASS_TO.fillTipDates = fillTipDates;

8
src/helpers/dom.ts

@ -134,7 +134,7 @@ export function getRichValue(field: HTMLElement, entities?: MessageEntity[]) { @@ -134,7 +134,7 @@ export function getRichValue(field: HTMLElement, entities?: MessageEntity[]) {
return value;
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.getRichValue = getRichValue);
MOUNT_CLASS_TO.getRichValue = getRichValue;
export type MarkdownType = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'monospace' | 'link';
export type MarkdownTag = {
@ -336,7 +336,7 @@ export function generatePathData(x: number, y: number, width: number, height: nu @@ -336,7 +336,7 @@ export function generatePathData(x: number, y: number, width: number, height: nu
return data.join(' ');
};
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.generatePathData = generatePathData);
MOUNT_CLASS_TO.generatePathData = generatePathData;
//export function findUpClassName<T>(el: any, className: string): T;
export function findUpClassName(el: any, className: string): HTMLElement {
@ -442,7 +442,7 @@ export function calcImageInBox(imageW: number, imageH: number, boxW: number, box @@ -442,7 +442,7 @@ export function calcImageInBox(imageW: number, imageH: number, boxW: number, box
return {w: boxedImageW, h: boxedImageH};
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.calcImageInBox = calcImageInBox);
MOUNT_CLASS_TO.calcImageInBox = calcImageInBox;
export function positionElementByIndex(element: HTMLElement, container: HTMLElement, pos: number) {
const prevPos = element.parentElement === container ? whichChild(element) : -1;
@ -651,7 +651,7 @@ export const getElementByPoint = (container: HTMLElement, verticalSide: 'top' | @@ -651,7 +651,7 @@ export const getElementByPoint = (container: HTMLElement, verticalSide: 'top' |
return document.elementFromPoint(x, y) as any;
};
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.getElementByPoint = getElementByPoint);
MOUNT_CLASS_TO.getElementByPoint = getElementByPoint;
export async function getFilesFromEvent(e: ClipboardEvent | DragEvent, onlyTypes = false): Promise<any[]> {
const files: any[] = [];

2
src/helpers/eventListenerBase.ts

@ -41,7 +41,7 @@ import type { ArgumentTypes, SuperReturnType } from "../types"; @@ -41,7 +41,7 @@ import type { ArgumentTypes, SuperReturnType } from "../types";
// console.log = () => {};
// const e = new EventSystem();
// MOUNT_CLASS_TO && (MOUNT_CLASS_TO.e = e);
// MOUNT_CLASS_TO.e = e;
/**
* Better not to remove listeners during setting

2
src/helpers/mediaSizes.ts

@ -126,5 +126,5 @@ class MediaSizes extends EventListenerBase<{ @@ -126,5 +126,5 @@ class MediaSizes extends EventListenerBase<{
}
const mediaSizes = new MediaSizes();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.mediaSizes = mediaSizes);
MOUNT_CLASS_TO.mediaSizes = mediaSizes;
export default mediaSizes;

8
src/lang.ts

@ -83,13 +83,17 @@ const lang = { @@ -83,13 +83,17 @@ const lang = {
"ActionInviteUser": "un1 joined the group via invite link",
"ActionPinnedNoText": "un1 pinned a message",
"ActionMigrateFromGroup": "This group was upgraded to a supergroup",
"ActionYouScored": "You scored %1$s",
"ActionUserScored": "un1 scored %1$s",
"ActionYouScoredInGame": "You scored %1$s in un2",
"ActionUserScoredInGame": "un1 scored %1$s in un2",
"AttachPhoto": "Photo",
"AttachVideo": "Video",
"AttachGif": "GIF",
"AttachLocation": "Location",
"AttachLiveLocation": "Live Location",
"AttachContact": "Contact",
"AttachDocument": "File",
//"AttachDocument": "File",
"AttachSticker": "Sticker",
"AttachAudio": "Voice message",
"AttachRound": "Video message",
@ -216,7 +220,7 @@ const lang = { @@ -216,7 +220,7 @@ const lang = {
"LinkCopiedPrivateInfo": "This link will only work for members of this chat.",
"GroupAddMembers": "Add Members",
"SendMessageTo": "Add people...",
"SelectChat": "Select Chat",
//"SelectChat": "Select Chat",
"JumpToDate": "Jump to Date",
"Caption": "Caption",
"Message": "Message",

2
src/lib/appManagers/apiUpdatesManager.ts

@ -632,5 +632,5 @@ export class ApiUpdatesManager { @@ -632,5 +632,5 @@ export class ApiUpdatesManager {
}
const apiUpdatesManager = new ApiUpdatesManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiUpdatesManager = apiUpdatesManager);
MOUNT_CLASS_TO.apiUpdatesManager = apiUpdatesManager;
export default apiUpdatesManager

2
src/lib/appManagers/appChatsManager.ts

@ -718,5 +718,5 @@ export class AppChatsManager { @@ -718,5 +718,5 @@ export class AppChatsManager {
}
const appChatsManager = new AppChatsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appChatsManager = appChatsManager);
MOUNT_CLASS_TO.appChatsManager = appChatsManager;
export default appChatsManager;

2
src/lib/appManagers/appDialogsManager.ts

@ -1397,5 +1397,5 @@ export class AppDialogsManager { @@ -1397,5 +1397,5 @@ export class AppDialogsManager {
}
const appDialogsManager = new AppDialogsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appDialogsManager = appDialogsManager);
MOUNT_CLASS_TO.appDialogsManager = appDialogsManager;
export default appDialogsManager;

2
src/lib/appManagers/appDocsManager.ts

@ -395,5 +395,5 @@ export class AppDocsManager { @@ -395,5 +395,5 @@ export class AppDocsManager {
}
const appDocsManager = new AppDocsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appDocsManager = appDocsManager);
MOUNT_CLASS_TO.appDocsManager = appDocsManager;
export default appDocsManager;

2
src/lib/appManagers/appDraftsManager.ts

@ -221,5 +221,5 @@ export class AppDraftsManager { @@ -221,5 +221,5 @@ export class AppDraftsManager {
}
const appDraftsManager = new AppDraftsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appDraftsManager = appDraftsManager);
MOUNT_CLASS_TO.appDraftsManager = appDraftsManager;
export default appDraftsManager;

112
src/lib/appManagers/appImManager.ts

@ -118,47 +118,8 @@ export class AppImManager { @@ -118,47 +118,8 @@ export class AppImManager {
this.createNewChat();
this.chatsSelectTab(this.chat.container);
window.addEventListener('hashchange', (e) => {
const hash = location.hash;
const splitted = hash.split('?');
if(!splitted[1]) {
return;
}
const params: any = {};
splitted[1].split('&').forEach(item => {
params[item.split('=')[0]] = decodeURIComponent(item.split('=')[1]);
});
this.log('hashchange', hash, splitted[0], params);
switch(splitted[0]) {
case '#/im': {
const p = params.p;
let postId = params.post !== undefined ? appMessagesManager.generateMessageId(+params.post) : undefined;
switch(p[0]) {
case '@': {
appUsersManager.resolveUsername(p).then(peer => {
const isUser = peer._ === 'user';
const peerId = isUser ? peer.id : -peer.id;
this.setInnerPeer(peerId, postId);
});
break;
}
default: { // peerId
this.setInnerPeer(postId ? -+p : +p, postId);
break;
}
}
}
}
location.hash = '';
});
appNavigationController.onHashChange = this.onHashChange;
//window.addEventListener('hashchange', this.onHashChange);
this.setSettings();
rootScope.on('settings_updated', this.setSettings);
@ -205,6 +166,49 @@ export class AppImManager { @@ -205,6 +166,49 @@ export class AppImManager {
}); */
}
private onHashChange = () => {
const hash = location.hash;
const splitted = hash.split('?');
if(!splitted[1]) {
return;
}
const params: any = {};
splitted[1].split('&').forEach(item => {
params[item.split('=')[0]] = decodeURIComponent(item.split('=')[1]);
});
this.log('hashchange', hash, splitted[0], params);
switch(splitted[0]) {
case '#/im': {
const p = params.p;
let postId = params.post !== undefined ? appMessagesManager.generateMessageId(+params.post) : undefined;
switch(p[0]) {
case '@': {
appUsersManager.resolveUsername(p).then(peer => {
const isUser = peer._ === 'user';
const peerId = isUser ? peer.id : -peer.id;
this.setInnerPeer(peerId, postId);
});
break;
}
default: { // peerId
this.setInnerPeer(postId ? -+p : +p, postId);
break;
}
}
}
}
//appNavigationController.replaceState();
//location.hash = '';
};
public setBackground(url: string, broadcastEvent = true): Promise<void> {
const promises = this.chats.map(chat => chat.setBackground(url));
return promises[promises.length - 1].then(() => {
@ -594,14 +598,20 @@ export class AppImManager { @@ -594,14 +598,20 @@ export class AppImManager {
this.chats.push(chat);
}
private spliceChats(fromIndex: number, justReturn = true, animate?: boolean) {
private spliceChats(fromIndex: number, justReturn = true, animate?: boolean, spliced?: Chat[]) {
if(fromIndex >= this.chats.length) return;
if(this.chats.length > 1 && justReturn) {
rootScope.broadcast('peer_changing', this.chat);
}
const spliced = this.chats.splice(fromIndex, this.chats.length - fromIndex);
if(!spliced) {
spliced = this.chats.splice(fromIndex, this.chats.length - fromIndex);
}
for(let i = 0; i < spliced.length; ++i) {
appNavigationController.removeByType('chat', true);
}
// * fix middle chat z-index on animation
if(spliced.length > 1) {
@ -655,8 +665,20 @@ export class AppImManager { @@ -655,8 +665,20 @@ export class AppImManager {
return;
}
} else if(chatIndex > 0 && chat.peerId && chat.peerId !== peerId) {
this.spliceChats(1, false, animate);
return this.setPeer(peerId, lastMsgId);
// const firstChat = this.chats[0];
// if(firstChat.peerId !== chat.peerId) {
/* // * slice idx > 0, set background and slice first, so new one will be the first
const spliced = this.chats.splice(1, this.chats.length - 1);
this.createNewChat();
this.chats.splice(0, 1); */
const spliced = this.chats.splice(1, this.chats.length - 1);
const ret = this.setPeer(peerId, lastMsgId);
this.spliceChats(0, false, false, spliced);
// } else {
// this.spliceChats(1, false, animate);
// }
return ret;
}
// * don't reset peer if returning

62
src/lib/appManagers/appMessagesManager.ts

@ -2375,9 +2375,6 @@ export class AppMessagesManager { @@ -2375,9 +2375,6 @@ export class AppMessagesManager {
case 'messageMediaInvoice':
message.media = {_: 'messageMediaUnsupportedWeb'};
break;
case 'messageMediaGeoLive':
message.media._ = 'messageMediaGeo';
break;
}
}
@ -2504,7 +2501,11 @@ export class AppMessagesManager { @@ -2504,7 +2501,11 @@ export class AppMessagesManager {
public wrapMessageForReply(message: any, text: string = message.message, usingMids?: number[], plain?: boolean, highlightWord?: string): DocumentFragment | string {
const parts: (HTMLElement | string)[] = [];
const addPart = (part: string | HTMLElement, text?: string) => {
const addPart = (langKey: LangPackKey, part?: string | HTMLElement, text?: string) => {
if(langKey) {
part = plain ? I18n.format(langKey, true) : i18n(langKey);
}
if(plain) {
parts.push(part);
} else {
@ -2538,7 +2539,7 @@ export class AppMessagesManager { @@ -2538,7 +2539,7 @@ export class AppMessagesManager {
if(usingFullAlbum) {
text = this.getAlbumText(message.grouped_id).message;
addPart(i18n('AttachAlbum'), text);
addPart('AttachAlbum', undefined, text);
}
} else {
usingFullAlbum = false;
@ -2548,36 +2549,50 @@ export class AppMessagesManager { @@ -2548,36 +2549,50 @@ export class AppMessagesManager {
const media = message.media;
switch(media._) {
case 'messageMediaPhoto':
addPart(i18n('AttachPhoto'), message.message);
addPart('AttachPhoto', undefined, message.message);
break;
case 'messageMediaDice':
addPart(plain ? media.emoticon : RichTextProcessor.wrapEmojiText(media.emoticon));
addPart(undefined, plain ? media.emoticon : RichTextProcessor.wrapEmojiText(media.emoticon));
break;
case 'messageMediaVenue': {
const text = plain ? media.title : RichTextProcessor.wrapEmojiText(media.title);
addPart('AttachLocation', undefined, text);
parts.push(htmlToDocumentFragment(text) as any);
break;
}
case 'messageMediaGeo':
addPart(i18n('AttachLiveLocation'));
addPart('AttachLocation');
break;
case 'messageMediaGeoLive':
addPart('AttachLiveLocation');
break;
case 'messageMediaPoll':
addPart(plain ? '📊' + ' ' + (media.poll.question || 'poll') : media.poll.rReply);
addPart(undefined, plain ? '📊' + ' ' + (media.poll.question || 'poll') : media.poll.rReply);
break;
case 'messageMediaContact':
addPart(i18n('AttachContact'));
addPart('AttachContact');
break;
case 'messageMediaGame': {
const prefix = '🎮' + ' ';
addPart(undefined, plain ? prefix + media.game.title : RichTextProcessor.wrapEmojiText(prefix + media.game.title));
break;
}
case 'messageMediaDocument':
let document = media.document;
if(document.type === 'video') {
addPart(i18n('AttachVideo'), message.message);
addPart('AttachVideo', undefined, message.message);
} else if(document.type === 'voice') {
addPart(i18n('AttachAudio'), message.message);
addPart('AttachAudio', undefined, message.message);
} else if(document.type === 'gif') {
addPart(i18n('AttachGif'), message.message);
addPart('AttachGif', undefined, message.message);
} else if(document.type === 'round') {
addPart(i18n('AttachRound'), message.message);
addPart('AttachRound', undefined, message.message);
} else if(document.type === 'sticker') {
addPart(((plain ? document.stickerEmojiRaw : document.stickerEmoji) || '') + 'Sticker');
addPart(undefined, ((plain ? document.stickerEmojiRaw : document.stickerEmoji) || '') + 'Sticker');
text = '';
} else {
addPart(document.file_name, message.message);
addPart(document.file_name, undefined, message.message);
}
break;
@ -2593,7 +2608,7 @@ export class AppMessagesManager { @@ -2593,7 +2608,7 @@ export class AppMessagesManager {
if(message.action) {
const actionWrapped = this.wrapMessageActionTextNew(message, plain);
if(actionWrapped) {
addPart(actionWrapped);
addPart(undefined, actionWrapped);
}
}
@ -2699,6 +2714,7 @@ export class AppMessagesManager { @@ -2699,6 +2714,7 @@ export class AppMessagesManager {
case 'messageActionPinMessage':
case 'messageActionContactSignUp':
case 'messageActionChatReturn':
case 'messageActionChatLeave':
case 'messageActionChatJoined':
case 'messageActionChatCreate':
@ -4305,16 +4321,16 @@ export class AppMessagesManager { @@ -4305,16 +4321,16 @@ export class AppMessagesManager {
case 'updateChannelReadMessagesContents':
case 'updateReadMessagesContents': {
const channelId = (update as Update.updateChannelReadMessagesContents).channel_id;
const peerId = channelId ? -channelId : this.getMessageById(update.messages[0]).peerId;
const messages: number[] = update.messages;
for(const messageId of messages) {
const message = this.getMessageByPeer(peerId, messageId);
const mids = (update as Update.updateReadMessagesContents).messages.map(id => this.generateMessageId(id));
const peerId = channelId ? -channelId : this.getMessageById(mids[0]).peerId;
for(const mid of mids) {
const message = this.getMessageByPeer(peerId, mid);
if(!message.deleted) {
delete message.pFlags.media_unread;
}
}
rootScope.broadcast('messages_media_read', {peerId, mids: messages.map(id => this.generateMessageId(id))});
rootScope.broadcast('messages_media_read', {peerId, mids});
break;
}
@ -5289,5 +5305,5 @@ export class AppMessagesManager { @@ -5289,5 +5305,5 @@ export class AppMessagesManager {
}
const appMessagesManager = new AppMessagesManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appMessagesManager = appMessagesManager);
MOUNT_CLASS_TO.appMessagesManager = appMessagesManager;
export default appMessagesManager;

2
src/lib/appManagers/appNotificationsManager.ts

@ -717,5 +717,5 @@ export class AppNotificationsManager { @@ -717,5 +717,5 @@ export class AppNotificationsManager {
}
const appNotificationsManager = new AppNotificationsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appNotificationsManager = appNotificationsManager);
MOUNT_CLASS_TO.appNotificationsManager = appNotificationsManager;
export default appNotificationsManager;

2
src/lib/appManagers/appPeersManager.ts

@ -288,5 +288,5 @@ export class AppPeersManager { @@ -288,5 +288,5 @@ export class AppPeersManager {
}
const appPeersManager = new AppPeersManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appPeersManager = appPeersManager);
MOUNT_CLASS_TO.appPeersManager = appPeersManager;
export default appPeersManager;

2
src/lib/appManagers/appPhotosManager.ts

@ -397,5 +397,5 @@ export class AppPhotosManager { @@ -397,5 +397,5 @@ export class AppPhotosManager {
}
const appPhotosManager = new AppPhotosManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appPhotosManager = appPhotosManager);
MOUNT_CLASS_TO.appPhotosManager = appPhotosManager;
export default appPhotosManager;

2
src/lib/appManagers/appPollsManager.ts

@ -239,5 +239,5 @@ export class AppPollsManager { @@ -239,5 +239,5 @@ export class AppPollsManager {
}
const appPollsManager = new AppPollsManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appPollsManager = appPollsManager);
MOUNT_CLASS_TO.appPollsManager = appPollsManager;
export default appPollsManager;

2
src/lib/appManagers/appPrivacyManager.ts

@ -124,5 +124,5 @@ export class AppPrivacyManager { @@ -124,5 +124,5 @@ export class AppPrivacyManager {
}
const appPrivacyManager = new AppPrivacyManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appPrivacyManager = appPrivacyManager);
MOUNT_CLASS_TO.appPrivacyManager = appPrivacyManager;
export default appPrivacyManager;

2
src/lib/appManagers/appStateManager.ts

@ -281,5 +281,5 @@ export class AppStateManager extends EventListenerBase<{ @@ -281,5 +281,5 @@ export class AppStateManager extends EventListenerBase<{
//console.trace('appStateManager include');
const appStateManager = new AppStateManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appStateManager = appStateManager);
MOUNT_CLASS_TO.appStateManager = appStateManager;
export default appStateManager;

2
src/lib/appManagers/appStickersManager.ts

@ -280,5 +280,5 @@ export class AppStickersManager { @@ -280,5 +280,5 @@ export class AppStickersManager {
}
const appStickersManager = new AppStickersManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appStickersManager = appStickersManager);
MOUNT_CLASS_TO.appStickersManager = appStickersManager;
export default appStickersManager;

2
src/lib/appManagers/appUsersManager.ts

@ -794,5 +794,5 @@ export class AppUsersManager { @@ -794,5 +794,5 @@ export class AppUsersManager {
}
const appUsersManager = new AppUsersManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appUsersManager = appUsersManager);
MOUNT_CLASS_TO.appUsersManager = appUsersManager;
export default appUsersManager

2
src/lib/cacheStorage.ts

@ -117,5 +117,5 @@ export default class CacheStorageController { @@ -117,5 +117,5 @@ export default class CacheStorageController {
}
//const cacheStorage = new CacheStorageController();
//MOUNT_CLASS_TO && (MOUNT_CLASS_TO.cacheStorage = cacheStorage);
//MOUNT_CLASS_TO.cacheStorage = cacheStorage;
//export default cacheStorage;

2
src/lib/config.ts

@ -20,5 +20,5 @@ const Config = { @@ -20,5 +20,5 @@ const Config = {
TLD,
MediaSizes: mediaSizes
};
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.Config = Config);
MOUNT_CLASS_TO.Config = Config;
export default Config;

2
src/lib/crypto/cryptoworker.ts

@ -125,5 +125,5 @@ class CryptoWorker extends CryptoWorkerMethods { @@ -125,5 +125,5 @@ class CryptoWorker extends CryptoWorkerMethods {
}
const cryptoWorker = new CryptoWorker();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.CryptoWorker = cryptoWorker);
MOUNT_CLASS_TO.CryptoWorker = cryptoWorker;
export default cryptoWorker;

2
src/lib/langPack.ts

@ -330,4 +330,4 @@ export function join(elements: HTMLElement[], useLast = true) { @@ -330,4 +330,4 @@ export function join(elements: HTMLElement[], useLast = true) {
return arr;
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.I18n = I18n);
MOUNT_CLASS_TO.I18n = I18n;

2
src/lib/lottieLoader.ts

@ -748,5 +748,5 @@ class LottieLoader { @@ -748,5 +748,5 @@ class LottieLoader {
}
const lottieLoader = new LottieLoader();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.lottieLoader = lottieLoader);
MOUNT_CLASS_TO.lottieLoader = lottieLoader;
export default lottieLoader;

2
src/lib/mtproto/apiFileManager.ts

@ -574,5 +574,5 @@ export class ApiFileManager { @@ -574,5 +574,5 @@ export class ApiFileManager {
}
const apiFileManager = new ApiFileManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiFileManager = apiFileManager);
MOUNT_CLASS_TO.apiFileManager = apiFileManager;
export default apiFileManager;

6
src/lib/mtproto/apiManager.ts

@ -12,7 +12,7 @@ import type { MethodDeclMap } from '../../layer'; @@ -12,7 +12,7 @@ import type { MethodDeclMap } from '../../layer';
import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePromise';
import { bytesFromHex, bytesToHex } from '../../helpers/bytes';
//import { clamp } from '../../helpers/number';
import { isSafari } from '../../helpers/userAgent';
import { ctx, isSafari } from '../../helpers/userAgent';
import App from '../../config/app';
import { MOUNT_CLASS_TO } from '../../config/debug';
@ -275,7 +275,7 @@ export class ApiManager { @@ -275,7 +275,7 @@ export class ApiManager {
});
const startTime = Date.now();
const interval = MOUNT_CLASS_TO.setInterval(() => {
const interval = ctx.setInterval(() => {
this.log.error('Request is still processing:', method, params, options, 'time:', (Date.now() - startTime) / 1000);
//this.cachedUploadNetworkers[2].requestMessageStatus();
}, 5e3);
@ -426,5 +426,5 @@ export class ApiManager { @@ -426,5 +426,5 @@ export class ApiManager {
}
const apiManager = new ApiManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiManager = apiManager);
MOUNT_CLASS_TO.apiManager = apiManager;
export default apiManager;

2
src/lib/mtproto/mtproto.service.ts

@ -239,4 +239,4 @@ function alignLimit(limit: number) { @@ -239,4 +239,4 @@ function alignLimit(limit: number) {
//export default () => {};
//MOUNT_CLASS_TO && (MOUNT_CLASS_TO.onFetch = onFetch);
//MOUNT_CLASS_TO.onFetch = onFetch;

2
src/lib/mtproto/mtprotoworker.ts

@ -475,5 +475,5 @@ export class ApiManagerProxy extends CryptoWorkerMethods { @@ -475,5 +475,5 @@ export class ApiManagerProxy extends CryptoWorkerMethods {
}
const apiManagerProxy = new ApiManagerProxy();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.apiManagerProxy = apiManagerProxy);
MOUNT_CLASS_TO.apiManagerProxy = apiManagerProxy;
export default apiManagerProxy;

2
src/lib/mtproto/passwordManager.ts

@ -104,5 +104,5 @@ export class PasswordManager { @@ -104,5 +104,5 @@ export class PasswordManager {
}
const passwordManager = new PasswordManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.passwordManager = passwordManager);
MOUNT_CLASS_TO.passwordManager = passwordManager;
export default passwordManager;

2
src/lib/mtproto/referenceDatabase.ts

@ -115,5 +115,5 @@ class ReferenceDatabase { @@ -115,5 +115,5 @@ class ReferenceDatabase {
}
const referenceDatabase = new ReferenceDatabase();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.referenceDatabase = referenceDatabase);
MOUNT_CLASS_TO.referenceDatabase = referenceDatabase;
export default referenceDatabase;

2
src/lib/mtproto/timeManager.ts

@ -66,5 +66,5 @@ export class TimeManager { @@ -66,5 +66,5 @@ export class TimeManager {
}
const timeManager = new TimeManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.timeManager = timeManager);
MOUNT_CLASS_TO.timeManager = timeManager;
export default timeManager;

4
src/lib/mtproto/tl_utils.ts

@ -811,6 +811,6 @@ class TLDeserialization { @@ -811,6 +811,6 @@ class TLDeserialization {
}
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.TLDeserialization = TLDeserialization);
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.TLSerialization = TLSerialization);
MOUNT_CLASS_TO.TLDeserialization = TLDeserialization;
MOUNT_CLASS_TO.TLSerialization = TLSerialization;
export { TLDeserialization, TLSerialization };

2
src/lib/opusDecodeController.ts

@ -173,5 +173,5 @@ export class OpusDecodeController { @@ -173,5 +173,5 @@ export class OpusDecodeController {
}
const opusDecodeController = new OpusDecodeController();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.opusDecodeController = opusDecodeController);
MOUNT_CLASS_TO.opusDecodeController = opusDecodeController;
export default opusDecodeController;

2
src/lib/richtextprocessor.ts

@ -747,7 +747,7 @@ namespace RichTextProcessor { @@ -747,7 +747,7 @@ namespace RichTextProcessor {
}
}
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.RichTextProcessor = RichTextProcessor);
MOUNT_CLASS_TO.RichTextProcessor = RichTextProcessor;
export {RichTextProcessor};
export default RichTextProcessor;

2
src/lib/rootScope.ts

@ -159,5 +159,5 @@ class RootScope extends EventListenerBase<any> { @@ -159,5 +159,5 @@ class RootScope extends EventListenerBase<any> {
}
const rootScope = new RootScope();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.rootScope = rootScope);
MOUNT_CLASS_TO.rootScope = rootScope;
export default rootScope;

2
src/lib/sessionStorage.ts

@ -24,5 +24,5 @@ const sessionStorage = new AppStorage<{ @@ -24,5 +24,5 @@ const sessionStorage = new AppStorage<{
} & State>({
storeName: 'session'
});
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.appStorage = sessionStorage);
MOUNT_CLASS_TO.appStorage = sessionStorage;
export default sessionStorage;

2
src/lib/webp/webpWorkerController.ts

@ -66,5 +66,5 @@ export class WebpWorkerController { @@ -66,5 +66,5 @@ export class WebpWorkerController {
}
const webpWorkerController = new WebpWorkerController();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.webpWorkerController = webpWorkerController);
MOUNT_CLASS_TO.webpWorkerController = webpWorkerController;
export default webpWorkerController;

2
src/pages/pagesManager.ts

@ -46,5 +46,5 @@ class PagesManager { @@ -46,5 +46,5 @@ class PagesManager {
}
const pagesManager = new PagesManager();
MOUNT_CLASS_TO && (MOUNT_CLASS_TO.pagesManager = pagesManager);
MOUNT_CLASS_TO.pagesManager = pagesManager;
export default pagesManager;

8
src/scss/partials/_chat.scss

@ -1065,7 +1065,13 @@ $chat-helper-size: 39px; @@ -1065,7 +1065,13 @@ $chat-helper-size: 39px;
}
@include respond-to(handhelds) {
padding: 0 .75rem 0 .5rem;
padding: 0 .5rem;
.is-out {
.bubble-content-wrapper {
margin-right: .25rem;
}
}
html.is-mac & {
-webkit-user-select: none;

Loading…
Cancel
Save