Skip to content

Commit

Permalink
Make out of space errors in the desktop client more obvious
Browse files Browse the repository at this point in the history
  • Loading branch information
sabaimran committed Feb 26, 2024
1 parent 956dd71 commit c8194a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 0 additions & 3 deletions src/interface/desktop/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ <h3 class="card-title">
<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>

Expand Down
4 changes: 3 additions & 1 deletion src/interface/desktop/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ function pushDataToKhoj (regenerate = false) {
.catch(error => {
console.error(error);
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.`;
const win = BrowserWindow.getAllWindows().find(win => win.webContents.getURL().includes('config'));
if (win) win.webContents.send('needsSubscription', true);
} else if (error?.code === 'ECONNREFUSED') {
state["error"] = `Could not connect to Khoj server. Ensure you can connect to it at ${error.address}:${error.port}.`;
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/interface/desktop/renderer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const setFolderButton = document.getElementById('update-folder');
const setFileButton = document.getElementById('update-file');
const loadingBar = document.getElementById('loading-bar');
const needsSubscriptionElement = document.getElementById('needs-subscription');

async function removeFile(filePath) {
const updatedFiles = await window.removeFileAPI.removeFile(filePath);
Expand Down Expand Up @@ -168,9 +167,8 @@ window.updateStateAPI.onUpdateState((event, state) => {
window.needsSubscriptionAPI.onNeedsSubscription((event, needsSubscription) => {
console.log("needs subscription", 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';
} else {
needsSubscriptionElement.style.display = 'none';
}
});

Expand Down

0 comments on commit c8194a7

Please sign in to comment.