Make out of space errors in the desktop client more obvious

This commit is contained in:
sabaimran
2024-02-26 11:53:36 -08:00
parent 956dd71d91
commit c8194a7364
3 changed files with 4 additions and 7 deletions

View File

@@ -101,9 +101,6 @@
<div class="card-description-row"> <div class="card-description-row">
<div id="sync-status"></div> <div id="sync-status"></div>
</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> </div>
</body> </body>

View File

@@ -215,8 +215,10 @@ function pushDataToKhoj (regenerate = false) {
.catch(error => { .catch(error => {
console.error(error); console.error(error);
state["completed"] = false; state["completed"] = false;
if (error?.response?.status === 429 && (win = BrowserWindow.getAllWindows()[0])) { if (error?.response?.status === 429 && (BrowserWindow.getAllWindows().find(win => win.webContents.getURL().includes('config')))) {
state["error"] = `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.`; state["error"] = `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.`;
const win = BrowserWindow.getAllWindows().find(win => win.webContents.getURL().includes('config'));
if (win) win.webContents.send('needsSubscription', true);
} else if (error?.code === 'ECONNREFUSED') { } else if (error?.code === 'ECONNREFUSED') {
state["error"] = `Could not connect to Khoj server. Ensure you can connect to it at ${error.address}:${error.port}.`; state["error"] = `Could not connect to Khoj server. Ensure you can connect to it at ${error.address}:${error.port}.`;
} else { } else {

View File

@@ -1,7 +1,6 @@
const setFolderButton = document.getElementById('update-folder'); const setFolderButton = document.getElementById('update-folder');
const setFileButton = document.getElementById('update-file'); const setFileButton = document.getElementById('update-file');
const loadingBar = document.getElementById('loading-bar'); const loadingBar = document.getElementById('loading-bar');
const needsSubscriptionElement = document.getElementById('needs-subscription');
async function removeFile(filePath) { async function removeFile(filePath) {
const updatedFiles = await window.removeFileAPI.removeFile(filePath); const updatedFiles = await window.removeFileAPI.removeFile(filePath);
@@ -168,9 +167,8 @@ window.updateStateAPI.onUpdateState((event, state) => {
window.needsSubscriptionAPI.onNeedsSubscription((event, needsSubscription) => { window.needsSubscriptionAPI.onNeedsSubscription((event, needsSubscription) => {
console.log("needs subscription", needsSubscription); console.log("needs subscription", needsSubscription);
if (needsSubscription) { if (needsSubscription) {
window.alert("Looks like you're out of space to sync your files. Upgrade your plan to unlock more space here: https://app.khoj.dev/config");
needsSubscriptionElement.style.display = 'block'; needsSubscriptionElement.style.display = 'block';
} else {
needsSubscriptionElement.style.display = 'none';
} }
}); });