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"; @@ -73,7 +73,8 @@ import { EmoticonsDropdown } from "../emoticonsDropdown";
const USE_MEDIA_TAILS = false;
const IGNORE_ACTIONS: Set<Message.messageService['action']['_']> = new Set([
'messageActionHistoryClear',
'messageActionChatCreate'
'messageActionChatCreate'/* ,
'messageActionChannelMigrateFrom' */
]);
const TEST_SCROLL_TIMES: number = undefined;
@ -1724,6 +1725,8 @@ export default class ChatBubbles { @@ -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 { @@ -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 { @@ -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 { @@ -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);

20
src/components/chat/chat.ts

@ -55,7 +55,7 @@ export default class Chat extends EventListenerBase<{ @@ -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<void>;
@ -66,6 +66,8 @@ export default class Chat extends EventListenerBase<{ @@ -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<{ @@ -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<{ @@ -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;

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

@ -1168,7 +1168,7 @@ export default class AppSharedMediaTab extends SliderSuperTab { @@ -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 = '';
}
}

2
src/config/app.ts

@ -17,7 +17,7 @@ const App = { @@ -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[],

2
src/lang.ts

@ -46,6 +46,8 @@ const lang = { @@ -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",

4
src/lib/appManagers/appChatsManager.ts

@ -217,6 +217,10 @@ export class AppChatsManager { @@ -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;
}

2
src/lib/appManagers/appImManager.ts

@ -1025,7 +1025,7 @@ export class AppImManager { @@ -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();
}

Loading…
Cancel
Save