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