diff --git a/src/App.vue b/src/App.vue index afe3fea..7c57827 100755 --- a/src/App.vue +++ b/src/App.vue @@ -124,8 +124,8 @@ const savePost = (saveArchive?: boolean): void => { ); if (saveArchive) { - if (!archive.value?.filter(post => post.filename === computedFilename.value) && !isDraft) { - archive.value?.push({ + if (!archive.value?.filter(post => post.filename === computedFilename.value).length && !isDraft.value) { + archive.value?.unshift({ postTitle: postTitle.value, timestamp: postTimestamp.value, filename: computedFilename.value diff --git a/src/file-manager.service.ts b/src/file-manager.service.ts index 5b03234..9c89284 100644 --- a/src/file-manager.service.ts +++ b/src/file-manager.service.ts @@ -24,8 +24,8 @@ export const parseFilename = (titleToFilename: string): string => { return titleToFilename; } -export const downloadFile = (dataPbj: any, fileName: string): void => { - const blob = new Blob([JSON.stringify(dataPbj, null, 2)], { type: 'text/plain;charset=utf-8;' }); +export const downloadFile = (dataObj: any, fileName: string): void => { + const blob = new Blob([JSON.stringify(dataObj, null, 2)], { type: 'text/plain;charset=utf-8;' }); const a = document.createElement('a'); a.setAttribute('download', `${fileName}.json`); a.setAttribute('href', window.URL.createObjectURL(blob)); @@ -45,7 +45,7 @@ export const loadFromFile = (file: any): Promise => { reader.onload = (event => { const contents: any = (event.target as FileReader).result; - // Yes, this is extremely hacky. + // Yes, this is extremely hacky... Empty object just to test below. 'Cuz I'm lazy. const objCompare: Post = { postTitle: "", timestamp: "",