|
|
@ -28,7 +28,7 @@ import I18n, { LangPackKey, i18n } from "../lib/langPack"; |
|
|
|
import findUpClassName from "../helpers/dom/findUpClassName"; |
|
|
|
import findUpClassName from "../helpers/dom/findUpClassName"; |
|
|
|
import { getMiddleware } from "../helpers/middleware"; |
|
|
|
import { getMiddleware } from "../helpers/middleware"; |
|
|
|
import appProfileManager from "../lib/appManagers/appProfileManager"; |
|
|
|
import appProfileManager from "../lib/appManagers/appProfileManager"; |
|
|
|
import { ChannelParticipant, ChatFull, ChatParticipant, ChatParticipants } from "../layer"; |
|
|
|
import { ChannelParticipant, ChatFull, ChatParticipant, ChatParticipants, Message, MessageMedia, Photo, WebPage } from "../layer"; |
|
|
|
import SortedUserList from "./sortedUserList"; |
|
|
|
import SortedUserList from "./sortedUserList"; |
|
|
|
import findUpTag from "../helpers/dom/findUpTag"; |
|
|
|
import findUpTag from "../helpers/dom/findUpTag"; |
|
|
|
import appSidebarRight from "./sidebarRight"; |
|
|
|
import appSidebarRight from "./sidebarRight"; |
|
|
@ -222,6 +222,15 @@ class SearchContextMenu { |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export type ProcessSearchSuperResult = { |
|
|
|
|
|
|
|
message: Message.message, |
|
|
|
|
|
|
|
middleware: () => boolean, |
|
|
|
|
|
|
|
promises: Promise<any>[], |
|
|
|
|
|
|
|
elemsToAppend: {element: HTMLElement, message: any}[], |
|
|
|
|
|
|
|
inputFilter: MyInputMessagesFilter, |
|
|
|
|
|
|
|
searchGroup?: SearchGroup |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export default class AppSearchSuper { |
|
|
|
export default class AppSearchSuper { |
|
|
|
public tabs: {[t in SearchSuperType]: HTMLDivElement} = {} as any; |
|
|
|
public tabs: {[t in SearchSuperType]: HTMLDivElement} = {} as any; |
|
|
|
|
|
|
|
|
|
|
@ -656,250 +665,268 @@ export default class AppSearchSuper { |
|
|
|
return filtered; |
|
|
|
return filtered; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async performSearchResult(messages: any[], mediaTab: SearchSuperMediaTab, append = true) { |
|
|
|
private processEmptyFilter({message, searchGroup}: ProcessSearchSuperResult) { |
|
|
|
const elemsToAppend: {element: HTMLElement, message: any}[] = []; |
|
|
|
const {dialog, dom} = appDialogsManager.addDialogNew({ |
|
|
|
const sharedMediaDiv: HTMLElement = mediaTab.contentTab; |
|
|
|
dialog: message.peerId, |
|
|
|
const promises: Promise<any>[] = []; |
|
|
|
container: searchGroup.list, |
|
|
|
const middleware = this.middleware.get(); |
|
|
|
drawStatus: false, |
|
|
|
let inputFilter = mediaTab.inputFilter; |
|
|
|
avatarSize: 54 |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
await getHeavyAnimationPromise(); |
|
|
|
appDialogsManager.setLastMessage(dialog, message, dom, this.searchContext.query); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
let searchGroup: SearchGroup; |
|
|
|
private processPhotoVideoFilter({message, promises, middleware, elemsToAppend}: ProcessSearchSuperResult) { |
|
|
|
if(inputFilter === 'inputMessagesFilterPhotoVideo' && !!this.searchContext.query.trim()) { |
|
|
|
const media = appMessagesManager.getMediaFromMessage(message); |
|
|
|
inputFilter = 'inputMessagesFilterEmpty'; |
|
|
|
|
|
|
|
searchGroup = this.searchGroupMedia; |
|
|
|
const div = document.createElement('div'); |
|
|
|
sharedMediaDiv.append(searchGroup.container); |
|
|
|
div.classList.add('grid-item'); |
|
|
|
} else if(inputFilter === 'inputMessagesFilterEmpty') { |
|
|
|
//this.log(message, photo);
|
|
|
|
searchGroup = this.searchGroups.messages; |
|
|
|
|
|
|
|
|
|
|
|
let wrapped: ReturnType<typeof wrapPhoto>; |
|
|
|
|
|
|
|
const size = appPhotosManager.choosePhotoSize(media, 200, 200); |
|
|
|
|
|
|
|
if(media._ !== 'photo') { |
|
|
|
|
|
|
|
wrapped = wrapVideo({ |
|
|
|
|
|
|
|
doc: media, |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
container: div, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
onlyPreview: true, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
noPlayButton: true, |
|
|
|
|
|
|
|
size |
|
|
|
|
|
|
|
}).thumb; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wrapped = wrapPhoto({ |
|
|
|
|
|
|
|
photo: media, |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
container: div, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
noBlur: true, |
|
|
|
|
|
|
|
size |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// https://core.telegram.org/type/MessagesFilter
|
|
|
|
[wrapped.images.thumb, wrapped.images.full].filter(Boolean).forEach(image => { |
|
|
|
switch(inputFilter) { |
|
|
|
image.classList.add('grid-item-media'); |
|
|
|
case 'inputMessagesFilterEmpty': { |
|
|
|
}); |
|
|
|
for(const message of messages) { |
|
|
|
|
|
|
|
const {dialog, dom} = appDialogsManager.addDialogNew({ |
|
|
|
|
|
|
|
dialog: message.peerId, |
|
|
|
|
|
|
|
container: searchGroup.list, |
|
|
|
|
|
|
|
drawStatus: false, |
|
|
|
|
|
|
|
avatarSize: 54 |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
appDialogsManager.setLastMessage(dialog, message, dom, this.searchContext.query); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(searchGroup.list.childElementCount) { |
|
|
|
promises.push(wrapped.loadPromises.thumb); |
|
|
|
searchGroup.setActive(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterPhotoVideo': { |
|
|
|
elemsToAppend.push({element: div, message}); |
|
|
|
for(const message of messages) { |
|
|
|
} |
|
|
|
const media = message.media.photo || message.media.document || (message.media.webpage && message.media.webpage.document); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const div = document.createElement('div'); |
|
|
|
|
|
|
|
div.classList.add('grid-item'); |
|
|
|
|
|
|
|
//this.log(message, photo);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let wrapped: ReturnType<typeof wrapPhoto>; |
|
|
|
|
|
|
|
const size = appPhotosManager.choosePhotoSize(media, 200, 200); |
|
|
|
|
|
|
|
if(media._ !== 'photo') { |
|
|
|
|
|
|
|
wrapped = wrapVideo({ |
|
|
|
|
|
|
|
doc: media, |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
container: div, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
onlyPreview: true, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
noPlayButton: true, |
|
|
|
|
|
|
|
size |
|
|
|
|
|
|
|
}).thumb; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
wrapped = wrapPhoto({ |
|
|
|
|
|
|
|
photo: media, |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
container: div, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
noBlur: true, |
|
|
|
|
|
|
|
size |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[wrapped.images.thumb, wrapped.images.full].filter(Boolean).forEach(image => { |
|
|
|
private processDocumentFilter({message, elemsToAppend, inputFilter}: ProcessSearchSuperResult) { |
|
|
|
image.classList.add('grid-item-media'); |
|
|
|
const document = appMessagesManager.getMediaFromMessage(message); |
|
|
|
}); |
|
|
|
const showSender = this.showSender || (['voice', 'round'] as MyDocument['type'][]).includes(document.type); |
|
|
|
|
|
|
|
const div = wrapDocument({ |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
withTime: !showSender, |
|
|
|
|
|
|
|
fontWeight: 400, |
|
|
|
|
|
|
|
voiceAsMusic: true, |
|
|
|
|
|
|
|
showSender, |
|
|
|
|
|
|
|
searchContext: this.copySearchContext(inputFilter), |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
noAutoDownload: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((['audio', 'voice', 'round'] as MyDocument['type'][]).includes(document.type)) { |
|
|
|
|
|
|
|
div.classList.add('audio-48'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elemsToAppend.push({element: div, message}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private processUrlFilter({message, promises, middleware, elemsToAppend}: ProcessSearchSuperResult) { |
|
|
|
|
|
|
|
let webpage = (message.media as MessageMedia.messageMediaWebPage)?.webpage as WebPage.webPage; |
|
|
|
|
|
|
|
|
|
|
|
promises.push(wrapped.loadPromises.thumb); |
|
|
|
if(!webpage) { |
|
|
|
|
|
|
|
const entity = message.totalEntities ? message.totalEntities.find((e: any) => e._ === 'messageEntityUrl' || e._ === 'messageEntityTextUrl') : null; |
|
|
|
|
|
|
|
let url: string, display_url: string, sliced: string; |
|
|
|
|
|
|
|
|
|
|
|
elemsToAppend.push({element: div, message}); |
|
|
|
if(!entity) { |
|
|
|
|
|
|
|
//this.log.error('NO ENTITY:', message);
|
|
|
|
|
|
|
|
const match = RichTextProcessor.matchUrl(message.message); |
|
|
|
|
|
|
|
if(!match) { |
|
|
|
|
|
|
|
//this.log.error('NO ENTITY AND NO MATCH:', message);
|
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
url = match[0]; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
sliced = message.message.slice(entity.offset, entity.offset + entity.length); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterVoice': |
|
|
|
if(entity?._ === 'messageEntityTextUrl') { |
|
|
|
case 'inputMessagesFilterRoundVoice': |
|
|
|
url = entity.url; |
|
|
|
case 'inputMessagesFilterMusic': |
|
|
|
//display_url = sliced;
|
|
|
|
case 'inputMessagesFilterDocument': { |
|
|
|
} else { |
|
|
|
for(const message of messages) { |
|
|
|
url = url || sliced; |
|
|
|
const showSender = this.showSender || (['voice', 'round'] as MyDocument['type'][]).includes(message.media.document.type); |
|
|
|
} |
|
|
|
const div = wrapDocument({ |
|
|
|
|
|
|
|
message, |
|
|
|
|
|
|
|
withTime: !showSender, |
|
|
|
|
|
|
|
fontWeight: 400, |
|
|
|
|
|
|
|
voiceAsMusic: true, |
|
|
|
|
|
|
|
showSender, |
|
|
|
|
|
|
|
searchContext: this.copySearchContext(inputFilter), |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
noAutoDownload: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if((['audio', 'voice', 'round'] as MyDocument['type'][]).includes(message.media.document.type)) { |
|
|
|
display_url = url; |
|
|
|
div.classList.add('audio-48'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elemsToAppend.push({element: div, message}); |
|
|
|
const same = message.message === url; |
|
|
|
} |
|
|
|
if(!url.match(/^(ftp|http|https):\/\//)) { |
|
|
|
break; |
|
|
|
display_url = 'https://' + url; |
|
|
|
|
|
|
|
url = url.includes('@') ? url : 'https://' + url; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterUrl': { |
|
|
|
display_url = new URL(display_url).hostname; |
|
|
|
for(let message of messages) { |
|
|
|
|
|
|
|
let webpage: any; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(message.media?.webpage && message.media.webpage._ !== 'webPageEmpty') { |
|
|
|
webpage = { |
|
|
|
webpage = message.media.webpage; |
|
|
|
_: 'webPage', |
|
|
|
} else { |
|
|
|
url, |
|
|
|
const entity = message.totalEntities ? message.totalEntities.find((e: any) => e._ === 'messageEntityUrl' || e._ === 'messageEntityTextUrl') : null; |
|
|
|
display_url, |
|
|
|
let url: string, display_url: string, sliced: string; |
|
|
|
id: '', |
|
|
|
|
|
|
|
hash: 0 |
|
|
|
if(!entity) { |
|
|
|
}; |
|
|
|
//this.log.error('NO ENTITY:', message);
|
|
|
|
|
|
|
|
const match = RichTextProcessor.matchUrl(message.message); |
|
|
|
|
|
|
|
if(!match) { |
|
|
|
|
|
|
|
//this.log.error('NO ENTITY AND NO MATCH:', message);
|
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
url = match[0]; |
|
|
|
if(!same) { |
|
|
|
} else { |
|
|
|
webpage.description = message.message; |
|
|
|
sliced = message.message.slice(entity.offset, entity.offset + entity.length); |
|
|
|
webpage.rDescription = RichTextProcessor.wrapRichText(limitSymbols(message.message, 150, 180)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(entity?._ === 'messageEntityTextUrl') { |
|
|
|
let previewDiv = document.createElement('div'); |
|
|
|
url = entity.url; |
|
|
|
previewDiv.classList.add('preview', 'row-media'); |
|
|
|
//display_url = sliced;
|
|
|
|
|
|
|
|
} else { |
|
|
|
//this.log('wrapping webpage', webpage);
|
|
|
|
url = url || sliced; |
|
|
|
|
|
|
|
} |
|
|
|
if(webpage.photo) { |
|
|
|
|
|
|
|
const res = wrapPhoto({ |
|
|
|
|
|
|
|
container: previewDiv, |
|
|
|
|
|
|
|
message: null, |
|
|
|
|
|
|
|
photo: webpage.photo as Photo.photo, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
size: appPhotosManager.choosePhotoSize(webpage.photo as Photo.photo, 60, 60, false), |
|
|
|
|
|
|
|
loadPromises: promises, |
|
|
|
|
|
|
|
noBlur: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
previewDiv.classList.add('empty'); |
|
|
|
|
|
|
|
previewDiv.innerHTML = RichTextProcessor.getAbbreviation(webpage.title || webpage.display_url || webpage.description || webpage.url, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
display_url = url; |
|
|
|
let title = webpage.rTitle || ''; |
|
|
|
|
|
|
|
let subtitle = webpage.rDescription || ''; |
|
|
|
|
|
|
|
|
|
|
|
const same = message.message === url; |
|
|
|
const subtitleFragment = htmlToDocumentFragment(subtitle); |
|
|
|
if(!url.match(/^(ftp|http|https):\/\//)) { |
|
|
|
const aFragment = htmlToDocumentFragment(RichTextProcessor.wrapRichText(webpage.url || '')); |
|
|
|
display_url = 'https://' + url; |
|
|
|
const a = aFragment.firstElementChild; |
|
|
|
url = url.includes('@') ? url : 'https://' + url; |
|
|
|
if(a instanceof HTMLAnchorElement) { |
|
|
|
} |
|
|
|
try { // can have 'URIError: URI malformed'
|
|
|
|
|
|
|
|
a.innerText = decodeURIComponent(a.href); |
|
|
|
|
|
|
|
} catch(err) { |
|
|
|
|
|
|
|
|
|
|
|
display_url = new URL(display_url).hostname; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
webpage = { |
|
|
|
if(subtitleFragment.firstChild) { |
|
|
|
url, |
|
|
|
subtitleFragment.append('\n'); |
|
|
|
display_url |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!same) { |
|
|
|
subtitleFragment.append(a); |
|
|
|
webpage.description = message.message; |
|
|
|
|
|
|
|
webpage.rDescription = RichTextProcessor.wrapRichText(limitSymbols(message.message, 150, 180)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let div = document.createElement('div'); |
|
|
|
if(this.showSender) { |
|
|
|
|
|
|
|
subtitleFragment.append('\n', appMessagesManager.wrapSenderToPeer(message)); |
|
|
|
let previewDiv = document.createElement('div'); |
|
|
|
} |
|
|
|
previewDiv.classList.add('preview', 'row-media'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//this.log('wrapping webpage', webpage);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(webpage.photo) { |
|
|
|
|
|
|
|
const res = wrapPhoto({ |
|
|
|
|
|
|
|
container: previewDiv, |
|
|
|
|
|
|
|
message: null, |
|
|
|
|
|
|
|
photo: webpage.photo, |
|
|
|
|
|
|
|
boxWidth: 0, |
|
|
|
|
|
|
|
boxHeight: 0, |
|
|
|
|
|
|
|
withoutPreloader: true, |
|
|
|
|
|
|
|
lazyLoadQueue: this.lazyLoadQueue, |
|
|
|
|
|
|
|
middleware, |
|
|
|
|
|
|
|
size: appPhotosManager.choosePhotoSize(webpage.photo, 60, 60, false), |
|
|
|
|
|
|
|
loadPromises: promises, |
|
|
|
|
|
|
|
noBlur: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
previewDiv.classList.add('empty'); |
|
|
|
|
|
|
|
previewDiv.innerHTML = RichTextProcessor.getAbbreviation(webpage.title || webpage.display_url || webpage.description || webpage.url, true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let title = webpage.rTitle || ''; |
|
|
|
if(!title) { |
|
|
|
let subtitle = webpage.rDescription || ''; |
|
|
|
//title = new URL(webpage.url).hostname;
|
|
|
|
|
|
|
|
title = RichTextProcessor.wrapPlainText(webpage.display_url.split('/', 1)[0]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const subtitleFragment = htmlToDocumentFragment(subtitle); |
|
|
|
const row = new Row({ |
|
|
|
const aFragment = htmlToDocumentFragment(RichTextProcessor.wrapRichText(webpage.url || '')); |
|
|
|
title, |
|
|
|
const a = aFragment.firstElementChild; |
|
|
|
titleRight: appMessagesManager.wrapSentTime(message), |
|
|
|
if(a instanceof HTMLAnchorElement) { |
|
|
|
subtitle: subtitleFragment, |
|
|
|
a.innerText = decodeURIComponent(a.href); |
|
|
|
havePadding: true, |
|
|
|
} |
|
|
|
clickable: true, |
|
|
|
|
|
|
|
noRipple: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
if(subtitleFragment.firstChild) { |
|
|
|
/* const mediaDiv = document.createElement('div'); |
|
|
|
subtitleFragment.append('\n'); |
|
|
|
mediaDiv.classList.add('row-media'); */ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subtitleFragment.append(a); |
|
|
|
row.container.append(previewDiv); |
|
|
|
|
|
|
|
|
|
|
|
if(this.showSender) { |
|
|
|
/* ripple(div); |
|
|
|
subtitleFragment.append('\n', appMessagesManager.wrapSenderToPeer(message)); |
|
|
|
div.append(previewDiv); |
|
|
|
} |
|
|
|
div.insertAdjacentHTML('beforeend', ` |
|
|
|
|
|
|
|
<div class="title">${title}${titleAdditionHTML}</div> |
|
|
|
|
|
|
|
<div class="subtitle">${subtitle}</div> |
|
|
|
|
|
|
|
<div class="url">${url}</div> |
|
|
|
|
|
|
|
${sender} |
|
|
|
|
|
|
|
`); */
|
|
|
|
|
|
|
|
|
|
|
|
if(!title) { |
|
|
|
if(row.container.innerText.trim().length) { |
|
|
|
//title = new URL(webpage.url).hostname;
|
|
|
|
elemsToAppend.push({element: row.container, message}); |
|
|
|
title = RichTextProcessor.wrapPlainText(webpage.display_url.split('/', 1)[0]); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const row = new Row({ |
|
|
|
public async performSearchResult(messages: any[], mediaTab: SearchSuperMediaTab, append = true) { |
|
|
|
title, |
|
|
|
const elemsToAppend: {element: HTMLElement, message: any}[] = []; |
|
|
|
titleRight: appMessagesManager.wrapSentTime(message), |
|
|
|
const sharedMediaDiv: HTMLElement = mediaTab.contentTab; |
|
|
|
subtitle: subtitleFragment, |
|
|
|
const promises: Promise<any>[] = []; |
|
|
|
havePadding: true, |
|
|
|
const middleware = this.middleware.get(); |
|
|
|
clickable: true, |
|
|
|
let inputFilter = mediaTab.inputFilter; |
|
|
|
noRipple: true |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* const mediaDiv = document.createElement('div'); |
|
|
|
await getHeavyAnimationPromise(); |
|
|
|
mediaDiv.classList.add('row-media'); */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row.container.append(previewDiv); |
|
|
|
let searchGroup: SearchGroup; |
|
|
|
|
|
|
|
if(inputFilter === 'inputMessagesFilterPhotoVideo' && !!this.searchContext.query.trim()) { |
|
|
|
|
|
|
|
inputFilter = 'inputMessagesFilterEmpty'; |
|
|
|
|
|
|
|
searchGroup = this.searchGroupMedia; |
|
|
|
|
|
|
|
sharedMediaDiv.append(searchGroup.container); |
|
|
|
|
|
|
|
} else if(inputFilter === 'inputMessagesFilterEmpty') { |
|
|
|
|
|
|
|
searchGroup = this.searchGroups.messages; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* ripple(div); |
|
|
|
const options: ProcessSearchSuperResult = { |
|
|
|
div.append(previewDiv); |
|
|
|
elemsToAppend, |
|
|
|
div.insertAdjacentHTML('beforeend', ` |
|
|
|
inputFilter, |
|
|
|
<div class="title">${title}${titleAdditionHTML}</div> |
|
|
|
message: undefined, |
|
|
|
<div class="subtitle">${subtitle}</div> |
|
|
|
middleware, |
|
|
|
<div class="url">${url}</div> |
|
|
|
promises, |
|
|
|
${sender} |
|
|
|
searchGroup |
|
|
|
`); */
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if(row.container.innerText.trim().length) { |
|
|
|
let processCallback: (options: ProcessSearchSuperResult) => any; |
|
|
|
elemsToAppend.push({element: row.container, message}); |
|
|
|
|
|
|
|
} |
|
|
|
// https://core.telegram.org/type/MessagesFilter
|
|
|
|
} |
|
|
|
switch(inputFilter) { |
|
|
|
|
|
|
|
case 'inputMessagesFilterEmpty': { |
|
|
|
|
|
|
|
processCallback = this.processEmptyFilter; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterPhotoVideo': { |
|
|
|
|
|
|
|
processCallback = this.processPhotoVideoFilter; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterVoice': |
|
|
|
|
|
|
|
case 'inputMessagesFilterRoundVoice': |
|
|
|
|
|
|
|
case 'inputMessagesFilterMusic': |
|
|
|
|
|
|
|
case 'inputMessagesFilterDocument': { |
|
|
|
|
|
|
|
processCallback = this.processDocumentFilter; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case 'inputMessagesFilterUrl': { |
|
|
|
|
|
|
|
processCallback = this.processUrlFilter; |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -908,6 +935,23 @@ export default class AppSearchSuper { |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(processCallback) { |
|
|
|
|
|
|
|
processCallback = processCallback.bind(this); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(const message of messages) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
options.message = message; |
|
|
|
|
|
|
|
processCallback(options); |
|
|
|
|
|
|
|
} catch(err) { |
|
|
|
|
|
|
|
this.log.error('error rendering filter', inputFilter, options, message, err); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(searchGroup && searchGroup.list.childElementCount) { |
|
|
|
|
|
|
|
searchGroup.setActive(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(this.loadMutex) { |
|
|
|
if(this.loadMutex) { |
|
|
|
promises.push(this.loadMutex); |
|
|
|
promises.push(this.loadMutex); |
|
|
|
} |
|
|
|
} |
|
|
@ -1163,7 +1207,7 @@ export default class AppSearchSuper { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
promise.then(() => { |
|
|
|
promise.then(() => { |
|
|
|
appImManager.setInnerPeer(peerId); |
|
|
|
appImManager.setInnerPeer({peerId}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
mediaTab.contentTab.append(this.membersList.list); |
|
|
|
mediaTab.contentTab.append(this.membersList.list); |
|
|
|