Dynamically generate navigation menu based on user info from server

This commit is contained in:
Debanjum Singh Solanky
2024-04-07 20:58:43 +05:30
parent 94c69eb8e3
commit 8ff3890ba8
7 changed files with 199 additions and 33 deletions

View File

@@ -351,6 +351,17 @@ async function deleteAllFiles () {
}
}
// Fetch user info from Khoj server
async function getUserInfo() {
const getUserInfoURL = `${store.get('hostURL') || KHOJ_URL}/api/v1/user?client=desktop`;
const headers = { 'Authorization': `Bearer ${store.get('khojToken')}` };
try {
let response = await axios.get(getUserInfoURL, { headers });
return response.data;
} catch (err) {
console.error(err);
}
}
let firstRun = true;
let win = null;
@@ -466,6 +477,7 @@ app.whenReady().then(() => {
ipcMain.handle('setToken', setToken);
ipcMain.handle('getToken', getToken);
ipcMain.handle('getUserInfo', getUserInfo);
ipcMain.handle('syncData', (event, regenerate) => {
syncData(regenerate);