Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 4 additions & 95 deletions src/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ const ROOT = path.join(__dirname, '..', '..');
const PRELOAD = path.join(__dirname, '..', 'preload');
const RENDERER = path.join(__dirname, '..', 'renderer');
const SETTINGS = path.join(__dirname, '..', 'settings');
const SETUP = path.join(__dirname, '..', 'setup');
const SETUP_PRELOAD = path.join(__dirname, '..', 'preload', 'preload-setup.js');

// Settings store (will be initialized when app is ready)
const store = new SimpleStore({
Expand All @@ -29,9 +27,6 @@ const store = new SimpleStore({
// Settings window reference
let settingsWindow = null;

// Setup window reference
let setupWindow = null;

// BrowserView reference (for reset functionality)
let mainBrowserView = null;

Expand Down Expand Up @@ -341,14 +336,7 @@ function createWindow() {
});

// Get the saved stream URL
const streamUrl = store ? store.get('streamUrl') : null;
if (!streamUrl) {
createSetupWindow();
return;
}

const fullUrl =
streamUrl.startsWith('http://') || streamUrl.startsWith('https://') ? streamUrl : `https://${streamUrl}/`;
const fullUrl = 'https://pstream.net';
view.webContents.loadURL(fullUrl);

// Show error page when the main document fails to load (e.g. no connection, DNS)
Expand Down Expand Up @@ -1002,46 +990,6 @@ function openSettingsWindow(parentWindow = null) {
});
}

function createSetupWindow() {
if (setupWindow) {
setupWindow.focus();
return;
}

const platform = process.env.PLATFORM_OVERRIDE || process.platform;
const isMac = platform === 'darwin';
const iconPath = path.join(ROOT, isMac ? 'app.icns' : 'logo.png');

setupWindow = new BrowserWindow({
width: 600,
height: 400,
minWidth: 400,
minHeight: 300,
resizable: false,
autoHideMenuBar: true,
backgroundColor: '#1f2025',
icon: iconPath,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: SETUP_PRELOAD,
},
title: 'P-Stream Setup',
show: false,
});

setupWindow.setMenu(null);
setupWindow.loadFile(path.join(SETUP, 'setup.html'));

setupWindow.once('ready-to-show', () => {
setupWindow.show();
});

setupWindow.on('closed', () => {
setupWindow = null;
});
}

// Auto-updater configuration
autoUpdater.autoDownload = false; // Don't auto-download, users download manually
autoUpdater.autoInstallOnAppQuit = false; // Don't auto-install, users install manually
Expand Down Expand Up @@ -1690,47 +1638,6 @@ ipcMain.handle('set-stream-url', async (event, url) => {
return true;
});

// IPC handler for saving the domain from the setup window
ipcMain.handle('save-domain', async (event, domain) => {
try {
if (!store) {
throw new Error('Settings store not available');
}

let normalizedDomain = domain.trim();

if (!normalizedDomain || normalizedDomain.length === 0) {
throw new Error('Domain cannot be empty');
}

// Basic validation: ensure it looks like a domain or IP
if (!normalizedDomain.includes('.') && !normalizedDomain.match(/^\d{1,3}(\.\d{1,3}){3}$/)) {
throw new Error('Please enter a valid domain or IP address (e.g., pstream.example.com or 192.168.1.1)');
}

store.set('streamUrl', normalizedDomain);

// Close the setup window
if (setupWindow) {
setupWindow.close();
}

// Load the stream URL into the main BrowserView
if (mainBrowserView && mainBrowserView.webContents) {
const fullUrl =
normalizedDomain.startsWith('http://') || normalizedDomain.startsWith('https://')
? normalizedDomain
: `https://${normalizedDomain}/`;
mainBrowserView.webContents.loadURL(fullUrl);
}

return { success: true };
} catch (error) {
console.error('Failed to save domain:', error);
return { success: false, error: error.message };
}
});

// IPC handler for resetting the app
ipcMain.handle('reset-app', async () => {
try {
Expand Down Expand Up @@ -1830,9 +1737,11 @@ ipcMain.handle('reload-stream-page', () => {
if (!mainBrowserView || !mainBrowserView.webContents) return;
const streamUrl = store ? store.get('streamUrl') : null;
if (!streamUrl) {
mainBrowserView.webContents.loadFile(path.join(SETUP, 'setup.html'));
const fullUrl = 'https://pstream.net';
mainBrowserView.webContents.loadURL(fullUrl);
return;
}

const fullUrl =
streamUrl.startsWith('http://') || streamUrl.startsWith('https://') ? streamUrl : `https://${streamUrl}/`;
mainBrowserView.webContents.loadURL(fullUrl);
Expand Down
102 changes: 0 additions & 102 deletions src/setup/setup.css

This file was deleted.

22 changes: 0 additions & 22 deletions src/setup/setup.html

This file was deleted.

20 changes: 0 additions & 20 deletions src/setup/setup.js

This file was deleted.