Skip to content

Commit e34eca9

Browse files
author
FileShot
committed
feat: Load desktop UI by default with live API
1 parent 055e564 commit e34eca9

3 files changed

Lines changed: 39 additions & 3 deletions

File tree

main.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,21 @@ async function loadFrontend({ preferredPath = '/', reason = '' } = {}) {
106106

107107
const safePath = String(preferredPath || '/').startsWith('/') ? String(preferredPath || '/') : '/';
108108

109+
// Load the local desktop UI with sidebar + file explorer connected to live API
110+
const localUIUrl = `file://${LOCAL_UI_INDEX}`;
111+
console.log('[FileShot] Loading desktop UI:', localUIUrl, reason ? `(${reason})` : '');
112+
await mainWindow.loadFile(LOCAL_UI_INDEX);
113+
mainWindow.webContents.on('did-finish-load', () => {
114+
mainWindow.webContents.send('api-config', { apiUrl: API_URL });
115+
});
116+
return;
117+
}
118+
119+
async function loadFrontendFallback({ preferredPath = '/', reason = '' } = {}) {
120+
if (!mainWindow) return;
121+
122+
const safePath = String(preferredPath || '/').startsWith('/') ? String(preferredPath || '/') : '/';
123+
109124
// Dev: always use local dev server.
110125
if (isDev) {
111126
const url = `http://localhost:8080${safePath}`;

preload.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ const { contextBridge, ipcRenderer } = require('electron');
88
contextBridge.exposeInMainWorld('electronAPI', {
99
// API configuration
1010
getApiUrl: () => ipcRenderer.invoke('get-api-url'),
11+
onApiConfig: (callback) => {
12+
ipcRenderer.on('api-config', (_event, config) => {
13+
try { callback(config); } catch (_) {}
14+
});
15+
},
1116

1217
// Authentication
1318
getAuthToken: () => ipcRenderer.invoke('get-auth-token'),

renderer/local/app.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,22 @@
11
/**
2-
* FileShot Offline Desktop App - Main Application Logic
3-
* Handles sidebar navigation, drag-drop, storage management, and secure shredding
2+
* FileShot Desktop App - Hybrid UI
3+
* Local sidebar + file explorer connected to live API
44
*/
55

6+
// ============================================================================
7+
// API CONFIGURATION
8+
// ============================================================================
9+
10+
let API_URL = 'https://api.fileshot.io/api'; // Default to live API
11+
12+
// Receive API config from main process
13+
if (window.electronAPI) {
14+
window.electronAPI.onApiConfig?.((config) => {
15+
API_URL = config.apiUrl;
16+
console.log('[FileShot Desktop] API configured:', API_URL);
17+
});
18+
}
19+
620
// ============================================================================
721
// STATE MANAGEMENT
822
// ============================================================================
@@ -16,7 +30,9 @@ const state = {
1630
settings: {
1731
autoLock: false,
1832
requirePin: false
19-
}
33+
},
34+
authToken: localStorage.getItem('fileshot_token') || null,
35+
userId: localStorage.getItem('fileshot_userId') || null
2036
};
2137

2238
// ============================================================================

0 commit comments

Comments
 (0)