|
|
@ -1,6 +1,5 @@ |
|
|
|
//import apiManager from '../mtproto/apiManager';
|
|
|
|
//import apiManager from '../mtproto/apiManager';
|
|
|
|
import animationIntersector from '../../components/animationIntersector'; |
|
|
|
import animationIntersector from '../../components/animationIntersector'; |
|
|
|
import { horizontalMenu } from '../../components/horizontalMenu'; |
|
|
|
|
|
|
|
import appSidebarLeft from "../../components/sidebarLeft"; |
|
|
|
import appSidebarLeft from "../../components/sidebarLeft"; |
|
|
|
import appSidebarRight, { AppSidebarRight, RIGHT_COLUMN_ACTIVE_CLASSNAME } from '../../components/sidebarRight'; |
|
|
|
import appSidebarRight, { AppSidebarRight, RIGHT_COLUMN_ACTIVE_CLASSNAME } from '../../components/sidebarRight'; |
|
|
|
import mediaSizes, { ScreenSize } from '../../helpers/mediaSizes'; |
|
|
|
import mediaSizes, { ScreenSize } from '../../helpers/mediaSizes'; |
|
|
@ -22,13 +21,13 @@ import appStickersManager from './appStickersManager'; |
|
|
|
import appWebPagesManager from './appWebPagesManager'; |
|
|
|
import appWebPagesManager from './appWebPagesManager'; |
|
|
|
import { cancelEvent, getFilesFromEvent, placeCaretAtEnd } from '../../helpers/dom'; |
|
|
|
import { cancelEvent, getFilesFromEvent, placeCaretAtEnd } from '../../helpers/dom'; |
|
|
|
import PopupNewMedia from '../../components/popups/newMedia'; |
|
|
|
import PopupNewMedia from '../../components/popups/newMedia'; |
|
|
|
import { TransitionSlider } from '../../components/transition'; |
|
|
|
|
|
|
|
import { numberWithCommas } from '../../helpers/number'; |
|
|
|
import { numberWithCommas } from '../../helpers/number'; |
|
|
|
import MarkupTooltip from '../../components/chat/markupTooltip'; |
|
|
|
import MarkupTooltip from '../../components/chat/markupTooltip'; |
|
|
|
import { isTouchSupported } from '../../helpers/touchSupport'; |
|
|
|
import { isTouchSupported } from '../../helpers/touchSupport'; |
|
|
|
import appPollsManager from './appPollsManager'; |
|
|
|
import appPollsManager from './appPollsManager'; |
|
|
|
import SetTransition from '../../components/singleTransition'; |
|
|
|
import SetTransition from '../../components/singleTransition'; |
|
|
|
import ChatDragAndDrop from '../../components/chat/dragAndDrop'; |
|
|
|
import ChatDragAndDrop from '../../components/chat/dragAndDrop'; |
|
|
|
|
|
|
|
import { debounce } from '../../helpers/schedulers'; |
|
|
|
|
|
|
|
|
|
|
|
//console.log('appImManager included33!');
|
|
|
|
//console.log('appImManager included33!');
|
|
|
|
|
|
|
|
|
|
|
@ -42,7 +41,7 @@ export class AppImManager { |
|
|
|
public columnEl = document.getElementById('column-center') as HTMLDivElement; |
|
|
|
public columnEl = document.getElementById('column-center') as HTMLDivElement; |
|
|
|
public chatsContainer: HTMLElement; |
|
|
|
public chatsContainer: HTMLElement; |
|
|
|
|
|
|
|
|
|
|
|
public chatsSelectTab: ReturnType<typeof horizontalMenu>; |
|
|
|
//public chatsSelectTab: ReturnType<typeof horizontalMenu>;
|
|
|
|
|
|
|
|
|
|
|
|
public offline = false; |
|
|
|
public offline = false; |
|
|
|
public updateStatusInterval = 0; |
|
|
|
public updateStatusInterval = 0; |
|
|
@ -58,7 +57,9 @@ export class AppImManager { |
|
|
|
public hideRightSidebar = false; |
|
|
|
public hideRightSidebar = false; |
|
|
|
|
|
|
|
|
|
|
|
private chats: Chat[] = []; |
|
|
|
private chats: Chat[] = []; |
|
|
|
|
|
|
|
private prevTab: HTMLElement; |
|
|
|
|
|
|
|
private chatsSelectTabDebounced: () => void; |
|
|
|
|
|
|
|
|
|
|
|
public markupTooltip: MarkupTooltip; |
|
|
|
public markupTooltip: MarkupTooltip; |
|
|
|
|
|
|
|
|
|
|
|
get myId() { |
|
|
|
get myId() { |
|
|
@ -119,19 +120,19 @@ export class AppImManager { |
|
|
|
this.chatsContainer = document.createElement('div'); |
|
|
|
this.chatsContainer = document.createElement('div'); |
|
|
|
this.chatsContainer.classList.add('chats-container', 'tabs-container'); |
|
|
|
this.chatsContainer.classList.add('chats-container', 'tabs-container'); |
|
|
|
|
|
|
|
|
|
|
|
this.chatsSelectTab = TransitionSlider(this.chatsContainer, 'navigation', 250, (id) => { |
|
|
|
this.columnEl.append(this.chatsContainer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.chatsSelectTabDebounced = debounce(() => { |
|
|
|
const topbar = this.chat.topbar; |
|
|
|
const topbar = this.chat.topbar; |
|
|
|
if(topbar.pinnedMessage) { // * буду молиться богам, чтобы это ничего не сломало, но это исправляет получение пиннеда после анимации
|
|
|
|
if(topbar.pinnedMessage) { // * буду молиться богам, чтобы это ничего не сломало, но это исправляет получение пиннеда после анимации
|
|
|
|
topbar.pinnedMessage.setCorrectIndex(0); |
|
|
|
topbar.pinnedMessage.setCorrectIndex(0); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
apiManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId); |
|
|
|
apiManager.setQueueId(this.chat.bubbles.lazyLoadQueue.queueId); |
|
|
|
}); |
|
|
|
}, 250, false, true); |
|
|
|
|
|
|
|
|
|
|
|
this.columnEl.append(this.chatsContainer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.createNewChat(); |
|
|
|
this.createNewChat(); |
|
|
|
this.chatsSelectTab(0); |
|
|
|
this.chatsSelectTab(this.chat.container); |
|
|
|
|
|
|
|
|
|
|
|
window.addEventListener('hashchange', (e) => { |
|
|
|
window.addEventListener('hashchange', (e) => { |
|
|
|
const hash = location.hash; |
|
|
|
const hash = location.hash; |
|
|
@ -169,6 +170,20 @@ export class AppImManager { |
|
|
|
//apiUpdatesManager.attach();
|
|
|
|
//apiUpdatesManager.attach();
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private chatsSelectTab(tab: HTMLElement) { |
|
|
|
|
|
|
|
if(this.prevTab === tab) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(this.prevTab) { |
|
|
|
|
|
|
|
this.prevTab.classList.remove('active'); |
|
|
|
|
|
|
|
this.chatsSelectTabDebounced(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tab.classList.add('active'); |
|
|
|
|
|
|
|
this.prevTab = tab; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private init() { |
|
|
|
private init() { |
|
|
|
document.addEventListener('paste', this.onDocumentPaste, true); |
|
|
|
document.addEventListener('paste', this.onDocumentPaste, true); |
|
|
|
|
|
|
|
|
|
|
@ -498,9 +513,16 @@ export class AppImManager { |
|
|
|
return this.setPeer(peerId, lastMsgId); |
|
|
|
return this.setPeer(peerId, lastMsgId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// * don't reset peer if returning
|
|
|
|
|
|
|
|
if(peerId === chat.peerId && mediaSizes.activeScreen === ScreenSize.mobile && document.body.classList.contains(LEFT_COLUMN_ACTIVE_CLASSNAME)) { |
|
|
|
|
|
|
|
this.selectTab(1); |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(peerId || mediaSizes.activeScreen !== ScreenSize.mobile) { |
|
|
|
if(peerId || mediaSizes.activeScreen !== ScreenSize.mobile) { |
|
|
|
const result = chat.setPeer(peerId, lastMsgId); |
|
|
|
const result = chat.setPeer(peerId, lastMsgId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// * wait for cached render
|
|
|
|
const promise = result?.cached ? result.promise : Promise.resolve(); |
|
|
|
const promise = result?.cached ? result.promise : Promise.resolve(); |
|
|
|
if(peerId) { |
|
|
|
if(peerId) { |
|
|
|
promise.then(() => { |
|
|
|
promise.then(() => { |
|
|
@ -511,6 +533,9 @@ export class AppImManager { |
|
|
|
this.hideRightSidebar = false; |
|
|
|
this.hideRightSidebar = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
this.chatsSelectTab(this.chat.container); |
|
|
|
|
|
|
|
}, 0); |
|
|
|
this.selectTab(1); |
|
|
|
this.selectTab(1); |
|
|
|
}, 0); |
|
|
|
}, 0); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -537,7 +562,7 @@ export class AppImManager { |
|
|
|
this.chat.setType(type); |
|
|
|
this.chat.setType(type); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.chatsSelectTab(this.chat.container); |
|
|
|
//this.chatsSelectTab(this.chat.container);
|
|
|
|
|
|
|
|
|
|
|
|
return this.setPeer(peerId, lastMsgId); |
|
|
|
return this.setPeer(peerId, lastMsgId); |
|
|
|
} |
|
|
|
} |
|
|
|