From b3f4794d91de1e2d8b7e1aba6f6252836b9461c2 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Fri, 12 Apr 2024 11:49:25 +0530 Subject: [PATCH] Remove the unnecessary async/await func chains on Desktop app --- src/interface/desktop/main.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/interface/desktop/main.js b/src/interface/desktop/main.js index 9cb1bc4e..eb3ceb37 100644 --- a/src/interface/desktop/main.js +++ b/src/interface/desktop/main.js @@ -120,7 +120,7 @@ function isSupportedFileType(filePath) { return validFileTypes.includes(fileExtension); } -async function processDirectory(filesToPush, folder) { +function processDirectory(filesToPush, folder) { const files = fs.readdirSync(folder.path, { withFileTypes: true }); for (const file of files) { @@ -136,12 +136,12 @@ async function processDirectory(filesToPush, folder) { } // Recursively process subdirectories if (file.isDirectory()) { - await processDirectory(filesToPush, {'path': filePath}); + processDirectory(filesToPush, {'path': filePath}); } } } -async function pushDataToKhoj (regenerate = false) { +function pushDataToKhoj (regenerate = false) { // Don't sync if token or hostURL is not set or if already syncing if (store.get('khojToken') === '' || store.get('hostURL') === '' || syncing === true) { const win = BrowserWindow.getAllWindows()[0]; @@ -163,7 +163,7 @@ async function pushDataToKhoj (regenerate = false) { // Collect paths of all indexable files in configured folders for (const folder of folders) { - await processDirectory(filesToPush, folder); + processDirectory(filesToPush, folder); } const lastSync = store.get('lastSync') || []; @@ -347,7 +347,7 @@ async function removeFolder (event, folderPath) { async function syncData (regenerate = false) { try { - await pushDataToKhoj(regenerate); + pushDataToKhoj(regenerate); const date = new Date(); console.log('Pushing data to Khoj at: ', date); } catch (err) { @@ -359,7 +359,7 @@ async function deleteAllFiles () { try { store.set('files', []); store.set('folders', []); - await pushDataToKhoj(true); + pushDataToKhoj(true); const date = new Date(); console.log('Pushing data to Khoj at: ', date); } catch (err) { @@ -395,9 +395,9 @@ const createWindow = (tab = 'chat.html') => { } }) - const job = new cron('0 */10 * * * *', async function() { + const job = new cron('0 */10 * * * *', function() { try { - await pushDataToKhoj(); + pushDataToKhoj(); const date = new Date(); console.log('Pushing data to Khoj at: ', date); win.webContents.send('update-state', state);