mirror of
https://github.com/khoj-ai/khoj.git
synced 2025-02-17 08:04:21 +00:00
Indicate in the desktop if the user gets rate limited for indexing
This commit is contained in:
parent
73e38fccf3
commit
52b88de7f4
4 changed files with 27 additions and 1 deletions
|
@ -101,6 +101,9 @@
|
|||
<div class="card-description-row">
|
||||
<div id="sync-status"></div>
|
||||
</div>
|
||||
<div id="needs-subscription" style="display: none;">
|
||||
Looks like you're out of space to sync your files. <a href="https://app.khoj.dev/config">Upgrade your plan</a> to unlock more space.
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Reference in a new issue