Skip to content

Commit

Permalink
v1.6.3 Fix early error out from SpectateManager
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Nov 27, 2020
1 parent 5cee6da commit 0bfacc5
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
14 changes: 12 additions & 2 deletions app/actions/broadcast.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { displayError } from './error';
import { BroadcastManager } from '../domain/BroadcastManager';
import { SpectateManager } from '../domain/SpectateManager';

Expand Down Expand Up @@ -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);
}
};
}

Expand Down
4 changes: 2 additions & 2 deletions app/actions/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function connectionStateChanged() {
return {
type: CONNECTION_STATE_CHANGED,
payload: {},
}
};
}

export function startMirroring(connection) {
Expand All @@ -71,6 +71,6 @@ export function startMirroring(connection) {
);

dispatch(errorAction);
});;
});
};
}
6 changes: 3 additions & 3 deletions app/domain/SlpFileWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
33 changes: 20 additions & 13 deletions app/domain/SpectateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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\"",
Expand Down

0 comments on commit 0bfacc5

Please sign in to comment.