Skip to content

Commit

Permalink
fix: cancel widget read tasks after a control scheme start failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsukhanov committed Mar 26, 2024
1 parent a7abffa commit 5239bcb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,24 @@ import { IWidgetsReadTasksFactory } from './i-widgets-read-tasks-factory';
export function createWidgetReadTasks(
scheme: ControlSchemeModel,
store: Store,
widgetTaskFactory: IWidgetsReadTasksFactory
widgetTaskFactory: IWidgetsReadTasksFactory,
): Array<Observable<unknown>> {
const result: Array<Observable<unknown>> = [];
const readerTasks = widgetTaskFactory.createReadTasks(scheme.widgets);
for (const task of readerTasks) {
const obs = new Observable((subscriber) => {
let initialValueReceived = false;
task.subscribe((taskData) => {
const sub = task.subscribe((taskData) => {
if (!initialValueReceived) {
initialValueReceived = true;
subscriber.next(null);
subscriber.complete();
}
store.dispatch(CONTROL_SCHEME_WIDGETS_DATA_ACTIONS.updateWidgetData(taskData));
});
return () => {
sub.unsubscribe();
};
});

result.push(obs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ export const CONTROL_SCHEME_WIDGET_DATA_FEATURE = createFeature({
{
widgetsData: {}
} as ControlSchemeWidgetsDataState,
on(CONTROL_SCHEME_ACTIONS.startScheme, CONTROL_SCHEME_ACTIONS.schemeStopped, (): ControlSchemeWidgetsDataState => ({ widgetsData: {} })),
on(
CONTROL_SCHEME_ACTIONS.startScheme,
CONTROL_SCHEME_ACTIONS.schemeStopped,
CONTROL_SCHEME_ACTIONS.schemeStartFailed,
(): ControlSchemeWidgetsDataState => ({ widgetsData: {} })
),
on(CONTROL_SCHEME_WIDGETS_DATA_ACTIONS.updateWidgetData, (state, { widgetId, data }): ControlSchemeWidgetsDataState => {
return {
...state,
Expand Down
3 changes: 2 additions & 1 deletion src/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@
"1-2-8": {
"minorNotificationImprovements": "Minor improvements to notifications",
"addGamepadPollingRateSettings": "Gamepad polling rate option added to the settings",
"increaseGamepadPollingRate": "Increased default gamepad poll rate. Previous value is now considered 'Low' in the settings"
"increaseGamepadPollingRate": "Increased default gamepad poll rate. Previous value is now considered 'Low' in the settings",
"fixWidgetUpdatesAfterSchemeStartFailure": "Fixed widgets continuing to update after a control scheme start failure"
}
}
}
3 changes: 2 additions & 1 deletion src/assets/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,8 @@
"1-2-8": {
"minorNotificationImprovements": "Небольшие улучшения уведомлений",
"addGamepadPollingRateSettings": "Добавлены настройки частоты опроса геймпада",
"increaseGamepadPollingRate": "Увеличена частота опроса геймпада. Предыдущая частота доступна в настройках как 'Низкая'"
"increaseGamepadPollingRate": "Увеличена частота опроса геймпада. Предыдущая частота доступна в настройках как 'Низкая'",
"fixWidgetUpdatesAfterSchemeStartFailure": "Исправлены обновления виджетов после неудачного запуска схемы управления"
}
}
}
1 change: 1 addition & 0 deletions src/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const CHANGELOG: IChangelog = [
'changelog.1-2-8.minorNotificationImprovements',
'changelog.1-2-8.addGamepadPollingRateSettings',
'changelog.1-2-8.increaseGamepadPollingRate',
'changelog.1-2-8.fixWidgetUpdatesAfterSchemeStartFailure',
]
},
{
Expand Down

0 comments on commit 5239bcb

Please sign in to comment.