Fix sending some gifs
Fix freezed media in ESG
This commit is contained in:
parent
d5255bed1e
commit
12fcc3c68e
|
@ -2611,7 +2611,7 @@ export default class ChatInput {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(getStickerEffectThumb(document) && !rootScope.premium) {
|
if(document.sticker && getStickerEffectThumb(document) && !rootScope.premium) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,14 @@ import IS_TOUCH_SUPPORTED from '../environment/touchSupport';
|
||||||
import safeAssign from './object/safeAssign';
|
import safeAssign from './object/safeAssign';
|
||||||
import appNavigationController, {NavigationItem} from '../components/appNavigationController';
|
import appNavigationController, {NavigationItem} from '../components/appNavigationController';
|
||||||
import findUpClassName from './dom/findUpClassName';
|
import findUpClassName from './dom/findUpClassName';
|
||||||
|
import rootScope from '../lib/rootScope';
|
||||||
|
|
||||||
const KEEP_OPEN = false;
|
const KEEP_OPEN = false;
|
||||||
const TOGGLE_TIMEOUT = 200;
|
const TOGGLE_TIMEOUT = 200;
|
||||||
const ANIMATION_DURATION = 200;
|
const ANIMATION_DURATION = 200;
|
||||||
|
|
||||||
export type IgnoreMouseOutType = 'click' | 'menu' | 'popup';
|
export type IgnoreMouseOutType = 'click' | 'menu' | 'popup';
|
||||||
|
type DropdownHoverTimeoutType = 'toggle' | 'done';
|
||||||
|
|
||||||
export default class DropdownHover extends EventListenerBase<{
|
export default class DropdownHover extends EventListenerBase<{
|
||||||
open: () => Promise<any> | void,
|
open: () => Promise<any> | void,
|
||||||
|
@ -27,13 +29,13 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
closed: () => any
|
closed: () => any
|
||||||
}> {
|
}> {
|
||||||
protected element: HTMLElement;
|
protected element: HTMLElement;
|
||||||
protected displayTimeout: number;
|
|
||||||
protected forceClose: boolean;
|
protected forceClose: boolean;
|
||||||
protected inited: boolean;
|
protected inited: boolean;
|
||||||
protected ignoreMouseOut: Set<IgnoreMouseOutType>;
|
protected ignoreMouseOut: Set<IgnoreMouseOutType>;
|
||||||
protected ignoreButtons: Set<HTMLElement>;
|
protected ignoreButtons: Set<HTMLElement>;
|
||||||
protected navigationItem: NavigationItem;
|
protected navigationItem: NavigationItem;
|
||||||
protected ignoreOutClickClassName: string;
|
protected ignoreOutClickClassName: string;
|
||||||
|
protected timeouts: {[type in DropdownHoverTimeoutType]?: number};
|
||||||
|
|
||||||
constructor(options: {
|
constructor(options: {
|
||||||
element: DropdownHover['element'],
|
element: DropdownHover['element'],
|
||||||
|
@ -45,6 +47,7 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
this.inited = false;
|
this.inited = false;
|
||||||
this.ignoreMouseOut = new Set();
|
this.ignoreMouseOut = new Set();
|
||||||
this.ignoreButtons = new Set();
|
this.ignoreButtons = new Set();
|
||||||
|
this.timeouts = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
public attachButtonListener(
|
public attachButtonListener(
|
||||||
|
@ -63,17 +66,15 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
}, {listenerSetter});
|
}, {listenerSetter});
|
||||||
} else {
|
} else {
|
||||||
listenerSetter.add(button)('mouseover', (e) => {
|
listenerSetter.add(button)('mouseover', (e) => {
|
||||||
// console.log('onmouseover button');
|
|
||||||
if(firstTime) {
|
if(firstTime) {
|
||||||
listenerSetter.add(button)('mouseout', (e) => {
|
listenerSetter.add(button)('mouseout', (e) => {
|
||||||
clearTimeout(this.displayTimeout);
|
this.clearTimeout('toggle');
|
||||||
this.onMouseOut(e);
|
this.onMouseOut(e);
|
||||||
});
|
});
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(this.displayTimeout);
|
this.setTimeout('toggle', () => {
|
||||||
this.displayTimeout = window.setTimeout(() => {
|
|
||||||
this.toggle(true);
|
this.toggle(true);
|
||||||
}, TOGGLE_TIMEOUT);
|
}, TOGGLE_TIMEOUT);
|
||||||
});
|
});
|
||||||
|
@ -109,7 +110,7 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
|
|
||||||
protected onMouseOut = (e: MouseEvent) => {
|
protected onMouseOut = (e: MouseEvent) => {
|
||||||
if(KEEP_OPEN || !this.isActive()) return;
|
if(KEEP_OPEN || !this.isActive()) return;
|
||||||
clearTimeout(this.displayTimeout);
|
this.clearTimeout('toggle');
|
||||||
|
|
||||||
if(this.ignoreMouseOut.size) {
|
if(this.ignoreMouseOut.size) {
|
||||||
return;
|
return;
|
||||||
|
@ -120,11 +121,26 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.displayTimeout = window.setTimeout(() => {
|
this.setTimeout('toggle', () => {
|
||||||
this.toggle(false);
|
this.toggle(false);
|
||||||
}, TOGGLE_TIMEOUT);
|
}, TOGGLE_TIMEOUT);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected clearTimeout(type: DropdownHoverTimeoutType) {
|
||||||
|
if(this.timeouts[type] !== undefined) {
|
||||||
|
clearTimeout(this.timeouts[type]);
|
||||||
|
delete this.timeouts[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected setTimeout(type: DropdownHoverTimeoutType, cb: () => void, timeout: number) {
|
||||||
|
this.clearTimeout(type);
|
||||||
|
this.timeouts[type] = window.setTimeout(() => {
|
||||||
|
this.clearTimeout(type);
|
||||||
|
cb();
|
||||||
|
}, timeout);
|
||||||
|
}
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
if(!IS_TOUCH_SUPPORTED) {
|
if(!IS_TOUCH_SUPPORTED) {
|
||||||
this.element.onmouseout = this.onMouseOut;
|
this.element.onmouseout = this.onMouseOut;
|
||||||
|
@ -134,7 +150,7 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('onmouseover element');
|
// console.log('onmouseover element');
|
||||||
clearTimeout(this.displayTimeout);
|
this.clearTimeout('toggle');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,6 +171,7 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const delay = IS_TOUCH_SUPPORTED || !rootScope.settings.animationsEnabled ? 0 : ANIMATION_DURATION;
|
||||||
if((this.element.style.display && enable === undefined) || enable) {
|
if((this.element.style.display && enable === undefined) || enable) {
|
||||||
const res = this.dispatchResultableEvent('open');
|
const res = this.dispatchResultableEvent('open');
|
||||||
await Promise.all(res);
|
await Promise.all(res);
|
||||||
|
@ -172,11 +189,11 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
clearTimeout(this.displayTimeout);
|
this.clearTimeout('toggle');
|
||||||
this.displayTimeout = window.setTimeout(() => {
|
this.setTimeout('done', () => {
|
||||||
this.forceClose = false;
|
this.forceClose = false;
|
||||||
this.dispatchEvent('opened');
|
this.dispatchEvent('opened');
|
||||||
}, IS_TOUCH_SUPPORTED ? 0 : ANIMATION_DURATION);
|
}, delay);
|
||||||
|
|
||||||
// ! can't use together with resizeObserver
|
// ! can't use together with resizeObserver
|
||||||
/* if(isTouchSupported) {
|
/* if(isTouchSupported) {
|
||||||
|
@ -198,12 +215,12 @@ export default class DropdownHover extends EventListenerBase<{
|
||||||
appNavigationController.removeItem(this.navigationItem);
|
appNavigationController.removeItem(this.navigationItem);
|
||||||
detachClickEvent(window, this.onClickOut, {capture: true});
|
detachClickEvent(window, this.onClickOut, {capture: true});
|
||||||
|
|
||||||
clearTimeout(this.displayTimeout);
|
this.clearTimeout('toggle');
|
||||||
this.displayTimeout = window.setTimeout(() => {
|
this.setTimeout('done', () => {
|
||||||
this.element.style.display = 'none';
|
this.element.style.display = 'none';
|
||||||
this.forceClose = false;
|
this.forceClose = false;
|
||||||
this.dispatchEvent('closed');
|
this.dispatchEvent('closed');
|
||||||
}, IS_TOUCH_SUPPORTED ? 0 : ANIMATION_DURATION);
|
}, delay);
|
||||||
|
|
||||||
/* if(isTouchSupported) {
|
/* if(isTouchSupported) {
|
||||||
const scrollHeight = this.container.scrollHeight;
|
const scrollHeight = this.container.scrollHeight;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user