Fix dead service worker
Fix push notifications Fix loading messages after deleting page Fix hiding go down button
This commit is contained in:
parent
20a6893859
commit
4c9fd2a88c
@ -1480,7 +1480,7 @@ export default class AppMediaViewerBase<
|
||||
if(supportsStreaming) {
|
||||
onAnimationEnd.then(() => {
|
||||
if(video.readyState < video.HAVE_FUTURE_DATA) {
|
||||
console.log('ppp 1');
|
||||
// console.log('ppp 1');
|
||||
preloader.attach(mover, true);
|
||||
}
|
||||
|
||||
@ -1491,7 +1491,7 @@ export default class AppMediaViewerBase<
|
||||
|
||||
const attachCanPlay = () => {
|
||||
video.addEventListener('canplay', () => {
|
||||
console.log('ppp 2');
|
||||
// console.log('ppp 2');
|
||||
preloader.detach();
|
||||
video.parentElement.classList.remove('is-buffering');
|
||||
}, {once: true});
|
||||
@ -1505,7 +1505,7 @@ export default class AppMediaViewerBase<
|
||||
if(loading && isntEnoughData) {
|
||||
attachCanPlay();
|
||||
|
||||
console.log('ppp 3');
|
||||
// console.log('ppp 3');
|
||||
preloader.attach(mover, true);
|
||||
|
||||
// поставлю класс для плеера, чтобы убрать большую иконку пока прелоадер на месте
|
||||
@ -1533,7 +1533,7 @@ export default class AppMediaViewerBase<
|
||||
if(!supportsStreaming) {
|
||||
onAnimationEnd.then(async() => {
|
||||
if(!(await getCacheContext()).url) {
|
||||
console.log('ppp 4');
|
||||
// console.log('ppp 4');
|
||||
preloader.attach(mover, true, promise);
|
||||
}
|
||||
});
|
||||
|
@ -1805,6 +1805,7 @@ export default class ChatBubbles {
|
||||
|
||||
public async onGoDownClick() {
|
||||
if(!this.replyFollowHistory.length) {
|
||||
this.onScroll(true, undefined, true);
|
||||
this.chat.setMessageId(/* , dialog.top_message */);
|
||||
// const dialog = this.appMessagesManager.getDialogByPeerId(this.peerId)[0];
|
||||
|
||||
@ -1944,7 +1945,10 @@ export default class ChatBubbles {
|
||||
.map((id) => +id)
|
||||
.filter((id) => id > 0 && !this.skippedMids.has(id))
|
||||
.sort((a, b) => a - b);
|
||||
if(!history.length) return;
|
||||
|
||||
if(!history.length) {
|
||||
history.push(0);
|
||||
}
|
||||
|
||||
if(top) {
|
||||
if(DEBUG) {
|
||||
@ -1970,7 +1974,7 @@ export default class ChatBubbles {
|
||||
}
|
||||
}
|
||||
|
||||
public onScroll = (ignoreHeavyAnimation?: boolean, scrollDimensions?: ScrollStartCallbackDimensions) => {
|
||||
public onScroll = (ignoreHeavyAnimation?: boolean, scrollDimensions?: ScrollStartCallbackDimensions, forceDown?: boolean) => {
|
||||
// return;
|
||||
|
||||
if(this.isHeavyAnimationInProgress) {
|
||||
@ -2000,8 +2004,8 @@ export default class ChatBubbles {
|
||||
return;
|
||||
}
|
||||
|
||||
const distanceToEnd = scrollDimensions?.distanceToEnd ?? this.scrollable.getDistanceToEnd();
|
||||
if(/* !IS_TOUCH_SUPPORTED && */(this.scrollable.lastScrollDirection !== 0 && distanceToEnd > 0) || scrollDimensions) {
|
||||
const distanceToEnd = forceDown ? 0 : scrollDimensions?.distanceToEnd ?? this.scrollable.getDistanceToEnd();
|
||||
if(/* !IS_TOUCH_SUPPORTED && */(this.scrollable.lastScrollDirection !== 0 && distanceToEnd > 0) || scrollDimensions || forceDown) {
|
||||
// if(/* !IS_TOUCH_SUPPORTED && */(this.scrollable.lastScrollDirection !== 0 || scrollDimensions) && distanceToEnd > 0) {
|
||||
if(this.isScrollingTimeout) {
|
||||
clearTimeout(this.isScrollingTimeout);
|
||||
@ -2015,7 +2019,7 @@ export default class ChatBubbles {
|
||||
}, 1350 + (scrollDimensions?.duration ?? 0));
|
||||
}
|
||||
|
||||
if(distanceToEnd < SCROLLED_DOWN_THRESHOLD && (this.scrollable.loadedAll.bottom || this.chat.setPeerPromise || !this.peerId)) {
|
||||
if(distanceToEnd < SCROLLED_DOWN_THRESHOLD && (forceDown || this.scrollable.loadedAll.bottom || this.chat.setPeerPromise || !this.peerId)) {
|
||||
this.container.classList.add('scrolled-down');
|
||||
this.scrolledDown = true;
|
||||
} else if(this.container.classList.contains('scrolled-down')) {
|
||||
@ -2724,7 +2728,7 @@ export default class ChatBubbles {
|
||||
this.replyFollowHistory.length = 0;
|
||||
|
||||
this.passEntities = {
|
||||
messageEntityBotCommand: await m(this.managers.appPeersManager.isAnyGroup(peerId)) || await m(this.managers.appUsersManager.isBot(peerId))
|
||||
messageEntityBotCommand: await m(this.managers.appPeersManager.isAnyGroup(peerId)) || this.chat.isBot
|
||||
};
|
||||
}
|
||||
|
||||
@ -2972,7 +2976,7 @@ export default class ChatBubbles {
|
||||
|
||||
private async setFetchReactionsInterval(afterSetPromise: Promise<any>) {
|
||||
const middleware = this.getMiddleware();
|
||||
const needReactionsInterval = await this.managers.appPeersManager.isChannel(this.peerId);
|
||||
const needReactionsInterval = this.chat.isChannel;
|
||||
if(needReactionsInterval) {
|
||||
const fetchReactions = async() => {
|
||||
if(!middleware()) return;
|
||||
@ -3077,7 +3081,7 @@ export default class ChatBubbles {
|
||||
|
||||
public async finishPeerChange() {
|
||||
const [isChannel, canWrite, isAnyGroup] = await Promise.all([
|
||||
this.managers.appPeersManager.isChannel(this.peerId),
|
||||
this.chat.isChannel,
|
||||
this.chat.canSend(),
|
||||
this.chat.isAnyGroup
|
||||
]);
|
||||
@ -5013,7 +5017,7 @@ export default class ChatBubbles {
|
||||
}
|
||||
|
||||
const elements: (Node | string)[] = [];
|
||||
const isBot = await m(this.managers.appPeersManager.isBot(this.peerId));
|
||||
const isBot = this.chat.isBot;
|
||||
let renderPromise: Promise<any>, appendTo = this.container, method: 'append' | 'prepend' = 'append';
|
||||
if(this.chat.isRestricted) {
|
||||
renderPromise = this.renderEmptyPlaceholder('restricted', bubble, message, elements);
|
||||
@ -5271,11 +5275,11 @@ export default class ChatBubbles {
|
||||
}
|
||||
|
||||
if(!this.chat.isRestricted) {
|
||||
if(side === 'bottom' && await this.managers.appPeersManager.isBroadcast(this.peerId)/* && false */) {
|
||||
if(side === 'bottom' && this.chat.isBroadcast/* && false */) {
|
||||
this.toggleSponsoredMessage(value);
|
||||
}
|
||||
|
||||
if(side === 'top' && value && await this.managers.appPeersManager.isBot(this.peerId)) {
|
||||
if(side === 'top' && value && this.chat.isBot) {
|
||||
return this.renderBotPlaceholder();
|
||||
}
|
||||
}
|
||||
@ -5426,6 +5430,8 @@ export default class ChatBubbles {
|
||||
// }
|
||||
}
|
||||
// }
|
||||
|
||||
// this.scrollable.onScroll();
|
||||
}
|
||||
});
|
||||
|
||||
@ -5450,7 +5456,7 @@ export default class ChatBubbles {
|
||||
): Promise<{cached: boolean, promise: Promise<void>, waitPromise: Promise<any>}> {
|
||||
const peerId = this.peerId;
|
||||
|
||||
const isBroadcast = await this.managers.appPeersManager.isBroadcast(peerId);
|
||||
const isBroadcast = this.chat.isBroadcast;
|
||||
// console.time('appImManager call getHistory');
|
||||
const pageCount = Math.min(30, windowSize.height / 40/* * 1.25 */ | 0);
|
||||
// const loadCount = Object.keys(this.bubbles).length > 0 ? 50 : pageCount;
|
||||
|
@ -80,6 +80,9 @@ export default class Chat extends EventListenerBase<{
|
||||
public sharedMediaTabs: AppSharedMediaTab[];
|
||||
// public renderDarkPattern: () => Promise<void>;
|
||||
|
||||
public isBot: boolean;
|
||||
public isChannel: boolean;
|
||||
public isBroadcast: boolean;
|
||||
public isAnyGroup: boolean;
|
||||
public isMegagroup: boolean;
|
||||
|
||||
@ -404,18 +407,33 @@ export default class Chat extends EventListenerBase<{
|
||||
searchTab.close();
|
||||
}
|
||||
|
||||
const [noForwards, isRestricted, isAnyGroup, _, isMegagroup] = await m(Promise.all([
|
||||
const [
|
||||
noForwards,
|
||||
isRestricted,
|
||||
isAnyGroup,
|
||||
_,
|
||||
isMegagroup,
|
||||
isBroadcast,
|
||||
isChannel,
|
||||
isBot
|
||||
] = await m(Promise.all([
|
||||
this.managers.appPeersManager.noForwards(peerId),
|
||||
this.managers.appPeersManager.isRestricted(peerId),
|
||||
this._isAnyGroup(peerId),
|
||||
this.setAutoDownloadMedia(),
|
||||
this.managers.appPeersManager.isMegagroup(peerId)
|
||||
this.managers.appPeersManager.isMegagroup(peerId),
|
||||
this.managers.appPeersManager.isBroadcast(peerId),
|
||||
this.managers.appPeersManager.isChannel(peerId),
|
||||
this.managers.appPeersManager.isBot(peerId)
|
||||
]));
|
||||
|
||||
this.noForwards = noForwards;
|
||||
this.isRestricted = isRestricted;
|
||||
this.isAnyGroup = isAnyGroup;
|
||||
this.isMegagroup = isMegagroup;
|
||||
this.isBroadcast = isBroadcast;
|
||||
this.isChannel = isChannel;
|
||||
this.isBot = isBot;
|
||||
|
||||
this.container.classList.toggle('no-forwards', this.noForwards);
|
||||
|
||||
|
@ -54,7 +54,7 @@ export default class ConnectionStatusComponent {
|
||||
chatsContainer.prepend(this.statusContainer);
|
||||
|
||||
rootScope.addEventListener('connection_status_change', (status) => {
|
||||
console.log(status);
|
||||
// console.log(status);
|
||||
|
||||
this.setConnectionStatus();
|
||||
});
|
||||
|
@ -159,9 +159,12 @@ export class ScrollableBase {
|
||||
|
||||
public scrollIntoViewNew(options: Omit<ScrollOptions, 'container'>) {
|
||||
// return Promise.resolve();
|
||||
this.removeListeners();
|
||||
return fastSmoothScroll({
|
||||
...options,
|
||||
container: this.container
|
||||
}).finally(() => {
|
||||
this.setListeners();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,11 @@ export default class ScrollSaver {
|
||||
const {scrollTop, scrollHeight} = this.scrollable;
|
||||
this.scrollHeight = scrollHeight;
|
||||
|
||||
if(!this.elements.length) { // maybe all messages have been deleted
|
||||
this._restore(useReflow);
|
||||
return;
|
||||
}
|
||||
|
||||
let anchor: ScrollSaver['elements'][0];
|
||||
// for(let i = this.elements.length - 1; i >= 0; --i) {
|
||||
// const _anchor = this.elements[i];
|
||||
|
@ -200,6 +200,10 @@ document.addEventListener('DOMContentLoaded', async() => {
|
||||
]);
|
||||
I18n.setTimeFormat(stateResult.state.settings.timeFormat);
|
||||
|
||||
rootScope.managers.rootScope.getPremium().then((isPremium) => {
|
||||
rootScope.premium = isPremium;
|
||||
});
|
||||
|
||||
themeController.setThemeListener();
|
||||
|
||||
if(langPack.appVersion !== App.langPackVersion) {
|
||||
|
@ -245,6 +245,8 @@ export class AppDownloadManager {
|
||||
// this.downloadsToDisc[cacheFileName] = promise;
|
||||
|
||||
if(justAttach) {
|
||||
// * force SW to keep alive
|
||||
fetch(url, {headers: {'Cache-Control': 'no-cache'}}).then((response) => response.status);
|
||||
return promise;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ export class AppImManager extends EventListenerBase<{
|
||||
|
||||
appMediaPlaybackController.construct(managers);
|
||||
uiNotificationsManager.construct(managers);
|
||||
// uiNotificationsManager.start();
|
||||
uiNotificationsManager.start();
|
||||
|
||||
this.log = logger('IM', LogTypes.Log | LogTypes.Warn | LogTypes.Debug | LogTypes.Error);
|
||||
|
||||
|
@ -51,7 +51,6 @@ export class AppManagersManager {
|
||||
++this.cryptoPortsAttached;
|
||||
cryptoMessagePort.attachPort(port);
|
||||
this.cryptoPortPromise?.resolve();
|
||||
return;
|
||||
});
|
||||
|
||||
port.addEventListener('createProxyWorkerURLs', (blob) => {
|
||||
|
@ -196,6 +196,10 @@ export class RootScope extends EventListenerBase<BroadcastEventsListeners> {
|
||||
return this.connectionStatus;
|
||||
}
|
||||
|
||||
public getPremium() {
|
||||
return this.premium;
|
||||
}
|
||||
|
||||
public dispatchEventSingle(...args: any[]) {
|
||||
// @ts-ignore
|
||||
super.dispatchEvent(...args);
|
||||
|
@ -35,12 +35,13 @@ const sendMessagePort = (source: MessageSendPort) => {
|
||||
|
||||
const sendMessagePortIfNeeded = (source: MessageSendPort) => {
|
||||
if(!connectedWindows.size && !_mtprotoMessagePort) {
|
||||
log('sending message port for mtproto');
|
||||
sendMessagePort(source);
|
||||
}
|
||||
};
|
||||
|
||||
const onWindowConnected = (source: WindowClient) => {
|
||||
log('window connected', source.id);
|
||||
log('window connected', source.id, 'windows before', connectedWindows.size);
|
||||
|
||||
if(source.frameType === 'none') {
|
||||
log.warn('maybe a bugged Safari starting window', source.id);
|
||||
@ -82,14 +83,15 @@ getWindowClients().then((windowClients) => {
|
||||
});
|
||||
|
||||
const connectedWindows: Set<string> = new Set();
|
||||
(self as any).connectedWindows = connectedWindows;
|
||||
listenMessagePort(serviceMessagePort, undefined, (source) => {
|
||||
const isWindowClient = source instanceof WindowClient;
|
||||
if(!isWindowClient || !connectedWindows.has(source.id)) {
|
||||
return;
|
||||
}
|
||||
|
||||
log('window disconnected');
|
||||
connectedWindows.delete(source.id);
|
||||
log('window disconnected, left', connectedWindows.size);
|
||||
if(!connectedWindows.size) {
|
||||
log.warn('no windows left');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user