diff --git a/src/interface/desktop/config.html b/src/interface/desktop/config.html index fb39fbb8..f8ecb06f 100644 --- a/src/interface/desktop/config.html +++ b/src/interface/desktop/config.html @@ -101,6 +101,9 @@
+ diff --git a/src/interface/desktop/main.js b/src/interface/desktop/main.js index eb355a5f..95927be1 100644 --- a/src/interface/desktop/main.js +++ b/src/interface/desktop/main.js @@ -198,6 +198,11 @@ function pushDataToKhoj (regenerate = false) { }) .catch(error => { console.error(error); + if (error.response.status == 429) { + const win = BrowserWindow.getAllWindows()[0]; + if (win) win.webContents.send('needsSubscription', true); + if (win) win.webContents.send('update-state', state); + } state['completed'] = false }) .finally(() => { @@ -396,6 +401,11 @@ app.whenReady().then(() => { event.reply('update-state', arg); }); + ipcMain.on('needsSubscription', (event, arg) => { + console.log(arg); + event.reply('needsSubscription', arg); + }); + ipcMain.on('navigate', (event, page) => { win.loadFile(page); }); diff --git a/src/interface/desktop/preload.js b/src/interface/desktop/preload.js index 1d4c6ec0..8d5152b7 100644 --- a/src/interface/desktop/preload.js +++ b/src/interface/desktop/preload.js @@ -31,6 +31,10 @@ contextBridge.exposeInMainWorld('updateStateAPI', { onUpdateState: (callback) => ipcRenderer.on('update-state', callback) }) +contextBridge.exposeInMainWorld('needsSubscriptionAPI', { + onNeedsSubscription: (callback) => ipcRenderer.on('needsSubscription', callback) +}) + contextBridge.exposeInMainWorld('removeFileAPI', { removeFile: (filePath) => ipcRenderer.invoke('removeFile', filePath) }) diff --git a/src/interface/desktop/renderer.js b/src/interface/desktop/renderer.js index 7d0d906e..16df6d2f 100644 --- a/src/interface/desktop/renderer.js +++ b/src/interface/desktop/renderer.js @@ -1,7 +1,7 @@ const setFolderButton = document.getElementById('update-folder'); const setFileButton = document.getElementById('update-file'); -const showKey = document.getElementById('show-key'); const loadingBar = document.getElementById('loading-bar'); +const needsSubscriptionElement = document.getElementById('needs-subscription'); async function removeFile(filePath) { const updatedFiles = await window.removeFileAPI.removeFile(filePath); @@ -165,6 +165,15 @@ window.updateStateAPI.onUpdateState((event, state) => { syncStatusElement.innerHTML = `⏱️ Synced at ${currentTime.toLocaleTimeString(undefined, options)}. Next sync at ${nextSyncTime.toLocaleTimeString(undefined, options)}.`; }); +window.needsSubscriptionAPI.onNeedsSubscription((event, needsSubscription) => { + console.log("needs subscription", needsSubscription); + if (needsSubscription) { + needsSubscriptionElement.style.display = 'block'; + } else { + needsSubscriptionElement.style.display = 'none'; + } +}); + const urlInput = document.getElementById('khoj-host-url'); (async function() { const url = await window.hostURLAPI.getURL();