Fix popup forward load count

New bubble time layout
This commit is contained in:
morethanwords 2020-10-28 18:11:57 +02:00
parent 2db5fadcf9
commit c1a419909b
17 changed files with 160 additions and 193 deletions

View File

@ -301,7 +301,8 @@ export default class AppSelectPeers {
if(promises.length) {
promise.then(this.checkForTriggers);
}
return promise
return promise;
}
private renderResults(peerIDs: number[]) {

View File

@ -218,12 +218,12 @@ export class ChatInput {
if(!value.trim() && !this.serializeNodes(Array.from(this.messageInput.childNodes)).trim()) {
this.messageInput.innerHTML = '';
appMessagesManager.setTyping('sendMessageCancelAction');
appMessagesManager.setTyping($rootScope.selectedPeerID, 'sendMessageCancelAction');
} else {
const time = Date.now();
if(time - this.lastTimeType >= 6000) {
this.lastTimeType = time;
appMessagesManager.setTyping('sendMessageTypingAction');
appMessagesManager.setTyping($rootScope.selectedPeerID, 'sendMessageTypingAction');
}
}

View File

@ -8,7 +8,7 @@ export namespace MessageRender {
}; */
export const setTime = (message: Message, bubble: HTMLElement, bubbleContainer: HTMLElement, messageDiv: HTMLElement) => {
let date = new Date(message.date * 1000);
const date = new Date(message.date * 1000);
let time = ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2);
if(message.views) {
@ -16,7 +16,7 @@ export namespace MessageRender {
time = formatNumber(message.views, 1) + ' <i class="tgico-channelviews"></i> ' + time;
if(!message.savedFrom) {
let forward = document.createElement('div');
const forward = document.createElement('div');
forward.classList.add('bubble-beside-button', 'forward');
forward.innerHTML = `
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24">
@ -35,14 +35,10 @@ export namespace MessageRender {
time = '<i class="edited">edited</i> ' + time;
}
let timeSpan = document.createElement('span');
timeSpan.classList.add('time');
let timeInner = document.createElement('div');
timeInner.classList.add('inner', 'tgico');
timeInner.innerHTML = time;
const timeSpan = document.createElement('span');
timeSpan.classList.add('time', 'tgico');
timeSpan.innerHTML = `${time}<div class="inner tgico">${time}</div>`;
timeSpan.appendChild(timeInner);
messageDiv.append(timeSpan);
return timeSpan;

View File

@ -24,6 +24,7 @@ export default class PopupForward extends PopupElement {
appImManager.chatInputC.initMessagesForward(mids.slice());
}, ['dialogs', 'contacts'], () => {
this.show();
this.selector.checkForTriggers(); // ! due to zero height before mounting
if(!isTouchSupported) {
this.selector.input.focus();

View File

@ -320,13 +320,13 @@ export class AppChatsManager {
return this.cachedPhotoLocations[id];
}
public getChatString(id: number) {
/* public getChatString(id: number) {
const chat = this.getChat(id);
if(this.isChannel(id)) {
return (this.isMegagroup(id) ? 's' : 'c') + id + '_' + chat.access_hash;
}
return 'g' + id;
}
} */
public getChatMembersString(id: number) {
const chat = this.getChat(id);
@ -353,7 +353,7 @@ export class AppChatsManager {
chatFull.rAbout = RichTextProcessor.wrapRichText(chatFull.about, {noLinebreaks: true});
}
chatFull.peerString = this.getChatString(id);
//chatFull.peerString = this.getChatString(id);
chatFull.chat = chat;
return chatFull;
@ -487,15 +487,17 @@ export class AppChatsManager {
}
}
onChatUpdated = (chatID: number, updates: any) => {
private onChatUpdated = (chatID: number, updates: any) => {
console.log('onChatUpdated', chatID, updates);
apiUpdatesManager.processUpdateMessage(updates);
if(updates &&
updates.updates &&
updates.updates.length &&
/* updates.updates &&
updates.updates.length && */
this.isChannel(chatID)) {
appProfileManager.invalidateChannelParticipants(chatID);
}
}
};
public leaveChannel(id: number) {
return apiManager.invokeApi('channels.leaveChannel', {

View File

@ -1326,6 +1326,7 @@ export class AppImManager {
this.chatInput.style.display = '';
this.chatInput.classList.toggle('is-hidden', !canWrite);
this.bubblesContainer.classList.toggle('is-chat-input-hidden', !canWrite);
this.chatInputC.messageInput.toggleAttribute('contenteditable', canWrite);
// const noTransition = [this.columnEl/* appSidebarRight.sidebarEl, this.backgroundEl,
// this.bubblesContainer, this.chatInput, this.chatInner,
@ -2140,23 +2141,13 @@ export class AppImManager {
});
}
break;
} else if(doc.mime_type == 'audio/ogg') {
let docDiv = wrapDocument(doc, false, false, message.mid);
bubble.classList.remove('is-message-empty');
bubble.classList.add('bubble-audio');
messageDiv.append(docDiv);
processingWebPage = true;
break;
} else {
let docDiv = wrapDocument(doc, false, false, message.mid);
const docDiv = wrapDocument(doc, false, false, message.mid);
bubble.classList.remove('is-message-empty');
messageDiv.append(docDiv);
messageDiv.classList.add((doc.type || 'document') + '-message');
messageDiv.classList.add((doc.type != 'photo' ? doc.type || 'document' : 'document') + '-message');
processingWebPage = true;
break;
@ -2168,14 +2159,14 @@ export class AppImManager {
case 'messageMediaContact': {
//this.log('wrapping contact', message);
let contactDiv = document.createElement('div');
const contactDiv = document.createElement('div');
contactDiv.classList.add('contact');
contactDiv.dataset.peerID = '' + messageMedia.user_id;
messageDiv.classList.add('contact-message');
processingWebPage = true;
let texts = [];
const texts = [];
if(message.media.first_name) texts.push(RichTextProcessor.wrapEmojiText(message.media.first_name));
if(message.media.last_name) texts.push(RichTextProcessor.wrapEmojiText(message.media.last_name));
@ -2185,13 +2176,14 @@ export class AppImManager {
<div class="contact-number">${message.media.phone_number ? '+' + formatPhoneNumber(message.media.phone_number).formatted : 'Unknown phone number'}</div>
</div>`;
let avatarElem = new AvatarElement();
const avatarElem = new AvatarElement();
avatarElem.setAttribute('peer', '' + message.media.user_id);
avatarElem.classList.add('contact-avatar');
contactDiv.prepend(avatarElem);
bubble.classList.remove('is-message-empty');
messageDiv.classList.add('contact-message');
messageDiv.append(contactDiv);
break;
@ -2200,8 +2192,9 @@ export class AppImManager {
case 'messageMediaPoll': {
bubble.classList.remove('is-message-empty');
let pollElement = wrapPoll(message.media.poll.id, message.mid);
const pollElement = wrapPoll(message.media.poll.id, message.mid);
messageDiv.prepend(pollElement);
messageDiv.classList.add('poll-message');
break;
}

View File

@ -1,9 +1,9 @@
import ProgressivePreloader from "../../components/preloader";
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise";
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, Update } from "../../layer";
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, SendMessageAction, Update } from "../../layer";
import { InvokeApiOptions, Modify } from "../../types";
import { bigint, nextRandomInt } from "../bin_utils";
import { logger } from "../logger";
import { logger, LogLevels } from "../logger";
import type { ApiFileManager } from '../mtproto/apiFileManager';
//import apiManager from '../mtproto/apiManager';
import apiManager from '../mtproto/mtprotoworker';
@ -507,7 +507,7 @@ export class AppMessagesManager {
folderID: 0
};
private log = logger('MESSAGES'/* , LogLevels.error */);
private log = logger('MESSAGES'/* , LogLevels.error | LogLevels.debug | LogLevels.log | LogLevels.warn */);
public dialogsStorage = new DialogsStorage();
public filtersStorage = new FiltersStorage();
@ -1168,7 +1168,7 @@ export class AppMessagesManager {
uploadPromise: ReturnType<ApiFileManager['uploadFile']> = null;
const invoke = (flags: number, inputMedia: any) => {
this.setTyping('sendMessageCancelAction');
this.setTyping(peerID, 'sendMessageCancelAction');
return apiManager.invokeApi('messages.sendMedia', {
flags: flags,
@ -1261,7 +1261,7 @@ export class AppMessagesManager {
uploadPromise.addNotifyListener((progress: {done: number, total: number}) => {
this.log('upload progress', progress);
const percents = Math.max(1, Math.floor(100 * progress.done / progress.total));
this.setTyping({_: actionName, progress: percents | 0});
this.setTyping(peerID, {_: actionName, progress: percents | 0});
});
uploadPromise.catch(err => {
@ -1270,7 +1270,7 @@ export class AppMessagesManager {
deferred.resolve();
this.cancelPendingMessage(randomIDS);
this.setTyping('sendMessageCancelAction');
this.setTyping(peerID, 'sendMessageCancelAction');
}
});
@ -1457,7 +1457,7 @@ export class AppMessagesManager {
let inputPeer = appPeersManager.getInputPeerByID(peerID);
let invoke = (multiMedia: any[]) => {
this.setTyping('sendMessageCancelAction');
this.setTyping(peerID, 'sendMessageCancelAction');
return apiManager.invokeApi('messages.sendMultiMedia', {
flags: flags,
@ -1500,7 +1500,7 @@ export class AppMessagesManager {
uploadPromise.addNotifyListener((progress: {done: number, total: number}) => {
this.log('upload progress', progress);
const percents = Math.max(1, Math.floor(100 * progress.done / progress.total));
this.setTyping({_: actionName, progress: percents | 0});
this.setTyping(peerID, {_: actionName, progress: percents | 0});
});
uploadPromise.catch(err => {
@ -3960,7 +3960,7 @@ export class AppMessagesManager {
const foundDialog = this.getDialogByPeerID(peerID);
const hasDialog = foundDialog.length > 0;
const canViewHistory = channel._ == 'channel' && (channel.username || !channel.pFlags.left && !channel.pFlags.kicked) && true || false;
const canViewHistory = channel._ == 'channel' && (channel.username || !channel.pFlags.left && !channel.pFlags.kicked);
const hasHistory = this.historiesStorage[peerID] !== undefined;
if(canViewHistory != hasHistory) {
@ -3974,7 +3974,6 @@ export class AppMessagesManager {
} else {
if(foundDialog[0]) {
this.dialogsStorage.dropDialog(peerID);
//this.dialogsStorage[foundDialog[0].folder_id].splice(foundDialog[1], 1);
$rootScope.$broadcast('dialog_drop', {peerID: peerID, dialog: foundDialog[0]});
}
}
@ -4486,17 +4485,13 @@ export class AppMessagesManager {
}
}
public setTyping(action: any): Promise<boolean> {
public setTyping(peerID: number, _action: any): Promise<boolean> {
if(!$rootScope.myID) return Promise.resolve(false);
if(typeof(action) == 'string') {
action = {_: action};
}
let input = appPeersManager.getInputPeerByID($rootScope.myID);
const action: SendMessageAction = typeof(_action) == 'string' ? {_: _action} : _action;
return apiManager.invokeApi('messages.setTyping', {
peer: input,
action: action
peer: appPeersManager.getInputPeerByID(peerID),
action
}) as Promise<boolean>;
}
}

View File

@ -87,12 +87,12 @@ export class AppPeersManager {
return {_: 'peerChat', chat_id: chatID};
}
public getPeerString(peerID: number) {
/* public getPeerString(peerID: number) {
if(peerID > 0) {
return appUsersManager.getUserString(peerID);
}
return appChatsManager.getChatString(-peerID);
}
} */
public getPeerUsername(peerID: number): string {
if(peerID > 0) {

View File

@ -417,10 +417,10 @@ export class AppUsersManager {
return this.cachedPhotoLocations[id];
}
public getUserString(id: number) {
/* public getUserString(id: number) {
const user = this.getUser(id);
return 'u' + id + (user.access_hash ? '_' + user.access_hash : '');
}
} */
public getUserInput(id: number): InputUser {
const user = this.getUser(id);

View File

@ -16,6 +16,16 @@ import { CancellablePromise, deferredPromise } from '../../helpers/cancellablePr
import $rootScope from '../rootScope';
/// #endif
/* var networker = apiManager.cachedNetworkers.websocket.upload[2];
networker.wrapMtpMessage({
_: 'msgs_state_req',
msg_ids: ["6888292542796810828"]
}, {
notContentRelated: true
}).then(res => {
console.log('status', res);
}); */
//console.error('apiManager included!');
// TODO: если запрос словил флуд, нужно сохранять его параметры и возвращать тот же промис на новый такой же запрос, например - загрузка истории
@ -127,7 +137,17 @@ export class ApiManager {
}
const connectionType: ConnectionType = options.fileDownload ? 'download' : (options.fileUpload ? 'upload' : 'client');
//const connectionType: ConnectionType = 'client';
/// #if MTPROTO_HTTP_UPLOAD
// @ts-ignore
const transportType: TransportType = connectionType == 'upload' ? 'https' : 'websocket';
//const transportType: TransportType = connectionType != 'client' ? 'https' : 'websocket';
/// #else
// @ts-ignore
const transportType = 'websocket';
/// #endif
const transport = dcConfigurator.chooseServer(dcID, connectionType, transportType);
if(!this.cachedNetworkers.hasOwnProperty(transportType)) {

View File

@ -48,7 +48,7 @@ export class DcConfigurator {
const path = Modes.test ? 'apiws_test' : 'apiws';
const chosenServer = 'wss://' + subdomain + '.web.telegram.org/' + path;
const suffix = connectionType == 'upload' ? '-U' : connectionType == 'download' ? '-D' : '';
return new Socket(dcID, chosenServer, connectionType != 'client' ? '-U' : '');
return new Socket(dcID, chosenServer, suffix);
};
private transportHTTP = (dcID: number, connectionType: ConnectionType) => {

View File

@ -116,13 +116,13 @@ export default class MTPNetworker {
const suffix = this.options.fileUpload ? '-U' : this.options.fileDownload ? '-D' : '';
this.upload = this.options.fileUpload || this.options.fileDownload;
//this.log = logger('NET-' + dcID + suffix, this.upload && this.dcID == 1 ? LogLevels.debug | LogLevels.warn | LogLevels.log | LogLevels.error : LogLevels.error);
//this.log = logger('NET-' + dcID + suffix, this.upload && this.dcID == 2 ? LogLevels.debug | LogLevels.warn | LogLevels.log | LogLevels.error : LogLevels.error);
this.log = logger('NET-' + dcID + suffix, LogLevels.log | LogLevels.error);
this.log('constructor'/* , this.authKey, this.authKeyID, this.serverSalt */);
// Test resend after bad_server_salt
/* if(this.dcID == 1 && this.upload) {
timeManager.applyServerTime((Date.now() / 1000 - 86400) | 0);
/* if(this.dcID == 2 && this.upload) {
//timeManager.applyServerTime((Date.now() / 1000 - 86400) | 0);
this.serverSalt[0] = 0;
} */
@ -1284,7 +1284,10 @@ export default class MTPNetworker {
}
delete this.sentMessages[sentMessageID];
} else {
this.log('Rpc result for unknown message:', sentMessageID);
}
break;
}

View File

@ -35,23 +35,30 @@ export default class Obfuscation {
}
////////////////////////initPayload.subarray(60, 62).hex = dcID;
/* initPayload.set(new Uint8Array([161, 208, 67, 71, 118, 109, 20, 111, 113, 255, 134, 10, 159, 241, 7, 44, 217, 82, 187, 76, 108, 131, 200, 186, 33, 57, 177, 251, 52, 34, 18, 54, 65, 105, 37, 89, 38, 20, 47, 168, 126, 181, 24, 138, 212, 68, 60, 150, 225, 37, 181, 4, 201, 50, 72, 151, 168, 143, 204, 169, 81, 187, 241, 23]));
console.log('initPayload', initPayload); */
const reversedPayload = initPayload.slice().reverse();
let encKey = initPayload.slice(8, 40);
let encIv = initPayload.slice(40, 56);
let decKey = reversedPayload.slice(8, 40);
let decIv = reversedPayload.slice(40, 56);
const encKey = initPayload.slice(8, 40);
const encIv = initPayload.slice(40, 56);
const decKey = reversedPayload.slice(8, 40);
const decIv = reversedPayload.slice(40, 56);
/* this.enc = new aesjs.ModeOfOperation.ctr(encKey, new aesjs.Counter(encIv as any));
this.dec = new aesjs.ModeOfOperation.ctr(decKey, new aesjs.Counter(decIv as any)); */
/* console.log('encKey', encKey, encIv);
console.log('decKey', decKey, decIv); */
this.encNew = new CTR(encKey, encIv);
this.decNew = new CTR(decKey, decIv);
initPayload.set(codec.obfuscateTag, 56);
const encrypted = this.encode(initPayload);
//console.log('encrypted', encrypted);
initPayload.set(encrypted.slice(56, 64), 56);
return initPayload;

View File

@ -2,7 +2,7 @@
position: relative;
padding-left: 67px;
min-height: 58px;
max-width: 244px;
max-width: 258px;
overflow: visible!important;
@include respond-to(handhelds) {
@ -10,6 +10,7 @@
}
&-toggle, &-download {
overflow: hidden;
border-radius: 50%;
background-color: $color-blue;
font-size: 0;

View File

@ -336,13 +336,6 @@ $bubble-margin: .25rem;
max-width: 100%;
}
}
&.webpage {
.time {
float: none;
width: 0;
}
}
.preview-resizer {
display: flex;
@ -886,13 +879,7 @@ $bubble-margin: .25rem;
} */
}
.bubble__container .message.audio-message {
.time {
width: unset !important;
}
}
.message.contact-message {
.message.contact-message {
min-width: 200px;
padding-left: 8px;
@ -920,19 +907,11 @@ $bubble-margin: .25rem;
line-height: 1.4;
}
}
.time {
width: unset;
}
}
.message.document-message {
max-width: 325px !important;
.time {
width: unset;
}
.document {
padding-left: 66px;
height: 58px;
@ -950,6 +929,21 @@ $bubble-margin: .25rem;
}
}
.message {
&.document-message, &.audio-message, &.voice-message, &.poll-message, &.contact-message {
.time {
position: absolute;
right: 0;
bottom: 0;
}
}
}
.message.voice-message {
// ! SAFARI FIX BLINK ON SELECTION TRANSFORM !
overflow: visible !important;
}
&.is-message-empty {
.message {
position: absolute;
@ -961,49 +955,48 @@ $bubble-margin: .25rem;
z-index: 2;
.time {
margin-left: 0;
color: #fff;
padding: 0;
display: flex;
align-items: center;
width: auto !important;
padding: 0 2.5px;
line-height: 20px;
.inner {
margin-bottom: 0;
position: relative;
padding: 0 2.5px;
bottom: 0;
display: none;
}
}
}
}
.time {
font-size: .8rem;
color: transparent;
font-size: 12px;
user-select: none;
float: right;
user-select: none;
height: 20px;
line-height: 20px;
line-height: 1;
vertical-align: middle;
/* display: inline-flex;
align-items: center; */
i {
font-size: 1.15rem;
margin-right: .4rem;
/* margin-left: .1rem; */
}
i.edited {
overflow: visible;
font-size: .8rem;
}
.inner {
position: absolute;
bottom: 0;
right: 0;
font-size: 12px;
display: flex;
align-items: center;
line-height: 1;
i {
font-size: 1.15rem;
margin-right: .4rem;
/* margin-left: .1rem; */
}
i.edited {
overflow: visible;
font-size: .8rem;
}
padding: inherit;
}
}
@ -1036,27 +1029,6 @@ $bubble-margin: .25rem;
}
}
&.is-edited.channel-post .time {
min-width: calc(5rem + 46px);
}
&.channel-post .time {
width: 5rem;
}
&.is-edited {
.time {
width: 78px !important;
}
&.emoji-big, &.sticker {
.time {
/* width: 81px !important; */
min-width: unset;
}
}
}
&:not(.forwarded).hide-name, &.emoji-big {
.name {
display: none;
@ -1179,22 +1151,6 @@ $bubble-margin: .25rem;
}
}
.bubble-audio {
.message {
// ! SAFARI FIX BLINK ON SELECTION TRANSFORM !
overflow: visible !important;
}
.time {
width: unset !important;
padding-left: 14px !important;
@include respond-to(handhelds) {
padding-left: 0px !important;
}
}
}
.bubble.is-in {
.bubble__container {
margin-right: auto;
@ -1274,12 +1230,11 @@ $bubble-margin: .25rem;
}
.time {
color: #a3adb6;
/* width: 36px; */
padding-left: 36px;
margin-left: -1px;
padding-right: 8px;
.inner {
padding: 0 7px 0 5px;
color: #a3adb6;
margin-bottom: 4px;
}
}
@ -1421,21 +1376,25 @@ $bubble-margin: .25rem;
}
.time {
color: $darkgreen;
width: 50px;
display: inline-block;
padding-right: 4px;
margin-left: -4px;
.inner {
padding: 0 4px 0 4px;
bottom: 1px;
color: $darkgreen;
bottom: 2px;
}
.tgico:after {
&:after, .inner:after {
font-size: 19px;
vertical-align: middle;
//vertical-align: middle;
margin-left: 1px;
line-height: 16px; // of message
}
}
/* &.is-message-empty .time:after {
margin-bottom: 1px;
} */
&.forwarded {
.name {
@ -1444,19 +1403,19 @@ $bubble-margin: .25rem;
}
&.is-read {
.time .tgico:after {
.time:after, .time .inner:after {
content: $tgico-checks;
}
}
&.is-sent {
.time .tgico:after {
.time:after, .time .inner:after {
content: $tgico-check;
}
}
&.is-sending {
.time .tgico:after {
.time:after, .time .inner:after {
content: $tgico-sending;
}
}
@ -1465,11 +1424,6 @@ $bubble-margin: .25rem;
display: none;
}
&.is-edited .time {
/* width: 85px; */
width: 90px !important;
}
.document-ico:after {
border-top-color: #eeffde;
border-right-color: #eeffde;
@ -1819,7 +1773,7 @@ poll-element {
&-footer {
text-align: center;
margin-top: 7px;
height: 21px;
height: 27px;
}
&-footer-button {
@ -1899,12 +1853,6 @@ poll-element {
cursor: pointer;
}
& + .time {
height: unset !important;
padding-top: 0px !important;
padding-bottom: 7px !important;
}
.circle-hover {
display: flex;
justify-content: center;

View File

@ -24,6 +24,17 @@
object-fit: contain;
}
}
.time {
float: right;
padding: 7px 0px 9px 14px;
font-size: 15px;
color: white;
@include respond-to(handhelds) {
padding: 7px 0px 9px 0px;
}
}
}
&__overlay {
@ -385,17 +396,6 @@ input[type=range] {
align-items: center;
}
.time {
float: right;
padding: 7px 0px 9px 14px;
font-size: 15px;
color: white;
@include respond-to(handhelds) {
padding: 7px 0px 9px 0px;
}
}
.circle .circle-time {
color: #fff;
font-size: 13px;

View File

@ -624,18 +624,18 @@
.selector {
ul {
li > .rp {
margin: 0 8px !important;
padding: 7px 12px !important;
height: 62px;
margin: 0 .5rem;
padding: .5rem .75rem;
height: 3.875rem;
@include respond-to(handhelds) {
margin: 0 !important;
margin: 0;
}
}
.dialog-avatar {
width: 46px;
height: 46px;
width: 2.875rem;
height: 2.875rem;
}
.user-caption {