Browse Source

some fixes

master
Eduard Kuzmenko 2 years ago
parent
commit
1b87103e02
  1. 5
      src/components/wrappers/document.ts
  2. 2
      src/helpers/fileName.ts
  3. 2
      src/lib/appManagers/appDownloadManager.ts
  4. 12
      src/lib/mtproto/mtprotoworker.ts
  5. 3
      src/lib/serviceWorker/index.service.ts

5
src/components/wrappers/document.ts

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

2
src/helpers/fileName.ts

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

2
src/lib/appManagers/appDownloadManager.ts

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

12
src/lib/mtproto/mtprotoworker.ts

@ -285,7 +285,17 @@ class ApiManagerProxy extends MTProtoMessagePort {
private async registerCryptoWorker() { private async registerCryptoWorker() {
const get = (url: string) => { const get = (url: string) => {
return fetch(url).then((response) => response.text()).then((text) => { 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'}); const blob = new Blob([text], {type: 'application/javascript'});
return blob; return blob;
}); });

3
src/lib/serviceWorker/index.service.ts

@ -115,7 +115,8 @@ const onFetch = (event: FetchEvent): void => {
// #endif // #endif
try { 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); // log.debug('[fetch]:', event);

Loading…
Cancel
Save