Temp commit
This commit is contained in:
parent
7c73101ef4
commit
8f6a414de4
@ -1820,7 +1820,11 @@ export default class ChatBubbles {
|
|||||||
|
|
||||||
bubble.className = 'bubble service';
|
bubble.className = 'bubble service';
|
||||||
|
|
||||||
bubbleContainer.innerHTML = `<div class="service-msg">${message.rReply}</div>`;
|
bubbleContainer.innerHTML = '';
|
||||||
|
const s = document.createElement('div');
|
||||||
|
s.classList.add('service-msg');
|
||||||
|
s.append(this.appMessagesManager.wrapMessageActionTextNew(message));
|
||||||
|
bubbleContainer.append(s);
|
||||||
|
|
||||||
if(updatePosition) {
|
if(updatePosition) {
|
||||||
this.renderMessagesQueue(message, bubble, reverse, loadPromises);
|
this.renderMessagesQueue(message, bubble, reverse, loadPromises);
|
||||||
|
25
src/lang.ts
25
src/lang.ts
@ -41,6 +41,21 @@ const lang = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// * android
|
// * android
|
||||||
|
ActionCreateChannel: "Channel created",
|
||||||
|
ActionCreateGroup: "un1 created the group",
|
||||||
|
ActionChangedTitle: "un1 changed the group name to un2",
|
||||||
|
ActionRemovedPhoto: "un1 removed the group photo",
|
||||||
|
ActionChangedPhoto: "un1 changed the group photo",
|
||||||
|
ActionChangedVideo: "un1 changed the group video",
|
||||||
|
ActionAddUser: "un1 added un2",
|
||||||
|
ActionAddUserSelf: "un1 returned to the group",
|
||||||
|
ActionAddUserSelfMega: "un1 joined the group",
|
||||||
|
ActionAddUserSelfYou: "You returned to the group",
|
||||||
|
ActionLeftUser: "un1 left the group",
|
||||||
|
ActionKickUser: "un1 removed un2",
|
||||||
|
ActionInviteUser: "un1 joined the group via invite link",
|
||||||
|
ActionPinnedNoText: "un1 pinned a message",
|
||||||
|
ActionMigrateFromGroup: "This group was upgraded to a supergroup",
|
||||||
FilterAlwaysShow: 'Include Chats',
|
FilterAlwaysShow: 'Include Chats',
|
||||||
FilterNeverShow: 'Exclude Chats',
|
FilterNeverShow: 'Exclude Chats',
|
||||||
FilterInclude: 'Included Chats',
|
FilterInclude: 'Included Chats',
|
||||||
@ -125,8 +140,18 @@ const lang = {
|
|||||||
WhoCanAddMe: "Who can add me to group chats?",
|
WhoCanAddMe: "Who can add me to group chats?",
|
||||||
ArchivedChats: "Archived Chats",
|
ArchivedChats: "Archived Chats",
|
||||||
Cancel: "Cancel",
|
Cancel: "Cancel",
|
||||||
|
HistoryCleared: "History was cleared",
|
||||||
|
|
||||||
// * macos
|
// * macos
|
||||||
|
"Chat.Service.PeerJoinedTelegram": "%@ joined Telegram",
|
||||||
|
"Chat.Service.Channel.UpdatedTitle": "Channel renamed to \"%@\"",
|
||||||
|
"Chat.Service.Channel.UpdatedPhoto": "Channel photo updated",
|
||||||
|
"Chat.Service.Channel.RemovedPhoto": "Channel photo removed",
|
||||||
|
"Chat.Service.BotPermissionAllowed": "You allowed this bot to message you when you logged in on %@",
|
||||||
|
"ChatList.Service.Call.incoming": "Incoming Call (%@)",
|
||||||
|
"ChatList.Service.Call.outgoing": "Outgoing Call (%@)",
|
||||||
|
"ChatList.Service.Call.Cancelled": "Cancelled Call",
|
||||||
|
"ChatList.Service.Call.Missed": "Missed Call",
|
||||||
"ChatList.Filter.Header": "Create folders for different groups of chats and quickly switch between them.",
|
"ChatList.Filter.Header": "Create folders for different groups of chats and quickly switch between them.",
|
||||||
"ChatList.Filter.NewTitle": "Create Folder",
|
"ChatList.Filter.NewTitle": "Create Folder",
|
||||||
"ChatList.Filter.List.Title": "Chat Folders",
|
"ChatList.Filter.List.Title": "Chat Folders",
|
||||||
|
@ -8,7 +8,7 @@ import { randomLong } from "../../helpers/random";
|
|||||||
import { splitStringByLength, limitSymbols } from "../../helpers/string";
|
import { splitStringByLength, limitSymbols } from "../../helpers/string";
|
||||||
import { Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update } from "../../layer";
|
import { Chat, ChatFull, Dialog as MTDialog, DialogPeer, DocumentAttribute, InputMedia, InputMessage, InputPeerNotifySettings, InputSingleMedia, Message, MessageAction, MessageEntity, MessageFwdHeader, MessageReplies, MessageReplyHeader, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, NotifyPeer, PeerNotifySettings, PhotoSize, SendMessageAction, Update } from "../../layer";
|
||||||
import { InvokeApiOptions } from "../../types";
|
import { InvokeApiOptions } from "../../types";
|
||||||
import { langPack } from "../langPack";
|
import I18n, { langPack, LangPackKey, _i18n } from "../langPack";
|
||||||
import { logger, LogLevels } from "../logger";
|
import { logger, LogLevels } from "../logger";
|
||||||
import type { ApiFileManager } from '../mtproto/apiFileManager';
|
import type { ApiFileManager } from '../mtproto/apiFileManager';
|
||||||
//import apiManager from '../mtproto/apiManager';
|
//import apiManager from '../mtproto/apiManager';
|
||||||
@ -2681,6 +2681,105 @@ export class AppMessagesManager {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public wrapMessageActionTextNew(message: any, plain: true): string;
|
||||||
|
public wrapMessageActionTextNew(message: any, plain?: false): HTMLElement;
|
||||||
|
public wrapMessageActionTextNew(message: any, plain?: boolean): HTMLElement | string {
|
||||||
|
const element: HTMLElement = plain ? undefined : document.createElement('span');
|
||||||
|
const action = message.action as MessageAction;
|
||||||
|
|
||||||
|
if((action as MessageAction.messageActionCustomAction).message) {
|
||||||
|
const richText = RichTextProcessor.wrapRichText((action as MessageAction.messageActionCustomAction).message, {noLinebreaks: true});
|
||||||
|
if(plain) {
|
||||||
|
return richText;
|
||||||
|
} else {
|
||||||
|
element.innerHTML = richText;
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let _ = action._;
|
||||||
|
//let suffix = '';
|
||||||
|
let langPackKey: LangPackKey = '';
|
||||||
|
let args: any[];
|
||||||
|
|
||||||
|
const getNameDivHTML = (peerId: number) => {
|
||||||
|
const title = appPeersManager.getPeerTitle(peerId);
|
||||||
|
return title ? (plain ? title + ' ' : `<div class="name inline" data-peer-id="${peerId}">${title}</div> `) : '';
|
||||||
|
};
|
||||||
|
|
||||||
|
switch(action._) {
|
||||||
|
case "messageActionPhoneCall": {
|
||||||
|
_ += '.' + (action as any).type;
|
||||||
|
|
||||||
|
const duration = action.duration || 1;
|
||||||
|
const d: string[] = [];
|
||||||
|
|
||||||
|
d.push(duration % 60 + ' s');
|
||||||
|
if(duration >= 60) d.push((duration / 60 | 0) + ' min');
|
||||||
|
//if(duration >= 3600) d.push((duration / 3600 | 0) + ' h');
|
||||||
|
|
||||||
|
langPackKey = langPack[_];
|
||||||
|
args = [d.reverse().join(' ')];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'messageActionChatJoinedByLink': {
|
||||||
|
langPackKey = langPack[_];
|
||||||
|
args = [getNameDivHTML(message.fromId)];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'messageActionChatDeleteUser':
|
||||||
|
// @ts-ignore
|
||||||
|
case 'messageActionChatAddUsers':
|
||||||
|
case 'messageActionChatAddUser': {
|
||||||
|
const users: number[] = (action as MessageAction.messageActionChatAddUser).users
|
||||||
|
|| [(action as MessageAction.messageActionChatDeleteUser).user_id];
|
||||||
|
|
||||||
|
langPackKey = langPack[_];
|
||||||
|
args = [getNameDivHTML(message.fromId), users.map((userId: number) => getNameDivHTML(userId).trim()).join(', ')];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'messageActionBotAllowed': {
|
||||||
|
const anchorHTML = RichTextProcessor.wrapRichText(action.domain, {
|
||||||
|
entities: [{
|
||||||
|
_: 'messageEntityUrl',
|
||||||
|
length: action.domain.length,
|
||||||
|
offset: 0
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
|
||||||
|
langPackKey = langPack[_];
|
||||||
|
args = [anchorHTML];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
langPackKey = langPack[_] || `[${action._}]`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!langPackKey) {
|
||||||
|
langPackKey = langPack[_];
|
||||||
|
if(langPackKey === undefined) {
|
||||||
|
langPackKey = '[' + _ + ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(plain) {
|
||||||
|
return I18n.getString(langPackKey, args);
|
||||||
|
} else {
|
||||||
|
return _i18n(element, langPackKey, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
//str = !langPackKey || langPackKey[0].toUpperCase() === langPackKey[0] ? langPackKey : getNameDivHTML(message.fromId) + langPackKey + (suffix ? ' ' : '');
|
||||||
|
}
|
||||||
|
|
||||||
|
//this.log('message action:', action);
|
||||||
|
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
public editPeerFolders(peerIds: number[], folderId: number) {
|
public editPeerFolders(peerIds: number[], folderId: number) {
|
||||||
apiManager.invokeApi('folders.editPeerFolders', {
|
apiManager.invokeApi('folders.editPeerFolders', {
|
||||||
folder_peers: peerIds.map(peerId => {
|
folder_peers: peerIds.map(peerId => {
|
||||||
|
@ -5,34 +5,34 @@ import { LangPackDifference, LangPackString } from "../layer";
|
|||||||
import apiManager from "./mtproto/mtprotoworker";
|
import apiManager from "./mtproto/mtprotoworker";
|
||||||
import sessionStorage from "./sessionStorage";
|
import sessionStorage from "./sessionStorage";
|
||||||
|
|
||||||
export const langPack: {[actionType: string]: string} = {
|
export const langPack: {[actionType: string]: LangPackKey} = {
|
||||||
"messageActionChatCreate": "created the group",
|
"messageActionChatCreate": "ActionCreateGroup",
|
||||||
"messageActionChatEditTitle": "changed group name",
|
"messageActionChatEditTitle": "ActionChangedTitle",
|
||||||
"messageActionChatEditPhoto": "changed group photo",
|
"messageActionChatEditPhoto": "ActionChangedPhoto",
|
||||||
"messageActionChatDeletePhoto": "removed group photo",
|
"messageActionChatDeletePhoto": "ActionRemovedPhoto",
|
||||||
"messageActionChatReturn": "returned to group",
|
"messageActionChatReturn": "ActionAddUserSelf",
|
||||||
"messageActionChatJoined": "joined the group",
|
"messageActionChatJoined": "ActionAddUserSelfMega",
|
||||||
"messageActionChatAddUser": "invited {}",
|
"messageActionChatAddUser": "ActionAddUser",
|
||||||
"messageActionChatAddUsers": "invited {} users",
|
"messageActionChatAddUsers": "ActionAddUser",
|
||||||
"messageActionChatLeave": "left the group",
|
"messageActionChatLeave": "ActionLeftUser",
|
||||||
"messageActionChatDeleteUser": "removed user {}",
|
"messageActionChatDeleteUser": "ActionKickUser",
|
||||||
"messageActionChatJoinedByLink": "joined the group via invite link",
|
"messageActionChatJoinedByLink": "ActionInviteUser",
|
||||||
"messageActionPinMessage": "pinned message",
|
"messageActionPinMessage": "ActionPinnedNoText",
|
||||||
"messageActionContactSignUp": "joined Telegram",
|
"messageActionContactSignUp": "Chat.Service.PeerJoinedTelegram",
|
||||||
"messageActionChannelCreate": "Channel created",
|
"messageActionChannelCreate": "ActionCreateChannel",
|
||||||
"messageActionChannelEditTitle": "Channel renamed",
|
"messageActionChannelEditTitle": "Chat.Service.Channel.UpdatedTitle",
|
||||||
"messageActionChannelEditPhoto": "Channel photo updated",
|
"messageActionChannelEditPhoto": "Chat.Service.Channel.UpdatedPhoto",
|
||||||
"messageActionChannelDeletePhoto": "Channel photo removed",
|
"messageActionChannelDeletePhoto": "Chat.Service.Channel.RemovedPhoto",
|
||||||
"messageActionHistoryClear": "History was cleared",
|
"messageActionHistoryClear": "HistoryCleared",
|
||||||
|
|
||||||
"messageActionChannelMigrateFrom": "",
|
"messageActionChannelMigrateFrom": "ActionMigrateFromGroup",
|
||||||
|
|
||||||
"messageActionPhoneCall.in_ok": "Incoming Call",
|
"messageActionPhoneCall.in_ok": "ChatList.Service.Call.incoming",
|
||||||
"messageActionPhoneCall.out_ok": "Outgoing Call",
|
"messageActionPhoneCall.out_ok": "ChatList.Service.Call.outgoing",
|
||||||
"messageActionPhoneCall.in_missed": "Missed Call",
|
"messageActionPhoneCall.in_missed": "ChatList.Service.Call.Missed",
|
||||||
"messageActionPhoneCall.out_missed": "Cancelled Call",
|
"messageActionPhoneCall.out_missed": "ChatList.Service.Call.Cancelled",
|
||||||
|
|
||||||
"messageActionBotAllowed": "You allowed this bot to message you when logged in {}"
|
"messageActionBotAllowed": "Chat.Service.BotPermissionAllowed"
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LangPackKey = string | keyof typeof lang;
|
export type LangPackKey = string | keyof typeof lang;
|
||||||
@ -109,11 +109,11 @@ namespace I18n {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const polyfillPromise = (function checkIfPolyfillNeeded() {
|
export const polyfillPromise = (function checkIfPolyfillNeeded() {
|
||||||
if(typeof(Intl) !== 'undefined' && typeof(Intl.PluralRules) !== 'undefined' && false) {
|
if(typeof(Intl) !== 'undefined' && typeof(Intl.PluralRules) !== 'undefined'/* && false */) {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
return import('./pluralPolyfill').then(_Intl => {
|
return import('./pluralPolyfill').then((_Intl) => {
|
||||||
(window as any).Intl = _Intl.default;
|
(window as any).Intl = Object.assign(typeof(Intl) !== 'undefined' ? Intl : {}, _Intl.default);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
@ -167,15 +167,16 @@ namespace I18n {
|
|||||||
.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>');
|
.replace(/\*\*(.+?)\*\*/g, '<b>$1</b>');
|
||||||
|
|
||||||
if(args?.length) {
|
if(args?.length) {
|
||||||
out = out.replace(/%\d\$.|%./g, (match, offset, string) => {
|
let i = 0;
|
||||||
return '' + args.shift();
|
out = out.replace(/un\d|%\d\$.|%./g, (match, offset, string) => {
|
||||||
|
return '' + args[i++];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
const weakMap: WeakMap<HTMLElement, IntlElement> = new WeakMap();
|
export const weakMap: WeakMap<HTMLElement, IntlElement> = new WeakMap();
|
||||||
|
|
||||||
export type IntlElementOptions = {
|
export type IntlElementOptions = {
|
||||||
element?: HTMLElement,
|
element?: HTMLElement,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user