mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +00:00
cache-files
This commit is contained in:
@@ -20,6 +20,7 @@ export default class SdocEditor extends React.Component {
|
|||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.onSetFavicon();
|
this.onSetFavicon();
|
||||||
this.getDirentList();
|
this.getDirentList();
|
||||||
|
this.cacheHistoryfiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
toggleStar = (isStarred) => {
|
toggleStar = (isStarred) => {
|
||||||
@@ -43,6 +44,25 @@ export default class SdocEditor extends React.Component {
|
|||||||
this.onSetFavicon('_notification');
|
this.onSetFavicon('_notification');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
cacheHistoryfiles = () => {
|
||||||
|
const { docName, docUuid } = window.seafile;
|
||||||
|
const rencentFiles = localStorage.getItem('sdoc-recent-files') ? JSON.parse(localStorage.getItem('sdoc-recent-files')) : [];
|
||||||
|
let arr = [];
|
||||||
|
const newFile = { file_uuid: docUuid, file_name: docName };
|
||||||
|
if (rencentFiles.length > 0) {
|
||||||
|
const isExist = rencentFiles.find((item) => item.file_uuid === docUuid);
|
||||||
|
if (isExist) return;
|
||||||
|
if (!isExist) {
|
||||||
|
let newRencentFiles = rencentFiles.slice(0);
|
||||||
|
if (rencentFiles.length === 10) {newRencentFiles.shift();}
|
||||||
|
arr = [newFile, ...newRencentFiles];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
arr.push(newFile);
|
||||||
|
}
|
||||||
|
localStorage.setItem('sdoc-recent-files', JSON.stringify(arr));
|
||||||
|
};
|
||||||
|
|
||||||
getDirPath = () => {
|
getDirPath = () => {
|
||||||
const { docPath } = window.seafile;
|
const { docPath } = window.seafile;
|
||||||
const index = docPath.lastIndexOf('/');
|
const index = docPath.lastIndexOf('/');
|
||||||
|
Reference in New Issue
Block a user