Browse Source

Temp

master
Eduard Kuzmenko 4 years ago
parent
commit
a4b023a247
  1. 22
      src/components/chat/bubbles.ts
  2. 15
      src/lib/appManagers/appChatsManager.ts
  3. 11
      src/lib/appManagers/appMessagesManager.ts
  4. 2
      src/lib/idb.ts

22
src/components/chat/bubbles.ts

@ -1618,14 +1618,30 @@ export default class ChatBubbles {
this.chat.dispatchEvent('setPeer', lastMsgId, !isJump); this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
const isFetchIntervalNeeded = () => peerId < 0 && !this.appChatsManager.isInChat(peerId);
const needFetchInterval = isFetchIntervalNeeded();
const needFetchNew = savedPosition || needFetchInterval;
if(!needFetchNew) {
// warning // warning
if((!lastMsgId && !savedPosition) || this.bubbles[topMessage] || lastMsgId === topMessage) { if(!lastMsgId || this.bubbles[topMessage] || lastMsgId === topMessage) {
this.scrollable.loadedAll.bottom = true; this.scrollable.loadedAll.bottom = true;
} }
} else {
if(savedPosition) {
Promise.all([setPeerPromise, getHeavyAnimationPromise()]).then(() => { Promise.all([setPeerPromise, getHeavyAnimationPromise()]).then(() => {
this.scrollable.checkForTriggers(); this.scrollable.checkForTriggers();
if(needFetchInterval) {
const middleware = this.getMiddleware();
const interval = window.setInterval(() => {
if(!middleware() || !isFetchIntervalNeeded()) {
clearInterval(interval);
return;
}
this.scrollable.loadedAll.bottom = false;
this.loadMoreHistory(false);
}, 30e3);
}
}); });
} }

15
src/lib/appManagers/appChatsManager.ts

@ -393,6 +393,21 @@ export class AppChatsManager {
return this.isChannel(id) && !this.isMegagroup(id); return this.isChannel(id) && !this.isMegagroup(id);
} }
public isInChat(id: number) {
let good = true;
const chat: Chat = this.getChat(id);
if(chat._ === 'channelForbidden'
|| chat._ === 'chatForbidden'
|| chat._ === 'chatEmpty'
|| (chat as Chat.chat).pFlags.left
|| (chat as Chat.chat).pFlags.kicked
|| (chat as Chat.chat).pFlags.deactivated) {
good = false;
}
return good;
}
public getChannelInput(id: number): InputChannel { public getChannelInput(id: number): InputChannel {
if(id < 0) id = -id; if(id < 0) id = -id;
const chat: Chat = this.getChat(id); const chat: Chat = this.getChat(id);

11
src/lib/appManagers/appMessagesManager.ts

@ -3652,14 +3652,7 @@ export class AppMessagesManager {
if(!dialog && !isLocalThreadUpdate) { if(!dialog && !isLocalThreadUpdate) {
let good = true; let good = true;
if(peerId < 0) { if(peerId < 0) {
const chat = appChatsManager.getChat(-peerId); good = appChatsManager.isInChat(-peerId);
if(chat._ === 'channelForbidden'
|| chat._ === 'chatForbidden'
|| (chat as Chat.chat).pFlags.left
|| (chat as Chat.chat).pFlags.kicked
|| (chat as Chat.chat).pFlags.deactivated) {
good = false;
}
} }
if(good) { if(good) {
@ -4034,7 +4027,7 @@ export class AppMessagesManager {
const peerId = -channelId; const peerId = -channelId;
const channel = appChatsManager.getChat(channelId); const channel = appChatsManager.getChat(channelId);
const needDialog = channel._ === 'channel' && (!channel.pFlags.left && !channel.pFlags.kicked); const needDialog = channel._ === 'channel' && appChatsManager.isInChat(channelId);
const dialog = this.getDialogOnly(peerId); const dialog = this.getDialogOnly(peerId);
const canViewHistory = channel._ === 'channel' && (channel.username || !channel.pFlags.left && !channel.pFlags.kicked); const canViewHistory = channel._ === 'channel' && (channel.username || !channel.pFlags.left && !channel.pFlags.kicked);

2
src/lib/idb.ts

@ -35,7 +35,7 @@ export type IDBOptions = {
version?: number version?: number
}; };
const DEBUG = true; const DEBUG = false;
export default class IDBStorage { export default class IDBStorage {
private static STORAGES: IDBStorage[] = []; private static STORAGES: IDBStorage[] = [];

Loading…
Cancel
Save