Skip to content

Commit 3fe9308

Browse files
committed
eliminate watcher
1 parent e152cc1 commit 3fe9308

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/App.vue

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import FileItem from './components/FileItem.vue';
55
import { useFileDataStore } from './stores/fileData';
66
import { storeToRefs } from 'pinia';
77
import type { FileObj } from './types/file';
8-
import { computed, ref, watch } from 'vue';
8+
import { computed, ref } from 'vue';
99
import { compressFile } from './functions/imageCompression';
10-
import { comressToZip } from './functions/zipCompression';
10+
import { compressToZip } from './functions/zipCompression';
1111
import { paginate } from './functions/paginate';
1212
import { useI18n } from './hooks/useI18n';
1313
@@ -46,19 +46,15 @@ async function compressFiles() {
4646
}
4747
4848
isCompressing.value = false;
49+
50+
isZipCompressing.value = true;
51+
zipData.value = await compressToZip();
52+
isZipCompressing.value = false;
4953
}
5054
5155
function removeItem(file: FileObj) {
5256
files.value = files.value.filter((item) => item !== file);
5357
}
54-
55-
watch(anyUncompressed, async (newVal) => {
56-
if (files.value.length && !newVal) {
57-
isZipCompressing.value = true;
58-
zipData.value = await comressToZip();
59-
isZipCompressing.value = false;
60-
}
61-
});
6258
</script>
6359

6460
<template>
@@ -93,7 +89,7 @@ watch(anyUncompressed, async (newVal) => {
9389
</button>
9490
<a
9591
:aria-busy="isZipCompressing"
96-
:aria-disabled="!zipData"
92+
:disabled="!zipData || undefined"
9793
:href="zipData || undefined"
9894
role="button"
9995
download

src/functions/zipCompression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import JSZip from 'jszip';
22
import { storeToRefs } from 'pinia';
33
import { useFileDataStore } from '@/stores/fileData';
44

5-
export async function comressToZip(): Promise<string> {
5+
export async function compressToZip(): Promise<string> {
66
const zip = new JSZip();
77

88
const fileDataStore = useFileDataStore();

0 commit comments

Comments
 (0)