You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d6431b4
Browse filesBrowse the repository at this point in the historyBrowse files
{label:labels.clearCache,click:()=>{pending=(async()=>{constdocument=awaitreadSystemPDF(path);constresponse=awaitfetch(windows.get(window).backend.origin+'/api/translation-cache/clear',{method:'POST',headers:{'Content-Type':'application/pdf','X-Preview-Token':token},body:document.bytes});if(!response.ok)throwError('Could not clear translation cache.');awaitrecents.clearTranslationStatus(id);selected='clearCache';})();}},
conststate=windows.get(window),path=value?.ticket?state.tickets.get(value.ticket):value?.path;if(!path){awaitdocumentSession.close(window.id);if(!state.unkeyedAnnotationSource?.preserveWithoutPath){state.unkeyedAnnotationSource=null;state.annotationSources.clear();}return{entries:recents.list(),recentId:null};}if(smoke&&!['A quieter way to read.pdf','Portrait and landscape.pdf'].includes(path.split(/[\\/]/).pop()))throwError('Test document rejected.');awaitvalidateSystemPDF(path);if(value?.ticket)state.tickets.delete(value.ticket);if(!smoke)app.addRecentDocument(path);constentries=awaitrecents.remember(path,value?.thumbnail),first=entries[0],source={path,reliable:true,preserveWithoutPath:false};state.annotationSources.set(first.id,source);state.unkeyedAnnotationSource=source;constrestored=state.restoreView;state.restoreView=null;awaitdocumentSession.open(window.id,{path,view:restored||first?.view});return{entries,recentId:first?.id??null,view:restored||first?.view};
404
+
conststate=windows.get(window),path=value?.ticket?state.tickets.get(value.ticket):value?.path;if(!path){awaitdocumentSession.close(window.id);if(!state.unkeyedAnnotationSource?.preserveWithoutPath){state.unkeyedAnnotationSource=null;state.annotationSources.clear();}return{entries:recents.list(),recentId:null};}if(smoke&&!['A quieter way to read.pdf','Portrait and landscape.pdf'].includes(path.split(/[\\/]/).pop()))throwError('Test document rejected.');awaitvalidateSystemPDF(path);if(value?.ticket)state.tickets.delete(value.ticket);if(!smoke)app.addRecentDocument(path);constentries=awaitrecents.remember(path,value?.thumbnail),first=entries.find(item=>recents.path(item.id)===path),source={path,reliable:true,preserveWithoutPath:false};state.annotationSources.set(first.id,source);state.unkeyedAnnotationSource=source;constrestored=state.restoreView;state.restoreView=null;awaitdocumentSession.open(window.id,{path,view:restored||first?.view});return{entries,recentId:first?.id??null,view:restored||first?.view};
return{list:()=>entries.map(listedEntry),path:id=>entries.find(e=>e.id===id)?.path,asyncremember(file,thumbnail){constcurrent=entries.find(e=>e.path===file),entry={id:current?.id||randomUUID(),path:file};if(thumbnail===undefined){if(current?.thumbnail!==undefined)entry.thumbnail=current.thumbnail;}elseentry.thumbnail=validateThumbnail(thumbnail);if(current?.view!==undefined)entry.view=cloneReadingView(current.view);if(current?.translationStatus!==undefined)entry.translationStatus=cloneTranslationStatus(current.translationStatus);entries=[entry,...entries.filter(e=>e.path!==file)].slice(0,10);awaitpersist();returnthis.list();},asyncsetThumbnail(id,thumbnail){constentry=entries.find(e=>e.id===id);if(!entry)throwError('Document no longer in history.');entry.thumbnail=validateThumbnail(thumbnail);awaitpersist();returnthis.list();},asyncsetView(id,view){constvalidated=validateReadingView(view),entry=entries.find(e=>e.id===id);if(!entry)returnthis.list();entry.view=validated;awaitpersist();returnthis.list();},asyncsetTranslationStatus(id,status){constvalidated=validateTranslationStatus(status),entry=entries.find(e=>e.id===id);if(!entry)returnthis.list();entry.translationStatus=validated;awaitpersist();returnthis.list();},asyncremove(id){constindex=entries.findIndex(e=>e.id===id);if(index<0)throwError('Document no longer in history.');entries.splice(index,1);awaitpersist();returnthis.list();},asyncclear(){entries=[];awaitpersist();return[];},flush:()=>writes};
53
+
return{list:()=>entries.map(listedEntry),path:id=>entries.find(e=>e.id===id)?.path,asyncremember(file,thumbnail){constcurrent=entries.find(e=>e.path===file),entry={id:current?.id||randomUUID(),path:file,pinned:current?.pinned===true};if(thumbnail===undefined){if(current?.thumbnail!==undefined)entry.thumbnail=current.thumbnail;}elseentry.thumbnail=validateThumbnail(thumbnail);if(current?.view!==undefined)entry.view=cloneReadingView(current.view);if(current?.translationStatus!==undefined)entry.translationStatus=cloneTranslationStatus(current.translationStatus);entries=normalizeEntries([entry,...entries.filter(e=>e.path!==file)]);awaitpersist();returnthis.list();},asyncsetThumbnail(id,thumbnail){constentry=entries.find(e=>e.id===id);if(!entry)throwError('Document no longer in history.');entry.thumbnail=validateThumbnail(thumbnail);awaitpersist();returnthis.list();},asyncsetView(id,view){constvalidated=validateReadingView(view),entry=entries.find(e=>e.id===id);if(!entry)returnthis.list();entry.view=validated;awaitpersist();returnthis.list();},asyncsetTranslationStatus(id,status){constvalidated=validateTranslationStatus(status),entry=entries.find(e=>e.id===id);if(!entry)returnthis.list();entry.translationStatus=validated;awaitpersist();returnthis.list();},asyncclearTranslationStatus(id){constentry=entries.find(e=>e.id===id);if(!entry)returnthis.list();deleteentry.translationStatus;awaitpersist();returnthis.list();},asyncsetPinned(id,pinned){if(typeofpinned!=='boolean')throwError('Invalid recent document pinned state.');constentry=entries.find(e=>e.id===id);if(!entry)returnthis.list();entry.pinned=pinned;entries=normalizeEntries(entries);awaitpersist();returnthis.list();},asyncremove(id){constindex=entries.findIndex(e=>e.id===id);if(index<0)throwError('Document no longer in history.');entries.splice(index,1);awaitpersist();returnthis.list();},asyncclear(){entries=entries.filter(entry=>entry.pinned);awaitpersist();returnthis.list();},flush:()=>writes};
0 commit comments