Browse Source

Fix loading messages if list is too short

Show 'migrated from' & 'migrated to' service messages
master
Eduard Kuzmenko 3 years ago
parent
commit
b986510798
  1. 22
      src/components/chat/bubbles.ts
  2. 20
      src/components/chat/chat.ts
  3. 2
      src/components/sidebarRight/tabs/sharedMedia.ts
  4. 2
      src/config/app.ts
  5. 2
      src/lang.ts
  6. 4
      src/lib/appManagers/appChatsManager.ts
  7. 2
      src/lib/appManagers/appImManager.ts

22
src/components/chat/bubbles.ts

@ -73,7 +73,8 @@ import { EmoticonsDropdown } from "../emoticonsDropdown";
const USE_MEDIA_TAILS = false; const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([ const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
'messageActionHistoryClear', 'messageActionHistoryClear',
'messageActionChatCreate' 'messageActionChatCreate'/* ,
'messageActionChannelMigrateFrom' */
]); ]);
const TEST_SCROLL_TIMES: number = undefined; const TEST_SCROLL_TIMES: number = undefined;
@ -1724,6 +1725,8 @@ export default class ChatBubbles {
// this.ladderDeferred.resolve(); // this.ladderDeferred.resolve();
this.scrollable.lastScrollDirection = 0;
this.scrollable.lastScrollTop = 0;
replaceContent(this.scrollable.container, this.chatInner); replaceContent(this.scrollable.container, this.chatInner);
animationIntersector.unlockGroup(CHAT_ANIMATION_GROUP); animationIntersector.unlockGroup(CHAT_ANIMATION_GROUP);
@ -1775,6 +1778,12 @@ export default class ChatBubbles {
this.onScroll(); 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); this.chat.dispatchEvent('setPeer', lastMsgId, !isJump);
const needFetchInterval = this.appMessagesManager.isFetchIntervalNeeded(peerId); const needFetchInterval = this.appMessagesManager.isFetchIntervalNeeded(peerId);
@ -1785,8 +1794,7 @@ export default class ChatBubbles {
this.setLoaded('bottom', true); this.setLoaded('bottom', true);
} }
} else { } else {
const middleware = this.getMiddleware(); afterSetPromise.then(() => {
Promise.all([setPeerPromise, getHeavyAnimationPromise()]).then(() => {
if(!middleware()) { if(!middleware()) {
return; return;
} }
@ -2108,7 +2116,13 @@ export default class ChatBubbles {
const s = document.createElement('div'); const s = document.createElement('div');
s.classList.add('service-msg'); s.classList.add('service-msg');
if(action) { 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); bubbleContainer.append(s);

20
src/components/chat/chat.ts

@ -55,7 +55,7 @@ export default class Chat extends EventListenerBase<{
public contextMenu: ChatContextMenu; public contextMenu: ChatContextMenu;
public wasAlreadyUsed = false; public wasAlreadyUsed = false;
public initPeerId = 0; // public initPeerId = 0;
public peerId = 0; public peerId = 0;
public threadId: number; public threadId: number;
public setPeerPromise: Promise<void>; public setPeerPromise: Promise<void>;
@ -67,6 +67,8 @@ export default class Chat extends EventListenerBase<{
public noAutoDownloadMedia: boolean; public noAutoDownloadMedia: boolean;
public inited = false;
constructor(public appImManager: AppImManager, constructor(public appImManager: AppImManager,
public appChatsManager: AppChatsManager, public appChatsManager: AppChatsManager,
public appDocsManager: AppDocsManager, public appDocsManager: AppDocsManager,
@ -166,8 +168,8 @@ export default class Chat extends EventListenerBase<{
} }
} }
public init(peerId: number) { public init(/* peerId: number */) {
this.initPeerId = peerId; // this.initPeerId = peerId;
this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager); 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); 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) { public setPeer(peerId: number, lastMsgId?: number) {
if(this.init) { if(!peerId) {
this.init(peerId); this.inited = false;
this.init = null; } else if(!this.inited) {
if(this.init) {
this.init(/* peerId */);
this.init = null;
}
this.inited = true;
} }
const samePeer = this.peerId === peerId; const samePeer = this.peerId === peerId;

2
src/components/sidebarRight/tabs/sharedMedia.ts

@ -1168,7 +1168,7 @@ export default class AppSharedMediaTab extends SliderSuperTab {
} }
} else { } else {
const chat: Chat = appChatsManager.getChat(-this.peerId); 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 = ''; this.editBtn.style.display = '';
} }
} }

2
src/config/app.ts

@ -17,7 +17,7 @@ const App = {
id: 1025907, id: 1025907,
hash: '452b0359b988148995f22ff0f4229750', hash: '452b0359b988148995f22ff0f4229750',
version: '0.6.0', version: '0.6.0',
langPackVersion: '0.3.0', langPackVersion: '0.3.1',
langPack: 'macos', langPack: 'macos',
langPackCode: 'en', langPackCode: 'en',
domains: [MAIN_DOMAIN] as string[], domains: [MAIN_DOMAIN] as string[],

2
src/lang.ts

@ -46,6 +46,8 @@ const lang = {
//"ChatList.Menu.Archived": "Archived", //"ChatList.Menu.Archived": "Archived",
"ChatList.Menu.SwitchTo.Webogram": "Switch to Old Version", "ChatList.Menu.SwitchTo.Webogram": "Switch to Old Version",
"ChatList.Menu.SwitchTo.Z": "Switch to Z version", "ChatList.Menu.SwitchTo.Z": "Switch to Z version",
"ChatMigration.From": "Migrated from %s",
"ChatMigration.To": "Migrated to %s",
"ConnectionStatus.ForceReconnect": "force reconnect", "ConnectionStatus.ForceReconnect": "force reconnect",
"ConnectionStatus.ReconnectIn": "Reconnect in %ds, %s", "ConnectionStatus.ReconnectIn": "Reconnect in %ds, %s",
"ConnectionStatus.Reconnect": "reconnect", "ConnectionStatus.Reconnect": "reconnect",

4
src/lib/appManagers/appChatsManager.ts

@ -217,6 +217,10 @@ export class AppChatsManager {
return false; return false;
} }
if((chat as Chat.chat).pFlags.deactivated && action !== 'view_messages') {
return false;
}
if(chat.pFlags.creator && rights === undefined) { if(chat.pFlags.creator && rights === undefined) {
return true; return true;
} }

2
src/lib/appManagers/appImManager.ts

@ -1025,7 +1025,7 @@ export class AppImManager {
} }
const chat = this.chat; const chat = this.chat;
if(!chat.init) { // * use first not inited chat if(chat.inited) { // * use first not inited chat
this.createNewChat(); this.createNewChat();
} }

Loading…
Cancel
Save