Browse Source

Temp

master
Eduard Kuzmenko 4 years ago
parent
commit
a4b023a247
  1. 30
      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

30
src/components/chat/bubbles.ts

@ -1618,17 +1618,33 @@ export default class ChatBubbles { @@ -1618,17 +1618,33 @@ export default class ChatBubbles {
this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
// warning
if((!lastMsgId && !savedPosition) || this.bubbles[topMessage] || lastMsgId === topMessage) {
this.scrollable.loadedAll.bottom = true;
}
if(savedPosition) {
const isFetchIntervalNeeded = () => peerId < 0 && !this.appChatsManager.isInChat(peerId);
const needFetchInterval = isFetchIntervalNeeded();
const needFetchNew = savedPosition || needFetchInterval;
if(!needFetchNew) {
// warning
if(!lastMsgId || this.bubbles[topMessage] || lastMsgId === topMessage) {
this.scrollable.loadedAll.bottom = true;
}
} else {
Promise.all([setPeerPromise, getHeavyAnimationPromise()]).then(() => {
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);
}
});
}
this.log('scrolledAllDown:', this.scrollable.loadedAll.bottom);
//if(!this.unreaded.length && dialog) { // lol

15
src/lib/appManagers/appChatsManager.ts

@ -393,6 +393,21 @@ export class AppChatsManager { @@ -393,6 +393,21 @@ export class AppChatsManager {
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 {
if(id < 0) id = -id;
const chat: Chat = this.getChat(id);

11
src/lib/appManagers/appMessagesManager.ts

@ -3652,14 +3652,7 @@ export class AppMessagesManager { @@ -3652,14 +3652,7 @@ export class AppMessagesManager {
if(!dialog && !isLocalThreadUpdate) {
let good = true;
if(peerId < 0) {
const chat = appChatsManager.getChat(-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;
}
good = appChatsManager.isInChat(-peerId);
}
if(good) {
@ -4034,7 +4027,7 @@ export class AppMessagesManager { @@ -4034,7 +4027,7 @@ export class AppMessagesManager {
const peerId = -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 canViewHistory = channel._ === 'channel' && (channel.username || !channel.pFlags.left && !channel.pFlags.kicked);

2
src/lib/idb.ts

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

Loading…
Cancel
Save