This commit is contained in:
pedrocx486 2023-03-05 02:09:25 -03:00
parent 8e49139cb6
commit 33f163cd87
2 changed files with 5 additions and 5 deletions

View file

@ -124,8 +124,8 @@ const savePost = (saveArchive?: boolean): void => {
); );
if (saveArchive) { if (saveArchive) {
if (!archive.value?.filter(post => post.filename === computedFilename.value) && !isDraft) { if (!archive.value?.filter(post => post.filename === computedFilename.value).length && !isDraft.value) {
archive.value?.push({ archive.value?.unshift({
postTitle: postTitle.value, postTitle: postTitle.value,
timestamp: postTimestamp.value, timestamp: postTimestamp.value,
filename: computedFilename.value filename: computedFilename.value

View file

@ -24,8 +24,8 @@ export const parseFilename = (titleToFilename: string): string => {
return titleToFilename; return titleToFilename;
} }
export const downloadFile = (dataPbj: any, fileName: string): void => { export const downloadFile = (dataObj: any, fileName: string): void => {
const blob = new Blob([JSON.stringify(dataPbj, null, 2)], { type: 'text/plain;charset=utf-8;' }); const blob = new Blob([JSON.stringify(dataObj, null, 2)], { type: 'text/plain;charset=utf-8;' });
const a = document.createElement('a'); const a = document.createElement('a');
a.setAttribute('download', `${fileName}.json`); a.setAttribute('download', `${fileName}.json`);
a.setAttribute('href', window.URL.createObjectURL(blob)); a.setAttribute('href', window.URL.createObjectURL(blob));
@ -45,7 +45,7 @@ export const loadFromFile = (file: any): Promise<Post> => {
reader.onload = (event => { reader.onload = (event => {
const contents: any = (event.target as FileReader).result; 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 = { const objCompare: Post = {
postTitle: "", postTitle: "",
timestamp: "", timestamp: "",