diff --git a/src/components/chat/bubbles.ts b/src/components/chat/bubbles.ts index d14546f5..561e1587 100644 --- a/src/components/chat/bubbles.ts +++ b/src/components/chat/bubbles.ts @@ -73,7 +73,8 @@ import { EmoticonsDropdown } from "../emoticonsDropdown"; const USE_MEDIA_TAILS = false; const IGNORE_ACTIONS: Set = new Set([ 'messageActionHistoryClear', - 'messageActionChatCreate' + 'messageActionChatCreate'/* , + 'messageActionChannelMigrateFrom' */ ]); const TEST_SCROLL_TIMES: number = undefined; @@ -1724,6 +1725,8 @@ export default class ChatBubbles { // this.ladderDeferred.resolve(); + this.scrollable.lastScrollDirection = 0; + this.scrollable.lastScrollTop = 0; replaceContent(this.scrollable.container, this.chatInner); animationIntersector.unlockGroup(CHAT_ANIMATION_GROUP); @@ -1775,6 +1778,12 @@ export default class ChatBubbles { this.onScroll(); + const middleware = this.getMiddleware(); + const afterSetPromise = Promise.all([setPeerPromise, getHeavyAnimationPromise()]); + afterSetPromise.then(() => { // check whether list isn't full + this.scrollable.checkForTriggers(); + }); + this.chat.dispatchEvent('setPeer', lastMsgId, !isJump); const needFetchInterval = this.appMessagesManager.isFetchIntervalNeeded(peerId); @@ -1785,8 +1794,7 @@ export default class ChatBubbles { this.setLoaded('bottom', true); } } else { - const middleware = this.getMiddleware(); - Promise.all([setPeerPromise, getHeavyAnimationPromise()]).then(() => { + afterSetPromise.then(() => { if(!middleware()) { return; } @@ -2108,7 +2116,13 @@ export default class ChatBubbles { const s = document.createElement('div'); s.classList.add('service-msg'); if(action) { - s.append(this.appMessagesManager.wrapMessageActionTextNew(message)); + if(action._ === 'messageActionChannelMigrateFrom') { + s.append(i18n('ChatMigration.From', [new PeerTitle({peerId: -action.chat_id}).element])); + } else if(action._ === 'messageActionChatMigrateTo') { + s.append(i18n('ChatMigration.To', [new PeerTitle({peerId: -action.channel_id}).element])); + } else { + s.append(this.appMessagesManager.wrapMessageActionTextNew(message)); + } } bubbleContainer.append(s); diff --git a/src/components/chat/chat.ts b/src/components/chat/chat.ts index a37c96e0..c24ffb44 100644 --- a/src/components/chat/chat.ts +++ b/src/components/chat/chat.ts @@ -55,7 +55,7 @@ export default class Chat extends EventListenerBase<{ public contextMenu: ChatContextMenu; public wasAlreadyUsed = false; - public initPeerId = 0; + // public initPeerId = 0; public peerId = 0; public threadId: number; public setPeerPromise: Promise; @@ -66,6 +66,8 @@ export default class Chat extends EventListenerBase<{ public type: ChatType = 'chat'; public noAutoDownloadMedia: boolean; + + public inited = false; constructor(public appImManager: AppImManager, public appChatsManager: AppChatsManager, @@ -166,8 +168,8 @@ export default class Chat extends EventListenerBase<{ } } - public init(peerId: number) { - this.initPeerId = peerId; + public init(/* peerId: number */) { + // this.initPeerId = peerId; this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager); this.bubbles = new ChatBubbles(this, this.appMessagesManager, this.appStickersManager, this.appUsersManager, this.appInlineBotsManager, this.appPhotosManager, this.appPeersManager, this.appProfileManager); @@ -246,9 +248,15 @@ export default class Chat extends EventListenerBase<{ } public setPeer(peerId: number, lastMsgId?: number) { - if(this.init) { - this.init(peerId); - this.init = null; + if(!peerId) { + this.inited = false; + } else if(!this.inited) { + if(this.init) { + this.init(/* peerId */); + this.init = null; + } + + this.inited = true; } const samePeer = this.peerId === peerId; diff --git a/src/components/sidebarRight/tabs/sharedMedia.ts b/src/components/sidebarRight/tabs/sharedMedia.ts index f768277a..fc2e6301 100644 --- a/src/components/sidebarRight/tabs/sharedMedia.ts +++ b/src/components/sidebarRight/tabs/sharedMedia.ts @@ -1168,7 +1168,7 @@ export default class AppSharedMediaTab extends SliderSuperTab { } } else { const chat: Chat = appChatsManager.getChat(-this.peerId); - if(chat._ === 'chat' || (chat as Chat.channel).admin_rights) { + if((chat._ === 'chat' || (chat as Chat.channel).admin_rights) && !(chat as Chat.chat).pFlags.deactivated) { this.editBtn.style.display = ''; } } diff --git a/src/config/app.ts b/src/config/app.ts index 4f447713..3a8eefbf 100644 --- a/src/config/app.ts +++ b/src/config/app.ts @@ -17,7 +17,7 @@ const App = { id: 1025907, hash: '452b0359b988148995f22ff0f4229750', version: '0.6.0', - langPackVersion: '0.3.0', + langPackVersion: '0.3.1', langPack: 'macos', langPackCode: 'en', domains: [MAIN_DOMAIN] as string[], diff --git a/src/lang.ts b/src/lang.ts index 4ff36879..4e126c64 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -46,6 +46,8 @@ const lang = { //"ChatList.Menu.Archived": "Archived", "ChatList.Menu.SwitchTo.Webogram": "Switch to Old Version", "ChatList.Menu.SwitchTo.Z": "Switch to Z version", + "ChatMigration.From": "Migrated from %s", + "ChatMigration.To": "Migrated to %s", "ConnectionStatus.ForceReconnect": "force reconnect", "ConnectionStatus.ReconnectIn": "Reconnect in %ds, %s", "ConnectionStatus.Reconnect": "reconnect", diff --git a/src/lib/appManagers/appChatsManager.ts b/src/lib/appManagers/appChatsManager.ts index ebaa6726..030494db 100644 --- a/src/lib/appManagers/appChatsManager.ts +++ b/src/lib/appManagers/appChatsManager.ts @@ -217,6 +217,10 @@ export class AppChatsManager { return false; } + if((chat as Chat.chat).pFlags.deactivated && action !== 'view_messages') { + return false; + } + if(chat.pFlags.creator && rights === undefined) { return true; } diff --git a/src/lib/appManagers/appImManager.ts b/src/lib/appManagers/appImManager.ts index 334658ee..ca85bfb9 100644 --- a/src/lib/appManagers/appImManager.ts +++ b/src/lib/appManagers/appImManager.ts @@ -1025,7 +1025,7 @@ export class AppImManager { } const chat = this.chat; - if(!chat.init) { // * use first not inited chat + if(chat.inited) { // * use first not inited chat this.createNewChat(); }