Skip to content

Commit

Permalink
Do not update settings in unattended mode (stream-labs#2833)
Browse files Browse the repository at this point in the history
* Do not update settings in unatended mode

* fix YT in unatended mode

* fix twitch

* strictnull fix

* fix types
  • Loading branch information
holiber authored Jul 28, 2020
1 parent e7f070f commit 735fc18
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/components/StartStreamingButton.vue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class StartStreamingButton extends Vue {
if (this.streamingService.views.shouldShowGoLiveWindow()) {
this.streamingService.actions.showGoLiveWindow();
} else {
this.streamingService.actions.goLive(null, true);
this.streamingService.actions.goLive();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/services/platforms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export interface IPlatformService {
/**
* Sets up the stream key and live broadcast info required to go live.
*/
beforeGoLive: (options: IGoLiveSettings) => Promise<void>;
beforeGoLive: (options?: IGoLiveSettings) => Promise<void>;

afterGoLive: () => Promise<void>;

Expand Down
6 changes: 4 additions & 2 deletions app/services/platforms/twitch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ export class TwitchService extends BasePlatformService<ITwitchServiceState>
});
}

const channelInfo = goLiveSettings?.platforms.twitch;
if (channelInfo) await this.putChannelInfo(channelInfo);
if (goLiveSettings) {
const channelInfo = goLiveSettings?.platforms.twitch;
if (channelInfo) await this.putChannelInfo(channelInfo);
}
}

async validatePlatform() {
Expand Down
10 changes: 8 additions & 2 deletions app/services/streaming/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class StreamingService extends StatefulService<IStreamingServiceState>
/**
* Make a transition to Live
*/
async goLive(newSettings?: IGoLiveSettings, unattendedMode = false) {
async goLive(newSettings?: IGoLiveSettings) {
// don't interact with API in loged out mode and when protected mode is disabled
if (
!this.userService.isLoggedIn ||
Expand All @@ -228,6 +228,10 @@ export class StreamingService extends StatefulService<IStreamingServiceState>
// clear the current stream info
this.RESET_STREAM_INFO();

// if settings are not provided then GoLive window has been not shown
// consider this as unattendedMode
const unattendedMode = !newSettings;

// use default settings if no new settings provided
const settings = newSettings || cloneDeep(this.views.goLiveSettings);

Expand All @@ -242,7 +246,9 @@ export class StreamingService extends StatefulService<IStreamingServiceState>
for (const platform of platforms) {
const service = getPlatformService(platform);
try {
await this.runCheck(platform, () => service.beforeGoLive(settings));
// don't update settigns for twitch in unattendedMode
const settingsForPlatform = platform === 'twitch' && unattendedMode ? undefined : settings;
await this.runCheck(platform, () => service.beforeGoLive(settingsForPlatform));
} catch (e) {
console.error(e);
// cast all PLATFORM_REQUEST_FAILED errors to SETTINGS_UPDATE_FAILED
Expand Down

0 comments on commit 735fc18

Please sign in to comment.