Fix editing profile
Fix bubble names with via Fix displaying hidden name in media viewer
This commit is contained in:
parent
4e61c4be0b
commit
385650f3f9
@ -13,7 +13,7 @@ import SearchListLoader from "../helpers/searchListLoader";
|
|||||||
import { Message } from "../layer";
|
import { Message } from "../layer";
|
||||||
import appDocsManager, { MyDocument } from "../lib/appManagers/appDocsManager";
|
import appDocsManager, { MyDocument } from "../lib/appManagers/appDocsManager";
|
||||||
import appImManager from "../lib/appManagers/appImManager";
|
import appImManager from "../lib/appManagers/appImManager";
|
||||||
import appMessagesManager from "../lib/appManagers/appMessagesManager";
|
import appMessagesManager, { MyMessage } from "../lib/appManagers/appMessagesManager";
|
||||||
import appPhotosManager, { MyPhoto } from "../lib/appManagers/appPhotosManager";
|
import appPhotosManager, { MyPhoto } from "../lib/appManagers/appPhotosManager";
|
||||||
import RichTextProcessor from "../lib/richtextprocessor";
|
import RichTextProcessor from "../lib/richtextprocessor";
|
||||||
import { MediaSearchContext } from "./appMediaPlaybackController";
|
import { MediaSearchContext } from "./appMediaPlaybackController";
|
||||||
@ -227,12 +227,12 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private setCaption(message: Message.message) {
|
private setCaption(message: MyMessage) {
|
||||||
const caption = message.message;
|
const caption = (message as Message.message).message;
|
||||||
let html = '';
|
let html = '';
|
||||||
if(caption) {
|
if(caption) {
|
||||||
html = RichTextProcessor.wrapRichText(caption, {
|
html = RichTextProcessor.wrapRichText(caption, {
|
||||||
entities: message.totalEntities
|
entities: (message as Message.message).totalEntities
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,12 +248,12 @@ export default class AppMediaViewer extends AppMediaViewerBase<'caption', 'delet
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async openMedia(message: any, target?: HTMLElement, fromRight = 0, reverse = false,
|
public async openMedia(message: MyMessage, target?: HTMLElement, fromRight = 0, reverse = false,
|
||||||
prevTargets: AppMediaViewerTargetType[] = [], nextTargets: AppMediaViewerTargetType[] = []/* , needLoadMore = true */) {
|
prevTargets: AppMediaViewerTargetType[] = [], nextTargets: AppMediaViewerTargetType[] = []/* , needLoadMore = true */) {
|
||||||
if(this.setMoverPromise) return this.setMoverPromise;
|
if(this.setMoverPromise) return this.setMoverPromise;
|
||||||
|
|
||||||
const mid = message.mid;
|
const mid = message.mid;
|
||||||
const fromId = message.fromId;
|
const fromId = (message as Message.message).fwd_from && !message.fromId ? (message as Message.message).fwd_from.from_name : message.fromId;
|
||||||
const media = appMessagesManager.getMediaFromMessage(message);
|
const media = appMessagesManager.getMediaFromMessage(message);
|
||||||
|
|
||||||
this.buttons.forward.classList.toggle('hide', message._ === 'messageService');
|
this.buttons.forward.classList.toggle('hide', message._ === 'messageService');
|
||||||
|
@ -39,6 +39,9 @@ import RangeSelector from "./rangeSelector";
|
|||||||
import windowSize from "../helpers/windowSize";
|
import windowSize from "../helpers/windowSize";
|
||||||
import ListLoader from "../helpers/listLoader";
|
import ListLoader from "../helpers/listLoader";
|
||||||
import EventListenerBase from "../helpers/eventListenerBase";
|
import EventListenerBase from "../helpers/eventListenerBase";
|
||||||
|
import { MyMessage } from "../lib/appManagers/appMessagesManager";
|
||||||
|
import RichTextProcessor from "../lib/richtextprocessor";
|
||||||
|
import { NULL_PEER_ID } from "../lib/mtproto/mtproto_config";
|
||||||
|
|
||||||
const ZOOM_STEP = 0.5;
|
const ZOOM_STEP = 0.5;
|
||||||
const ZOOM_INITIAL_VALUE = 1;
|
const ZOOM_INITIAL_VALUE = 1;
|
||||||
@ -1096,32 +1099,50 @@ export default class AppMediaViewerBase<
|
|||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
protected setAuthorInfo(fromId: PeerId, timestamp: number) {
|
protected setAuthorInfo(fromId: PeerId | string, timestamp: number) {
|
||||||
replaceContent(this.author.date, formatFullSentTime(timestamp));
|
replaceContent(this.author.date, formatFullSentTime(timestamp));
|
||||||
|
|
||||||
replaceContent(this.author.nameEl, new PeerTitle({
|
const isPeerId = fromId.isPeerId();
|
||||||
peerId: fromId,
|
let title: HTMLElement;
|
||||||
|
if(isPeerId) {
|
||||||
|
title = new PeerTitle({
|
||||||
|
peerId: fromId as PeerId,
|
||||||
dialog: false,
|
dialog: false,
|
||||||
onlyFirstName: false,
|
onlyFirstName: false,
|
||||||
plainText: false
|
plainText: false
|
||||||
}).element);
|
}).element;
|
||||||
|
} else {
|
||||||
|
title = document.createElement('span');
|
||||||
|
title.innerHTML = RichTextProcessor.wrapEmojiText(fromId);
|
||||||
|
title.classList.add('peer-title');
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceContent(this.author.nameEl, title);
|
||||||
|
|
||||||
let oldAvatar = this.author.avatarEl;
|
let oldAvatar = this.author.avatarEl;
|
||||||
this.author.avatarEl = (this.author.avatarEl.cloneNode() as AvatarElement);
|
this.author.avatarEl = (oldAvatar.cloneNode() as AvatarElement);
|
||||||
this.author.avatarEl.setAttribute('peer', '' + (fromId || rootScope.myId));
|
|
||||||
|
if(!isPeerId) {
|
||||||
|
this.author.avatarEl.setAttribute('peer-title', '' + fromId);
|
||||||
|
} else {
|
||||||
|
this.author.avatarEl.removeAttribute('peer-title');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.author.avatarEl.setAttribute('peer', '' + (fromId || NULL_PEER_ID));
|
||||||
|
|
||||||
oldAvatar.parentElement.replaceChild(this.author.avatarEl, oldAvatar);
|
oldAvatar.parentElement.replaceChild(this.author.avatarEl, oldAvatar);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async _openMedia(
|
protected async _openMedia(
|
||||||
media: MyDocument | MyPhoto,
|
media: MyDocument | MyPhoto,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
fromId: PeerId,
|
fromId: PeerId | string,
|
||||||
fromRight: number,
|
fromRight: number,
|
||||||
target?: HTMLElement,
|
target?: HTMLElement,
|
||||||
reverse = false,
|
reverse = false,
|
||||||
prevTargets: TargetType[] = [],
|
prevTargets: TargetType[] = [],
|
||||||
nextTargets: TargetType[] = [],
|
nextTargets: TargetType[] = [],
|
||||||
message?: Message.message
|
message?: MyMessage
|
||||||
/* , needLoadMore = true */
|
/* , needLoadMore = true */
|
||||||
) {
|
) {
|
||||||
if(this.setMoverPromise) return this.setMoverPromise;
|
if(this.setMoverPromise) return this.setMoverPromise;
|
||||||
@ -1407,7 +1428,7 @@ export default class AppMediaViewerBase<
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(useController) {
|
if(useController) {
|
||||||
const rollback = appMediaPlaybackController.setSingleMedia(video, message);
|
const rollback = appMediaPlaybackController.setSingleMedia(video, message as Message.message);
|
||||||
|
|
||||||
this.addEventListener('setMoverBefore', () => {
|
this.addEventListener('setMoverBefore', () => {
|
||||||
rollback();
|
rollback();
|
||||||
|
@ -42,7 +42,7 @@ import ListenerSetter from "../../helpers/listenerSetter";
|
|||||||
import PollElement from "../poll";
|
import PollElement from "../poll";
|
||||||
import AudioElement from "../audio";
|
import AudioElement from "../audio";
|
||||||
import { Message, MessageEntity, MessageReplyHeader, Photo, PhotoSize, ReplyMarkup, Update, WebPage } from "../../layer";
|
import { Message, MessageEntity, MessageReplyHeader, Photo, PhotoSize, ReplyMarkup, Update, WebPage } from "../../layer";
|
||||||
import { REPLIES_PEER_ID } from "../../lib/mtproto/mtproto_config";
|
import { NULL_PEER_ID, REPLIES_PEER_ID } from "../../lib/mtproto/mtproto_config";
|
||||||
import { FocusDirection } from "../../helpers/fastSmoothScroll";
|
import { FocusDirection } from "../../helpers/fastSmoothScroll";
|
||||||
import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent, interruptHeavyAnimation } from "../../hooks/useHeavyAnimationCheck";
|
import useHeavyAnimationCheck, { getHeavyAnimationPromise, dispatchHeavyAnimationEvent, interruptHeavyAnimation } from "../../hooks/useHeavyAnimationCheck";
|
||||||
import { fastRaf, fastRafPromise } from "../../helpers/schedulers";
|
import { fastRaf, fastRafPromise } from "../../helpers/schedulers";
|
||||||
@ -79,6 +79,7 @@ import SetTransition from "../singleTransition";
|
|||||||
import handleHorizontalSwipe from "../../helpers/dom/handleHorizontalSwipe";
|
import handleHorizontalSwipe from "../../helpers/dom/handleHorizontalSwipe";
|
||||||
import { cancelContextMenuOpening } from "../misc";
|
import { cancelContextMenuOpening } from "../misc";
|
||||||
import findUpAttribute from "../../helpers/dom/findUpAttribute";
|
import findUpAttribute from "../../helpers/dom/findUpAttribute";
|
||||||
|
import findUpAsChild from "../../helpers/dom/findUpAsChild";
|
||||||
|
|
||||||
const USE_MEDIA_TAILS = false;
|
const USE_MEDIA_TAILS = false;
|
||||||
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
|
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
|
||||||
@ -981,32 +982,43 @@ export default class ChatBubbles {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nameDiv = findUpClassName(target, 'peer-title') || findUpClassName(target, 'name') || findUpTag(target, 'AVATAR-ELEMENT') || findUpAttribute(target, 'data-saved-from');
|
const via = findUpClassName(target, 'is-via');
|
||||||
if(nameDiv && nameDiv !== bubble) {
|
if(via) {
|
||||||
target = nameDiv || target;
|
const el = via.querySelector('.peer-title') as HTMLElement;
|
||||||
const peerId = (target.dataset.peerId || target.getAttribute('peer'));
|
if(target === el || findUpAsChild(target, el)) {
|
||||||
const savedFrom = target.dataset.savedFrom;
|
const message = el.innerText + ' ';
|
||||||
if(nameDiv.classList.contains('is-via')) {
|
|
||||||
const message = '@' + this.appUsersManager.getUser(peerId).username + ' ';
|
|
||||||
this.appDraftsManager.setDraft(this.peerId, this.chat.threadId, message);
|
this.appDraftsManager.setDraft(this.peerId, this.chat.threadId, message);
|
||||||
cancelEvent(e);
|
cancelEvent(e);
|
||||||
} else if(savedFrom) {
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const nameDiv = findUpClassName(target, 'peer-title') || findUpTag(target, 'AVATAR-ELEMENT') || findUpAttribute(target, 'data-saved-from');
|
||||||
|
if(nameDiv && nameDiv !== bubble) {
|
||||||
|
target = nameDiv || target;
|
||||||
|
const peerIdStr = target.dataset.peerId || target.getAttribute('peer');
|
||||||
|
if(typeof(peerIdStr) === 'string') {
|
||||||
|
const savedFrom = target.dataset.savedFrom;
|
||||||
|
if(savedFrom) {
|
||||||
const [peerId, mid] = savedFrom.split('_');
|
const [peerId, mid] = savedFrom.split('_');
|
||||||
|
|
||||||
this.chat.appImManager.setInnerPeer(peerId.toPeerId(), +mid);
|
this.chat.appImManager.setInnerPeer(peerId.toPeerId(), +mid);
|
||||||
} else {
|
} else {
|
||||||
if(peerId) {
|
const peerId = peerIdStr.toPeerId();
|
||||||
this.chat.appImManager.setInnerPeer(peerId.toPeerId());
|
if(peerId !== NULL_PEER_ID) {
|
||||||
|
this.chat.appImManager.setInnerPeer(peerId);
|
||||||
} else {
|
} else {
|
||||||
toast(I18n.format('HidAccount', true));
|
toast(I18n.format('HidAccount', true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//this.log('chatInner click:', target);
|
//this.log('chatInner click:', target);
|
||||||
const isVideoComponentElement = target.tagName === 'SPAN' && !target.classList.contains('emoji');
|
// const isVideoComponentElement = target.tagName === 'SPAN' && findUpClassName(target, 'media-container');
|
||||||
/* if(isVideoComponentElement) {
|
/* if(isVideoComponentElement) {
|
||||||
const video = target.parentElement.querySelector('video') as HTMLElement;
|
const video = target.parentElement.querySelector('video') as HTMLElement;
|
||||||
if(video) {
|
if(video) {
|
||||||
@ -1031,7 +1043,7 @@ export default class ChatBubbles {
|
|||||||
const documentDiv = findUpClassName(target, 'document-with-thumb');
|
const documentDiv = findUpClassName(target, 'document-with-thumb');
|
||||||
if((target.tagName === 'IMG' && !target.classList.contains('emoji') && !target.classList.contains('document-thumb'))
|
if((target.tagName === 'IMG' && !target.classList.contains('emoji') && !target.classList.contains('document-thumb'))
|
||||||
|| target.classList.contains('album-item')
|
|| target.classList.contains('album-item')
|
||||||
|| isVideoComponentElement
|
// || isVideoComponentElement
|
||||||
|| (target.tagName === 'VIDEO' && !bubble.classList.contains('round'))
|
|| (target.tagName === 'VIDEO' && !bubble.classList.contains('round'))
|
||||||
|| (documentDiv && !documentDiv.querySelector('.preloader-container'))) {
|
|| (documentDiv && !documentDiv.querySelector('.preloader-container'))) {
|
||||||
const groupedItem = findUpClassName(target, 'album-item') || findUpClassName(target, 'document-container');
|
const groupedItem = findUpClassName(target, 'album-item') || findUpClassName(target, 'document-container');
|
||||||
@ -3040,15 +3052,19 @@ export default class ChatBubbles {
|
|||||||
const needName = (message.fromId !== rootScope.myId && this.appPeersManager.isAnyChat(peerId) && !this.appPeersManager.isBroadcast(peerId)) || message.viaBotId;
|
const needName = (message.fromId !== rootScope.myId && this.appPeersManager.isAnyChat(peerId) && !this.appPeersManager.isBroadcast(peerId)) || message.viaBotId;
|
||||||
if(needName || message.fwd_from || message.reply_to_mid) { // chat
|
if(needName || message.fwd_from || message.reply_to_mid) { // chat
|
||||||
let title: HTMLElement | DocumentFragment;
|
let title: HTMLElement | DocumentFragment;
|
||||||
|
let titleVia: typeof title;
|
||||||
|
|
||||||
const isForwardFromChannel = message.from_id && message.from_id._ === 'peerChannel' && message.fromId === message.fwdFromId;
|
const isForwardFromChannel = message.from_id && message.from_id._ === 'peerChannel' && message.fromId === message.fwdFromId;
|
||||||
|
|
||||||
let isHidden = message.fwd_from && !message.fwd_from.from_id && !message.fwd_from.channel_id;
|
let isHidden = message.fwd_from && !message.fwd_from.from_id && !message.fwd_from.channel_id;
|
||||||
if(message.viaBotId) {
|
if(message.viaBotId) {
|
||||||
title = document.createElement('span');
|
titleVia = document.createElement('span');
|
||||||
title.innerText = '@' + this.appUsersManager.getUser(message.viaBotId).username;
|
titleVia.innerText = '@' + this.appUsersManager.getUser(message.viaBotId).username;
|
||||||
title.classList.add('peer-title');
|
titleVia.classList.add('peer-title');
|
||||||
} else if(isHidden) {
|
bubble.classList.add('must-have-name');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isHidden) {
|
||||||
///////this.log('message to render hidden', message);
|
///////this.log('message to render hidden', message);
|
||||||
title = document.createElement('span');
|
title = document.createElement('span');
|
||||||
title.innerHTML = RichTextProcessor.wrapEmojiText(message.fwd_from.from_name);
|
title.innerHTML = RichTextProcessor.wrapEmojiText(message.fwd_from.from_name);
|
||||||
@ -3056,7 +3072,7 @@ export default class ChatBubbles {
|
|||||||
//title = message.fwd_from.from_name;
|
//title = message.fwd_from.from_name;
|
||||||
bubble.classList.add('hidden-profile');
|
bubble.classList.add('hidden-profile');
|
||||||
} else {
|
} else {
|
||||||
title = new PeerTitle({peerId: message.viaBotId || message.fwdFromId || message.fromId}).element;
|
title = new PeerTitle({peerId: message.fwdFromId || message.fromId}).element;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message.reply_to_mid && message.reply_to_mid !== this.chat.threadId) {
|
if(message.reply_to_mid && message.reply_to_mid !== this.chat.threadId) {
|
||||||
@ -3070,29 +3086,19 @@ export default class ChatBubbles {
|
|||||||
|
|
||||||
//this.log(title);
|
//this.log(title);
|
||||||
|
|
||||||
if(message.viaBotId) {
|
let nameDiv: HTMLElement;
|
||||||
//if(!bubble.classList.contains('sticker') || true) {
|
if((message.fwdFromId || message.fwd_from)) {
|
||||||
let nameDiv = document.createElement('div');
|
|
||||||
nameDiv.classList.add('name', 'is-via');
|
|
||||||
nameDiv.dataset.peerId = message.viaBotId;
|
|
||||||
nameDiv.append(i18n('ViaBot'), ' ', title);
|
|
||||||
nameContainer.append(nameDiv);
|
|
||||||
// } else {
|
|
||||||
// bubble.classList.add('hide-name');
|
|
||||||
// }
|
|
||||||
} else if((message.fwdFromId || message.fwd_from)) {
|
|
||||||
if(this.peerId !== rootScope.myId && !isForwardFromChannel) {
|
if(this.peerId !== rootScope.myId && !isForwardFromChannel) {
|
||||||
bubble.classList.add('forwarded');
|
bubble.classList.add('forwarded');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message.savedFrom) {
|
if(message.savedFrom) {
|
||||||
savedFrom = message.savedFrom;
|
savedFrom = message.savedFrom;
|
||||||
|
title.dataset.savedFrom = savedFrom;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if(!bubble.classList.contains('sticker') || true) {
|
nameDiv = document.createElement('div');
|
||||||
let nameDiv = document.createElement('div');
|
title.dataset.peerId = message.fwdFromId;
|
||||||
nameDiv.classList.add('name');
|
|
||||||
nameDiv.dataset.peerId = message.fwdFromId;
|
|
||||||
|
|
||||||
if((this.peerId === rootScope.myId || this.peerId === REPLIES_PEER_ID || isForwardFromChannel) && !isStandaloneMedia) {
|
if((this.peerId === rootScope.myId || this.peerId === REPLIES_PEER_ID || isForwardFromChannel) && !isStandaloneMedia) {
|
||||||
nameDiv.style.color = this.appPeersManager.getPeerColorById(message.fwdFromId, false);
|
nameDiv.style.color = this.appPeersManager.getPeerColorById(message.fwdFromId, false);
|
||||||
@ -3105,18 +3111,10 @@ export default class ChatBubbles {
|
|||||||
args.unshift(document.createElement('br'));
|
args.unshift(document.createElement('br'));
|
||||||
}
|
}
|
||||||
nameDiv.append(i18n('ForwardedFrom', [args]));
|
nameDiv.append(i18n('ForwardedFrom', [args]));
|
||||||
|
|
||||||
if(savedFrom) {
|
|
||||||
nameDiv.dataset.savedFrom = savedFrom;
|
|
||||||
}
|
}
|
||||||
}
|
} else if(!message.viaBotId) {
|
||||||
|
|
||||||
nameContainer.append(nameDiv);
|
|
||||||
//}
|
|
||||||
} else {
|
|
||||||
if(!isStandaloneMedia && needName) {
|
if(!isStandaloneMedia && needName) {
|
||||||
let nameDiv = document.createElement('div');
|
nameDiv = document.createElement('div');
|
||||||
nameDiv.classList.add('name');
|
|
||||||
nameDiv.append(title);
|
nameDiv.append(title);
|
||||||
|
|
||||||
if(!our) {
|
if(!our) {
|
||||||
@ -3124,12 +3122,30 @@ export default class ChatBubbles {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nameDiv.dataset.peerId = message.fromId;
|
nameDiv.dataset.peerId = message.fromId;
|
||||||
nameContainer.append(nameDiv);
|
|
||||||
} else /* if(!message.reply_to_mid) */ {
|
} else /* if(!message.reply_to_mid) */ {
|
||||||
bubble.classList.add('hide-name');
|
bubble.classList.add('hide-name');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(message.viaBotId) {
|
||||||
|
if(!nameDiv) {
|
||||||
|
nameDiv = document.createElement('div');
|
||||||
|
} else {
|
||||||
|
nameDiv.append(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
const span = document.createElement('span');
|
||||||
|
span.append(i18n('ViaBot'), ' ', titleVia);
|
||||||
|
span.classList.add('is-via');
|
||||||
|
|
||||||
|
nameDiv.append(span);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nameDiv) {
|
||||||
|
nameDiv.classList.add('name');
|
||||||
|
nameContainer.append(nameDiv);
|
||||||
|
}
|
||||||
|
|
||||||
const needAvatar = this.chat.isAnyGroup() && !isOut;
|
const needAvatar = this.chat.isAnyGroup() && !isOut;
|
||||||
if(needAvatar) {
|
if(needAvatar) {
|
||||||
let avatarElem = new AvatarElement();
|
let avatarElem = new AvatarElement();
|
||||||
@ -3141,7 +3157,7 @@ export default class ChatBubbles {
|
|||||||
avatarElem.setAttribute('peer-title', /* '🔥 FF 🔥' */message.fwd_from.from_name);
|
avatarElem.setAttribute('peer-title', /* '🔥 FF 🔥' */message.fwd_from.from_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
avatarElem.setAttribute('peer', '' + (((message.fwd_from && (this.peerId === rootScope.myId || this.peerId === REPLIES_PEER_ID)) || isForwardFromChannel ? message.fwdFromId : message.fromId) || 0));
|
avatarElem.setAttribute('peer', '' + (((message.fwd_from && (this.peerId === rootScope.myId || this.peerId === REPLIES_PEER_ID)) || isForwardFromChannel ? message.fwdFromId : message.fromId) || NULL_PEER_ID));
|
||||||
//avatarElem.update();
|
//avatarElem.update();
|
||||||
|
|
||||||
//this.log('exec loadDialogPhoto', message);
|
//this.log('exec loadDialogPhoto', message);
|
||||||
|
@ -95,11 +95,12 @@ export default class EditPeer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let validLength = 0, requiredLength = 0, requiredValidLength = 0;
|
let changedLength = 0, requiredLength = 0, requiredValidLength = 0;
|
||||||
this.inputFields.forEach(inputField => {
|
this.inputFields.forEach(inputField => {
|
||||||
const isValid = inputField.isValid();
|
if(inputField.isValid()) {
|
||||||
if(isValid) {
|
if(inputField.isChanged()) {
|
||||||
++validLength;
|
++changedLength;
|
||||||
|
}
|
||||||
|
|
||||||
if(inputField.required) {
|
if(inputField.required) {
|
||||||
++requiredValidLength;
|
++requiredValidLength;
|
||||||
@ -111,7 +112,7 @@ export default class EditPeer {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return requiredLength === requiredValidLength && validLength > 0;
|
return requiredLength === requiredValidLength && changedLength > 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
public handleChange = () => {
|
public handleChange = () => {
|
||||||
|
@ -300,11 +300,14 @@ class InputField {
|
|||||||
|
|
||||||
public isValid() {
|
public isValid() {
|
||||||
return !this.input.classList.contains('error') &&
|
return !this.input.classList.contains('error') &&
|
||||||
this.isChanged() &&
|
|
||||||
(!this.validate || this.validate()) &&
|
(!this.validate || this.validate()) &&
|
||||||
(!this.required || !isInputEmpty(this.input));
|
(!this.required || !isInputEmpty(this.input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isValidToChange() {
|
||||||
|
return this.isValid() && this.isChanged();
|
||||||
|
}
|
||||||
|
|
||||||
public setDraftValue(value = '', silent = false) {
|
public setDraftValue(value = '', silent = false) {
|
||||||
if(!this.options.plainText) {
|
if(!this.options.plainText) {
|
||||||
value = RichTextProcessor.wrapDraftText(value);
|
value = RichTextProcessor.wrapDraftText(value);
|
||||||
|
@ -42,7 +42,7 @@ export default class PopupElement {
|
|||||||
protected btnClose: HTMLElement;
|
protected btnClose: HTMLElement;
|
||||||
protected btnConfirm: HTMLButtonElement;
|
protected btnConfirm: HTMLButtonElement;
|
||||||
protected body: HTMLElement;
|
protected body: HTMLElement;
|
||||||
protected buttons: HTMLElement;
|
protected buttonsEl: HTMLElement;
|
||||||
|
|
||||||
protected onClose: () => void;
|
protected onClose: () => void;
|
||||||
protected onCloseAfterTimeout: () => void;
|
protected onCloseAfterTimeout: () => void;
|
||||||
@ -55,7 +55,7 @@ export default class PopupElement {
|
|||||||
protected confirmShortcutIsSendShortcut: boolean;
|
protected confirmShortcutIsSendShortcut: boolean;
|
||||||
protected btnConfirmOnEnter: HTMLButtonElement;
|
protected btnConfirmOnEnter: HTMLButtonElement;
|
||||||
|
|
||||||
constructor(className: string, buttons?: Array<PopupButton>, options: PopupOptions = {}) {
|
constructor(className: string, protected buttons?: Array<PopupButton>, options: PopupOptions = {}) {
|
||||||
this.element.classList.add('popup');
|
this.element.classList.add('popup');
|
||||||
this.element.className = 'popup' + (className ? ' ' + className : '');
|
this.element.className = 'popup' + (className ? ' ' + className : '');
|
||||||
this.container.classList.add('popup-container', 'z-depth-1');
|
this.container.classList.add('popup-container', 'z-depth-1');
|
||||||
@ -105,7 +105,7 @@ export default class PopupElement {
|
|||||||
|
|
||||||
let btnConfirmOnEnter = this.btnConfirm;
|
let btnConfirmOnEnter = this.btnConfirm;
|
||||||
if(buttons && buttons.length) {
|
if(buttons && buttons.length) {
|
||||||
const buttonsDiv = this.buttons = document.createElement('div');
|
const buttonsDiv = this.buttonsEl = document.createElement('div');
|
||||||
buttonsDiv.classList.add('popup-buttons');
|
buttonsDiv.classList.add('popup-buttons');
|
||||||
|
|
||||||
if(buttons.length === 2) {
|
if(buttons.length === 2) {
|
||||||
|
@ -9,6 +9,7 @@ import PopupElement, { addCancelButton, PopupButton, PopupOptions } from ".";
|
|||||||
import { i18n, LangPackKey } from "../../lib/langPack";
|
import { i18n, LangPackKey } from "../../lib/langPack";
|
||||||
import CheckboxField, { CheckboxFieldOptions } from "../checkboxField";
|
import CheckboxField, { CheckboxFieldOptions } from "../checkboxField";
|
||||||
|
|
||||||
|
export type PopupPeerButton = Omit<PopupButton, 'callback'> & Partial<{callback: PopupPeerButtonCallback}>;
|
||||||
export type PopupPeerButtonCallbackCheckboxes = Set<LangPackKey>;
|
export type PopupPeerButtonCallbackCheckboxes = Set<LangPackKey>;
|
||||||
export type PopupPeerButtonCallback = (checkboxes?: PopupPeerButtonCallbackCheckboxes) => void;
|
export type PopupPeerButtonCallback = (checkboxes?: PopupPeerButtonCallbackCheckboxes) => void;
|
||||||
export type PopupPeerCheckboxOptions = CheckboxFieldOptions & {checkboxField?: CheckboxField};
|
export type PopupPeerCheckboxOptions = CheckboxFieldOptions & {checkboxField?: CheckboxField};
|
||||||
@ -22,7 +23,7 @@ export type PopupPeerOptions = PopupOptions & Partial<{
|
|||||||
description: string,
|
description: string,
|
||||||
descriptionLangKey?: LangPackKey,
|
descriptionLangKey?: LangPackKey,
|
||||||
descriptionLangArgs?: any[],
|
descriptionLangArgs?: any[],
|
||||||
buttons?: Array<Omit<PopupButton, 'callback'> & Partial<{callback: PopupPeerButtonCallback}>>,
|
buttons?: Array<PopupPeerButton>,
|
||||||
checkboxes: Array<PopupPeerCheckboxOptions>
|
checkboxes: Array<PopupPeerCheckboxOptions>
|
||||||
}>;
|
}>;
|
||||||
export default class PopupPeer extends PopupElement {
|
export default class PopupPeer extends PopupElement {
|
||||||
|
@ -48,7 +48,7 @@ export default class PopupReportMessages extends PopupPeer {
|
|||||||
}, {listenerSetter: this.listenerSetter});
|
}, {listenerSetter: this.listenerSetter});
|
||||||
|
|
||||||
this.body.style.margin = '0 -1rem';
|
this.body.style.margin = '0 -1rem';
|
||||||
this.buttons.style.marginTop = '.5rem';
|
this.buttonsEl.style.marginTop = '.5rem';
|
||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,10 @@ export default class PopupReportMessagesConfirm extends PopupPeer {
|
|||||||
placeholder: 'ReportChatDescription'
|
placeholder: 'ReportChatDescription'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
inputField.input.addEventListener('input', () => {
|
||||||
|
this.buttons[0].element.toggleAttribute('disabled', !inputField.isValid());
|
||||||
|
});
|
||||||
|
|
||||||
this.body.append(inputField.container);
|
this.body.append(inputField.container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ export default class AppEditProfileTab extends SliderSuperTab {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.usernameInputField.isValid() && !this.usernameInputField.input.classList.contains('error')) {
|
if(this.usernameInputField.isValidToChange()) {
|
||||||
promises.push(appUsersManager.updateUsername(this.usernameInputField.value));
|
promises.push(appUsersManager.updateUsername(this.usernameInputField.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ export default class AppChatTypeTab extends SliderSuperTabEventable {
|
|||||||
|
|
||||||
const onChange = () => {
|
const onChange = () => {
|
||||||
const changed = (privateRow.radioField.checked && (originalValue !== placeholder/* || revoked */))
|
const changed = (privateRow.radioField.checked && (originalValue !== placeholder/* || revoked */))
|
||||||
|| (linkInputField.isValid() && linkInputField.input.classList.contains('valid'));
|
|| (linkInputField.isValidToChange() && linkInputField.input.classList.contains('valid'));
|
||||||
applyBtn.classList.toggle('is-visible', changed);
|
applyBtn.classList.toggle('is-visible', changed);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -174,11 +174,11 @@ export default class AppEditChatTab extends SliderSuperTab {
|
|||||||
let promises: Promise<any>[] = [];
|
let promises: Promise<any>[] = [];
|
||||||
|
|
||||||
const id = this.chatId;
|
const id = this.chatId;
|
||||||
if(this.chatNameInputField.isValid()) {
|
if(this.chatNameInputField.isValidToChange()) {
|
||||||
promises.push(appChatsManager.editTitle(id, this.chatNameInputField.value));
|
promises.push(appChatsManager.editTitle(id, this.chatNameInputField.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.descriptionInputField.isValid()) {
|
if(this.descriptionInputField.isValidToChange()) {
|
||||||
promises.push(appChatsManager.editAbout(id, this.descriptionInputField.value));
|
promises.push(appChatsManager.editAbout(id, this.descriptionInputField.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ export class UsernameInputField extends InputField {
|
|||||||
this.options.onChange && this.options.onChange();
|
this.options.onChange && this.options.onChange();
|
||||||
|
|
||||||
const value = this.getValue();
|
const value = this.getValue();
|
||||||
if(value !== username && this.isValid() && RichTextProcessor.isUsernameValid(value)) {
|
if(value !== username && this.isValidToChange() && RichTextProcessor.isUsernameValid(value)) {
|
||||||
this.checkUsername(value);
|
this.checkUsername(value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ let convert = (value: number) => {
|
|||||||
|
|
||||||
type RLottiePlayerListeners = 'enterFrame' | 'ready' | 'firstFrame' | 'cached';
|
type RLottiePlayerListeners = 'enterFrame' | 'ready' | 'firstFrame' | 'cached';
|
||||||
type RLottieOptions = {
|
type RLottieOptions = {
|
||||||
container: HTMLElement,
|
container?: HTMLElement,
|
||||||
autoplay?: boolean,
|
autoplay?: boolean,
|
||||||
animationData: string,
|
animationData: string,
|
||||||
loop?: boolean,
|
loop?: boolean,
|
||||||
@ -83,15 +83,14 @@ export class RLottiePlayer extends EventListenerBase<{
|
|||||||
private currentMethod: RLottiePlayer['mainLoopForwards'] | RLottiePlayer['mainLoopBackwards'];
|
private currentMethod: RLottiePlayer['mainLoopForwards'] | RLottiePlayer['mainLoopBackwards'];
|
||||||
private frameListener: () => void;
|
private frameListener: () => void;
|
||||||
|
|
||||||
constructor({el, worker, options}: {
|
constructor({worker, options}: {
|
||||||
el: HTMLElement,
|
|
||||||
worker: QueryableWorker,
|
worker: QueryableWorker,
|
||||||
options: RLottieOptions
|
options: RLottieOptions
|
||||||
}) {
|
}) {
|
||||||
super(true);
|
super(true);
|
||||||
|
|
||||||
this.reqId = ++RLottiePlayer['reqId'];
|
this.reqId = ++RLottiePlayer['reqId'];
|
||||||
this.el = el;
|
this.el = options.container;
|
||||||
this.worker = worker;
|
this.worker = worker;
|
||||||
|
|
||||||
for(let i in options) {
|
for(let i in options) {
|
||||||
@ -416,7 +415,7 @@ export class RLottiePlayer extends EventListenerBase<{
|
|||||||
this.addEventListener('enterFrame', () => {
|
this.addEventListener('enterFrame', () => {
|
||||||
this.dispatchEvent('firstFrame');
|
this.dispatchEvent('firstFrame');
|
||||||
|
|
||||||
this.el.appendChild(this.canvas);
|
this.el && this.el.appendChild(this.canvas);
|
||||||
|
|
||||||
//console.log('enterFrame firstFrame');
|
//console.log('enterFrame firstFrame');
|
||||||
|
|
||||||
@ -720,7 +719,7 @@ class LottieLoader {
|
|||||||
await this.loadLottieWorkers();
|
await this.loadLottieWorkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!params.width || !params.height) {
|
if((!params.width || !params.height) && params.container) {
|
||||||
params.width = parseInt(params.container.style.width);
|
params.width = parseInt(params.container.style.width);
|
||||||
params.height = parseInt(params.container.style.height);
|
params.height = parseInt(params.container.style.height);
|
||||||
}
|
}
|
||||||
@ -731,7 +730,7 @@ class LottieLoader {
|
|||||||
|
|
||||||
params.group = group;
|
params.group = group;
|
||||||
|
|
||||||
const player = this.initPlayer(params.container, params);
|
const player = this.initPlayer(params);
|
||||||
|
|
||||||
if(group !== 'none') {
|
if(group !== 'none') {
|
||||||
animationIntersector.addAnimation(player, group);
|
animationIntersector.addAnimation(player, group);
|
||||||
@ -790,9 +789,8 @@ class LottieLoader {
|
|||||||
this.workers.length = 0;
|
this.workers.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private initPlayer(el: HTMLElement, options: RLottieOptions) {
|
private initPlayer(options: RLottieOptions) {
|
||||||
const rlPlayer = new RLottiePlayer({
|
const rlPlayer = new RLottiePlayer({
|
||||||
el,
|
|
||||||
worker: this.workers[this.curWorkerNum++],
|
worker: this.workers[this.curWorkerNum++],
|
||||||
options
|
options
|
||||||
});
|
});
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@include btn-hoverable();
|
@include btn-hoverable();
|
||||||
|
|
||||||
|
&:disabled {
|
||||||
|
pointer-events: none !important;
|
||||||
|
opacity: var(--disabled-opacity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-icon {
|
.btn-icon {
|
||||||
@ -42,11 +47,6 @@
|
|||||||
&.active {
|
&.active {
|
||||||
color: var(--primary-color);
|
color: var(--primary-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:disabled {
|
|
||||||
pointer-events: none !important;
|
|
||||||
opacity: var(--disabled-opacity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-corner {
|
.btn-corner {
|
||||||
|
@ -277,9 +277,7 @@ $bubble-beside-button-width: 38px;
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column-reverse;
|
flex-direction: column-reverse;
|
||||||
/* font-size: 0; */
|
// align-items: flex-start;
|
||||||
width: max-content;
|
|
||||||
height: fit-content;
|
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
background-color: var(--message-background-color);
|
background-color: var(--message-background-color);
|
||||||
@ -327,7 +325,8 @@ $bubble-beside-button-width: 38px;
|
|||||||
opacity: .99999; // for safari
|
opacity: .99999; // for safari
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
||||||
&:before, &:after {
|
&:before,
|
||||||
|
&:after {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +425,7 @@ $bubble-beside-button-width: 38px;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.forwarded) {
|
&:not(.forwarded):not(.must-have-name) {
|
||||||
&:not(.is-group-first) {
|
&:not(.is-group-first) {
|
||||||
.bubble-content > .name,
|
.bubble-content > .name,
|
||||||
.document-wrapper > .name {
|
.document-wrapper > .name {
|
||||||
@ -1116,7 +1115,7 @@ $bubble-beside-button-width: 38px;
|
|||||||
|
|
||||||
&.forwarded .attachment,
|
&.forwarded .attachment,
|
||||||
&.is-reply .attachment,
|
&.is-reply .attachment,
|
||||||
&:not(.hide-name).is-message-empty .attachment/* ,
|
&:not(.hide-name)/* .is-message-empty */ .attachment/* ,
|
||||||
&:not(.hide-name):not(.sticker) .attachment */ {
|
&:not(.hide-name):not(.sticker) .attachment */ {
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
@ -1596,6 +1595,11 @@ $bubble-beside-button-width: 38px;
|
|||||||
float: none;
|
float: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.video-time,
|
||||||
|
.video-play {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.video-time {
|
.video-time {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 3px;
|
top: 3px;
|
||||||
@ -1655,10 +1659,13 @@ $bubble-beside-button-width: 38px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
.name {
|
.name {
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.peer-title {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
&-content > .name,
|
&-content > .name,
|
||||||
.document-wrapper > .name {
|
.document-wrapper > .name {
|
||||||
/* padding: .2675rem 9px 0 9px; */
|
/* padding: .2675rem 9px 0 9px; */
|
||||||
@ -1676,9 +1683,9 @@ $bubble-beside-button-width: 38px;
|
|||||||
//white-space: nowrap;
|
//white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:not(.is-group-first) .bubble-content > .name .name {
|
/* &:not(.is-group-first) .bubble-content > .name .name {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
} */
|
||||||
|
|
||||||
&:not(.webpage) {
|
&:not(.webpage) {
|
||||||
&.photo,
|
&.photo,
|
||||||
@ -2191,7 +2198,8 @@ $bubble-beside-button-width: 38px;
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.just-media {
|
&.just-media {
|
||||||
.reply, .name {
|
.reply,
|
||||||
|
.name {
|
||||||
right: calc(100% + 10px);
|
right: calc(100% + 10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user