diff --git a/app/actions/broadcast.js b/app/actions/broadcast.js index ea4fb316d..d585cf81e 100644 --- a/app/actions/broadcast.js +++ b/app/actions/broadcast.js @@ -1,3 +1,4 @@ +import { displayError } from './error'; import { BroadcastManager } from '../domain/BroadcastManager'; import { SpectateManager } from '../domain/SpectateManager'; @@ -59,8 +60,17 @@ export function refreshBroadcasts() { } export function watchBroadcast(broadcastId) { - return async () => { - spectateManager.watchBroadcast(broadcastId); + return async (dispatch) => { + try { + spectateManager.watchBroadcast(broadcastId); + } catch (err) { + const errorAction = displayError( + 'broadcast-global', + err.message, + ); + + dispatch(errorAction); + } }; } diff --git a/app/actions/console.js b/app/actions/console.js index 56705e702..feb8a2229 100644 --- a/app/actions/console.js +++ b/app/actions/console.js @@ -58,7 +58,7 @@ export function connectionStateChanged() { return { type: CONNECTION_STATE_CHANGED, payload: {}, - } + }; } export function startMirroring(connection) { @@ -71,6 +71,6 @@ export function startMirroring(connection) { ); dispatch(errorAction); - });; + }); }; } diff --git a/app/domain/SlpFileWriter.js b/app/domain/SlpFileWriter.js index 59f367ee7..df7b58471 100644 --- a/app/domain/SlpFileWriter.js +++ b/app/domain/SlpFileWriter.js @@ -88,9 +88,9 @@ export default class SlpFileWriter extends EventEmitter { } updateSettings(settings) { - this.folderPath = settings.targetFolder; - this.id = settings.id; - this.isRelaying = settings.isRelaying; + this.folderPath = settings.targetFolder || this.folderPath; + this.id = settings.id || this.id; + this.isRelaying = settings.isRelaying || this.isRelaying; this.consoleNick = settings.consoleNick || this.consoleNick; this.obs.updateSettings(settings); this.slpStream.updateSettings({ diff --git a/app/domain/SpectateManager.js b/app/domain/SpectateManager.js index 0140c873b..55a647106 100644 --- a/app/domain/SpectateManager.js +++ b/app/domain/SpectateManager.js @@ -53,20 +53,10 @@ export class SpectateManager { this.prevBroadcastId = null; }); - // Get path for spectate replays in my documents - const rootFolderPath = electronSettings.get('settings.rootSlpPath'); - if (!rootFolderPath) { - throw new Error( - `Files cannot be saved without a Root Replay Directory set. Please return to the - settings page and set a Replay Root Directory.` - ); - } - const targetPath = path.join(rootFolderPath, 'Spectate'); - fs.ensureDirSync(targetPath); - - // Initialize SlpFileWriter for writting files + // Initialize SlpFileWriter for writting files with an empty folderPath + // We will update the folderPath when starting to watch a broadcast const slpSettings = { - folderPath: targetPath, + folderPath: "", onFileStateChange: () => { }, }; this.slpFileWriter = new SlpFileWriter(slpSettings); @@ -260,6 +250,23 @@ export class SpectateManager { return; } + // Get path for spectate replays in my documents + const rootFolderPath = electronSettings.get('settings.rootSlpPath'); + if (!rootFolderPath) { + throw new Error( + `Files cannot be saved without a Root Replay Directory set. Please return to the + settings page and set a Replay Root Directory.` + ); + } + const targetPath = path.join(rootFolderPath, 'Spectate'); + fs.ensureDirSync(targetPath); + + const slpSettings = { + folderPath: targetPath, + }; + + this.slpFileWriter.updateSettings(slpSettings); + if (broadcastId === this.prevBroadcastId) { // If we have not changed broadcasts, don't do anything. Worth noting that closing // dolphin will count as a broadcast change because it resets prevBroadcastId diff --git a/package.json b/package.json index ab57ad39b..6f597a297 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "slippi-desktop-app", "productName": "Slippi Desktop App", - "version": "1.6.2", + "version": "1.6.3", "description": "Slippi Desktop App for browsing and playing replays.", "scripts": { "build": "concurrently \"yarn build-main\" \"yarn build-renderer\"",