|
|
@ -44,6 +44,17 @@ const stickersTab = new AppStickersTab(); |
|
|
|
const pollResultsTab = new AppPollResultsTab(); |
|
|
|
const pollResultsTab = new AppPollResultsTab(); |
|
|
|
const gifsTab = new AppGifsTab(); |
|
|
|
const gifsTab = new AppGifsTab(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type ContentType = 'contentMembers' | 'contentMedia' | 'contentDocuments' | 'contentLinks' | 'contentAudio'; |
|
|
|
|
|
|
|
type SharedMediaType = 'inputMessagesFilterContacts' | 'inputMessagesFilterPhotoVideo' | 'inputMessagesFilterDocument' | 'inputMessagesFilterUrl' | 'inputMessagesFilterMusic'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const contentToSharedMap: {[contentType in ContentType]: SharedMediaType} = { |
|
|
|
|
|
|
|
contentMembers: 'inputMessagesFilterContacts', |
|
|
|
|
|
|
|
contentMedia: 'inputMessagesFilterPhotoVideo', |
|
|
|
|
|
|
|
contentDocuments: 'inputMessagesFilterDocument', |
|
|
|
|
|
|
|
contentLinks: 'inputMessagesFilterUrl', |
|
|
|
|
|
|
|
contentAudio: 'inputMessagesFilterMusic' |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export class AppSidebarRight extends SidebarSlider { |
|
|
|
export class AppSidebarRight extends SidebarSlider { |
|
|
|
public static SLIDERITEMSIDS = { |
|
|
|
public static SLIDERITEMSIDS = { |
|
|
|
search: 1, |
|
|
|
search: 1, |
|
|
@ -68,13 +79,13 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
notificationsStatus: HTMLParagraphElement |
|
|
|
notificationsStatus: HTMLParagraphElement |
|
|
|
} = {} as any; |
|
|
|
} = {} as any; |
|
|
|
public sharedMedia: { |
|
|
|
public sharedMedia: { |
|
|
|
[type: string]: HTMLDivElement |
|
|
|
[t in ContentType]: HTMLDivElement |
|
|
|
} = {}; |
|
|
|
} = {} as any; |
|
|
|
|
|
|
|
|
|
|
|
private loadSidebarMediaPromises: {[type: string]: Promise<void>} = {}; |
|
|
|
private loadSidebarMediaPromises: {[type: string]: Promise<void>} = {}; |
|
|
|
private loadedAllMedia: {[type: string]: boolean} = {}; |
|
|
|
private loadedAllMedia: {[type: string]: boolean} = {}; |
|
|
|
|
|
|
|
|
|
|
|
public sharedMediaTypes = [ |
|
|
|
public sharedMediaTypes: SharedMediaType[] = [ |
|
|
|
//'members',
|
|
|
|
//'members',
|
|
|
|
'inputMessagesFilterContacts', |
|
|
|
'inputMessagesFilterContacts', |
|
|
|
'inputMessagesFilterPhotoVideo', |
|
|
|
'inputMessagesFilterPhotoVideo', |
|
|
@ -82,19 +93,19 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
'inputMessagesFilterUrl', |
|
|
|
'inputMessagesFilterUrl', |
|
|
|
'inputMessagesFilterMusic' |
|
|
|
'inputMessagesFilterMusic' |
|
|
|
]; |
|
|
|
]; |
|
|
|
public sharedMediaType: AppSidebarRight['sharedMediaTypes'][number] = ''; |
|
|
|
public sharedMediaType: SharedMediaType = 'inputMessagesFilterPhotoVideo'; |
|
|
|
private sharedMediaSelected: HTMLDivElement = null; |
|
|
|
private sharedMediaSelected: HTMLDivElement = null; |
|
|
|
|
|
|
|
|
|
|
|
private lazyLoadQueue = new LazyLoadQueue(); |
|
|
|
private lazyLoadQueue = new LazyLoadQueue(); |
|
|
|
|
|
|
|
|
|
|
|
public historiesStorage: { |
|
|
|
public historiesStorage: { |
|
|
|
[peerID: number]: { |
|
|
|
[peerID: number]: Partial<{ |
|
|
|
[type: string]: number[] |
|
|
|
[type in SharedMediaType]: number[] |
|
|
|
} |
|
|
|
}> |
|
|
|
} = {}; |
|
|
|
|
|
|
|
public usedFromHistory: { |
|
|
|
|
|
|
|
[type: string]: number |
|
|
|
|
|
|
|
} = {}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
public usedFromHistory: Partial<{ |
|
|
|
|
|
|
|
[type in SharedMediaType]: number |
|
|
|
|
|
|
|
}> = {}; |
|
|
|
|
|
|
|
|
|
|
|
private log = logger('SR', LogLevels.error); |
|
|
|
private log = logger('SR', LogLevels.error); |
|
|
|
|
|
|
|
|
|
|
@ -197,6 +208,8 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.prevTabID = id; |
|
|
|
this.prevTabID = id; |
|
|
|
|
|
|
|
}, () => { |
|
|
|
|
|
|
|
this.scroll.onScroll(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let sidebarCloseBtn = this.sidebarEl.querySelector('.sidebar-close-button') as HTMLButtonElement; |
|
|
|
let sidebarCloseBtn = this.sidebarEl.querySelector('.sidebar-close-button') as HTMLButtonElement; |
|
|
@ -401,6 +414,12 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
const elemsToAppend: HTMLElement[] = []; |
|
|
|
const elemsToAppend: HTMLElement[] = []; |
|
|
|
const promises: Promise<any>[] = []; |
|
|
|
const promises: Promise<any>[] = []; |
|
|
|
let sharedMediaDiv: HTMLDivElement; |
|
|
|
let sharedMediaDiv: HTMLDivElement; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* for(let contentType in contentToSharedMap) { |
|
|
|
|
|
|
|
if(contentToSharedMap[contentType as ContentType] == type) { |
|
|
|
|
|
|
|
sharedMediaDiv = this.sharedMedia[contentType as ContentType]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
|
|
// https://core.telegram.org/type/MessagesFilter
|
|
|
|
// https://core.telegram.org/type/MessagesFilter
|
|
|
|
switch(type) { |
|
|
|
switch(type) { |
|
|
@ -607,10 +626,19 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(sharedMediaDiv) { |
|
|
|
if(sharedMediaDiv) { |
|
|
|
let parent = sharedMediaDiv.parentElement; |
|
|
|
const parent = sharedMediaDiv.parentElement; |
|
|
|
if(parent.lastElementChild.classList.contains('preloader')) { |
|
|
|
Array.from(parent.children).slice(1).forEach(child => { |
|
|
|
parent.lastElementChild.remove(); |
|
|
|
child.remove(); |
|
|
|
//this.contentContainer.classList.add('loaded');
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this.contentContainer.classList.add('loaded');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!messages.length) { |
|
|
|
|
|
|
|
const div = document.createElement('div'); |
|
|
|
|
|
|
|
div.innerText = 'Nothing interesting here yet...'; |
|
|
|
|
|
|
|
div.classList.add('position-center', 'text-center', 'content-empty', 'no-select'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parent.append(div); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -622,20 +650,20 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
|
|
|
|
|
|
|
|
this.log('loadSidebarMedia', single, this.peerID, this.loadSidebarMediaPromises); |
|
|
|
this.log('loadSidebarMedia', single, this.peerID, this.loadSidebarMediaPromises); |
|
|
|
|
|
|
|
|
|
|
|
let peerID = this.peerID; |
|
|
|
const peerID = this.peerID; |
|
|
|
|
|
|
|
|
|
|
|
let typesToLoad = single ? [this.sharedMediaType] : this.sharedMediaTypes; |
|
|
|
let typesToLoad = single ? [this.sharedMediaType] : this.sharedMediaTypes; |
|
|
|
typesToLoad = typesToLoad.filter(type => !this.loadedAllMedia[type]); |
|
|
|
typesToLoad = typesToLoad.filter(type => !this.loadedAllMedia[type]); |
|
|
|
if(!typesToLoad.length) return; |
|
|
|
if(!typesToLoad.length) return; |
|
|
|
|
|
|
|
|
|
|
|
let loadCount = (appPhotosManager.windowH / 130 | 0) * 3; // that's good for all types
|
|
|
|
const loadCount = (appPhotosManager.windowH / 130 | 0) * 3; // that's good for all types
|
|
|
|
|
|
|
|
|
|
|
|
let historyStorage = this.historiesStorage[peerID] ?? (this.historiesStorage[peerID] = {}); |
|
|
|
const historyStorage = this.historiesStorage[peerID] ?? (this.historiesStorage[peerID] = {}); |
|
|
|
|
|
|
|
|
|
|
|
let promises = typesToLoad.map(type => { |
|
|
|
const promises = typesToLoad.map(type => { |
|
|
|
if(this.loadSidebarMediaPromises[type]) return this.loadSidebarMediaPromises[type]; |
|
|
|
if(this.loadSidebarMediaPromises[type]) return this.loadSidebarMediaPromises[type]; |
|
|
|
|
|
|
|
|
|
|
|
let history = historyStorage[type] ?? (historyStorage[type] = []); |
|
|
|
const history = historyStorage[type] ?? (historyStorage[type] = []); |
|
|
|
|
|
|
|
|
|
|
|
// render from cache
|
|
|
|
// render from cache
|
|
|
|
if(history.length && this.usedFromHistory[type] < history.length) { |
|
|
|
if(history.length && this.usedFromHistory[type] < history.length) { |
|
|
@ -658,9 +686,9 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.usedFromHistory[type] = used; |
|
|
|
this.usedFromHistory[type] = used; |
|
|
|
if(messages.length) { |
|
|
|
//if(messages.length) {
|
|
|
|
return this.performSearchResult(messages, type); |
|
|
|
return this.performSearchResult(messages, type); |
|
|
|
} |
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.resolve(); |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
} |
|
|
@ -693,9 +721,9 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
|
|
|
|
|
|
|
|
this.usedFromHistory[type] = history.length; |
|
|
|
this.usedFromHistory[type] = history.length; |
|
|
|
|
|
|
|
|
|
|
|
if(ids.length) { |
|
|
|
//if(ids.length) {
|
|
|
|
return this.performSearchResult(this.filterMessagesByType(ids, type), type); |
|
|
|
return this.performSearchResult(this.filterMessagesByType(ids, type), type); |
|
|
|
} |
|
|
|
//}
|
|
|
|
}, (err) => { |
|
|
|
}, (err) => { |
|
|
|
this.log.error('load error:', err); |
|
|
|
this.log.error('load error:', err); |
|
|
|
}).then(() => { |
|
|
|
}).then(() => { |
|
|
@ -739,14 +767,20 @@ export class AppSidebarRight extends SidebarSlider { |
|
|
|
this.urlsToRevoke.length = 0; |
|
|
|
this.urlsToRevoke.length = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Object.keys(this.sharedMedia).forEach(key => { |
|
|
|
(Object.keys(this.sharedMedia) as ContentType[]).forEach(key => { |
|
|
|
this.sharedMedia[key].innerHTML = ''; |
|
|
|
this.sharedMedia[key].innerHTML = ''; |
|
|
|
|
|
|
|
|
|
|
|
if(!this.historiesStorage[this.peerID] || !this.historiesStorage[this.peerID][key]) { |
|
|
|
const inputFilter = contentToSharedMap[key]; |
|
|
|
let parent = this.sharedMedia[key].parentElement; |
|
|
|
if(!this.historiesStorage[this.peerID] || !this.historiesStorage[this.peerID][inputFilter]) { |
|
|
|
|
|
|
|
const parent = this.sharedMedia[key].parentElement; |
|
|
|
if(!parent.querySelector('.preloader')) { |
|
|
|
if(!parent.querySelector('.preloader')) { |
|
|
|
putPreloader(parent, true); |
|
|
|
putPreloader(parent, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const empty = parent.querySelector('.content-empty'); |
|
|
|
|
|
|
|
if(empty) { |
|
|
|
|
|
|
|
empty.remove(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|