some fixes

This commit is contained in:
Eduard Kuzmenko 2022-08-20 13:06:08 +02:00
parent 0191f3e554
commit aead5ec7aa
5 changed files with 20 additions and 4 deletions

View File

@ -181,6 +181,11 @@ export default async function wrapDocument({message, withTime, fontWeight, voice
middleEllipsisEl.textContent = fileName;
// setInnerHTML(middleEllipsisEl, fileName);
// * new media popup
if(!message.mid) {
docDiv.classList.add('downloaded');
}
nameDiv.append(middleEllipsisEl);
if(showSender) {

View File

@ -68,5 +68,5 @@ export function getFileURL(type: FileURLType, options: DownloadOptions) {
const encoded = encodeURIComponent(JSON.stringify(options));
// console.log('getFileURL encode:', performance.now() - perf, encoded);
return '/' + type + '/' + encoded;
return /* '/' + */type + '/' + encoded;
}

View File

@ -238,7 +238,7 @@ export class AppDownloadManager {
// if(downloadOptions.size && downloadOptions.size > MAX_FILE_SAVE_SIZE) {
const id = '' + (Math.random() * 0x7FFFFFFF | 0);
// const id = 'test';
const url = `/download/${id}`;
const url = `download/${id}`;
options.downloadId = id;
const promise = this.downloadMedia(options, 'disc');

View File

@ -285,7 +285,17 @@ class ApiManagerProxy extends MTProtoMessagePort {
private async registerCryptoWorker() {
const get = (url: string) => {
return fetch(url).then((response) => response.text()).then((text) => {
text = 'var a = importScripts; importScripts = (url) => {console.log(`wut`, url); return a(url.slice(5));};' + text;
const pathnameSplitted = location.pathname.split('/');
pathnameSplitted[pathnameSplitted.length - 1] = '';
const pre = location.origin + pathnameSplitted.join('/');
text = `
var originalImportScripts = importScripts;
importScripts = (url) => {
console.log('importScripts', url);
var newUrl = '${pre}' + url.split('/').pop();
return originalImportScripts(newUrl);
};
${text}`;
const blob = new Blob([text], {type: 'application/javascript'});
return blob;
});

View File

@ -115,7 +115,8 @@ const onFetch = (event: FetchEvent): void => {
// #endif
try {
const [, url, scope, params] = /http[:s]+\/\/.*?(\/(.*?)(?:$|\/(.*)$))/.exec(event.request.url) || [];
// const [, url, scope, params] = /http[:s]+\/\/.*?(\/(.*?)(?:$|\/(.*)$))/.exec(event.request.url) || [];
const [scope, params] = event.request.url.split('/').slice(-2);
// log.debug('[fetch]:', event);