Skip to content

Commit a0eb959

Browse files
committed
feat: add refresh accelerate uploading cache on confirm popup
1 parent 60ef446 commit a0eb959

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

Diff for: src/renderer/modules/qiniu-client/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ export async function isAccelerateUploadingAvailable(
9797
user: AkItem,
9898
bucket: string,
9999
opt: GetAdapterOptionParam,
100-
withoutCache = false,
100+
refreshCache = false,
101101
): Promise<boolean> {
102102
if (user.specialType === AkSpecialType.STS) {
103103
return false;
104104
}
105105

106106
return await getDefaultClient(opt).enter("isAccelerateUploadingAvailable", async client => {
107-
if (withoutCache) {
107+
if (refreshCache) {
108108
client.client.clearCache();
109109
}
110110
const accUrls = await client.client.getServiceUrls({

Diff for: src/renderer/pages/browse/files/index.tsx

+13-7
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,10 @@ const Files: React.FC<FilesProps> = (props) => {
185185
const [fetchingAccelerateUploading, setFetchingAccelerateUploading] = useState<boolean>(false);
186186
const fetchAccelerateUploading = ({
187187
needFeedback,
188-
withoutCache,
188+
refreshCache,
189189
}: {
190190
needFeedback?: boolean,
191-
withoutCache?: boolean,
191+
refreshCache?: boolean,
192192
} = {}) => {
193193
if (!currentUser || !props.bucket || fetchingAccelerateUploading) {
194194
return;
@@ -203,7 +203,7 @@ const Files: React.FC<FilesProps> = (props) => {
203203
currentUser,
204204
props.bucket?.name,
205205
opt,
206-
withoutCache,
206+
refreshCache,
207207
);
208208
if (needFeedback) {
209209
p = toast.promise(p, {
@@ -216,14 +216,11 @@ const Files: React.FC<FilesProps> = (props) => {
216216
.catch(err => LocalLogger.error(err))
217217
.finally(() => setFetchingAccelerateUploading(false));
218218
};
219-
useEffect(() => {
220-
fetchAccelerateUploading();
221-
}, [currentUser?.accessKey, props.bucket]);
222219
const refreshCanAccelerateUploading = () => {
223220
ipcUploadManager.clearRegionsCache();
224221
fetchAccelerateUploading({
225222
needFeedback: true,
226-
withoutCache: true,
223+
refreshCache: true,
227224
});
228225
};
229226

@@ -285,6 +282,15 @@ const Files: React.FC<FilesProps> = (props) => {
285282
] = useDisplayModal<{filePaths: string[]}>({
286283
filePaths: []
287284
});
285+
useEffect(() => {
286+
if (!isShowUploadFilesConfirm) {
287+
return;
288+
}
289+
ipcUploadManager.clearRegionsCache();
290+
fetchAccelerateUploading({
291+
refreshCache: true,
292+
});
293+
}, [isShowUploadFilesConfirm]);
288294

289295
// handle upload and download
290296
const handleUploadFiles = async (filePaths: string[]) => {

0 commit comments

Comments
 (0)