Selaa lähdekoodia

fix: Prevent constant reassignment in Google Drive file picker

Taylor Wilsdon (aider) 4 kuukautta sitten
vanhempi
commit
886fb3f426
1 muutettua tiedostoa jossa 4 lisäystä ja 4 poistoa
  1. 4 4
      src/lib/utils/google-drive-picker.ts

+ 4 - 4
src/lib/utils/google-drive-picker.ts

@@ -132,9 +132,9 @@ export const createPicker = () => {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
                                 } else if (mimeType.includes('spreadsheet')) {
                                 } else if (mimeType.includes('spreadsheet')) {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
-                                    // Create new filename with .xlsx extension for spreadsheets
-                                    const modifiedFileName = fileName.endsWith('.xlsx') ? fileName : `${fileName}.xlsx`;
-                                    fileName = modifiedFileName;
+                                    // Create new filename with .xlsx extension for spreadsheets if needed
+                                    const finalFileName = fileName.endsWith('.xlsx') ? fileName : `${fileName}.xlsx`;
+                                    // Use finalFileName in the result object later
                                 } else if (mimeType.includes('presentation')) {
                                 } else if (mimeType.includes('presentation')) {
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
                                     exportFormat = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
                                 } else {
                                 } else {
@@ -166,7 +166,7 @@ export const createPicker = () => {
                             const blob = await response.blob();
                             const blob = await response.blob();
                             const result = {
                             const result = {
                                 id: fileId,
                                 id: fileId,
-                                name: fileName,
+                                name: finalFileName || fileName, // Use modified filename if available
                                 url: downloadUrl,
                                 url: downloadUrl,
                                 blob: blob,
                                 blob: blob,
                                 headers: {
                                 headers: {