Skip to content

Commit 5fb96be

Browse files
authored
Fixes/trigger random with queue (#505)
* fix waitUntilDone checks for the targetScreen * QoL: Recipe: Action List Config - now has a button to open up the Action Settings * Fix up the Action State Debug View
1 parent abdd461 commit 5fb96be

File tree

9 files changed

+70
-37
lines changed

9 files changed

+70
-37
lines changed

CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
## 2022.1 to be released
1+
## 2022.1-rc1 to be released
22

3-
### Feature
3+
### Quality of Life
4+
5+
* [x] Recipe: Action List Config - now has a button to open up the Action Settings
6+
7+
### Fixes
48

5-
* [ ] Ability to re-authenticate even when you are not in the normal ports
9+
* [x] Trigger random using a queue on recipe and each item - could end up in not triggering a second time
610

711
## 2022.1-beta-4
812

ROADMAP.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This list might be changed in future, depending on the amount of work that needs
1414
* [ ] Dependency: Twitch Scope System - for Scripts and Command Block Checks
1515
* [ ] Recipe: Obs Command Block: Set Volume
1616
* [ ] Dependency: Command Block Settings for Numbers with a Range Config
17+
* [ ] Ability to re-authenticate even when you are not in the normal ports
1718

1819
### Misc
1920

projects/app-state/src/lib/activity-state/action-activity.service.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ export class ActionActivityService {
1717
// Load State once
1818
this.memeboxApi.get<ActionStateEntries>(`${ENDPOINTS.ACTION_ACTIVITY.PREFIX}${ENDPOINTS.ACTION_ACTIVITY.CURRENT}`)
1919
.then( actionStateInitialValue => {
20-
this.activityStore.update(() => actionStateInitialValue);
20+
this.activityStore.update((currentState) =>
21+
{
22+
return {
23+
actionState: {
24+
...currentState.actionState,
25+
...actionStateInitialValue,
26+
},
27+
screenState: currentState.screenState
28+
}
29+
});
2130
});
2231

2332
const actionStateWSHandler = new WebsocketHandler(

projects/recipe-ui/src/lib/command-setting-dialog/action-list-settings/action-list-settings.component.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,21 @@
4242
<mat-card-header class="card__header">
4343
<mat-card-title>{{ actionDictionary[actionEntry.actionId]?.name }}</mat-card-title>
4444

45-
<button mat-icon-button class="remove-icon"
46-
matTooltip="Remove" *ngIf="actionListTypeSelect.value !== 'byTag'"
47-
(click)="removeActionEntry(actionList, actionEntry)">
48-
<mat-icon svgIcon="delete"></mat-icon>
49-
</button>
45+
46+
<div class="icon-list">
47+
<button mat-icon-button
48+
matTooltip="edit Action"
49+
color="accent"
50+
(click)="openActionEditDialog(actionDictionary[actionEntry.actionId])">
51+
<mat-icon svgIcon="settings"></mat-icon>
52+
</button>
53+
<button mat-icon-button
54+
matTooltip="Remove" *ngIf="actionListTypeSelect.value !== 'byTag'"
55+
color="warn"
56+
(click)="removeActionEntry(actionList, actionEntry)">
57+
<mat-icon svgIcon="delete"></mat-icon>
58+
</button>
59+
</div>
5060
</mat-card-header>
5161

5262
<app-action-preview [action]="actionDictionary[actionEntry.actionId]"

projects/recipe-ui/src/lib/command-setting-dialog/action-list-settings/action-list-settings.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
width: 0;
2828
}
2929

30-
.mat-icon-button.remove-icon {
30+
.icon-list {
3131
position: absolute;
3232
top: 0.25rem;
3333
right: 1rem;

projects/recipe-ui/src/lib/command-setting-dialog/action-list-settings/action-list-settings.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ export class ActionListSettingsComponent {
8080
actionList.splice(indexOf, 1);
8181
}
8282

83+
openActionEditDialog (action: Action) {
84+
this.dialogService.showMediaEditDialog({
85+
actionToEdit: action
86+
});
87+
}
88+
8389
onTagSelected($event: string) {
8490
this.updateConfigPayload({
8591
actionsByTag: $event

server/providers/actions/action-active-state.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export class ActionActiveState {
8282
return this._state$
8383
.pipe(
8484
filter(( state) => {
85-
return isActionCurrently(state, ActionStateEnum.Active, actionId, screenId ?? actionId);
85+
return isActionCurrently(state, ActionStateEnum.Active, actionId, screenId);
8686
}),
8787
map(_ => {}),
8888
take(1)
@@ -98,7 +98,7 @@ export class ActionActiveState {
9898
return this._state$
9999
.pipe(
100100
filter(( state) => {
101-
const done = isActionCurrently(state, ActionStateEnum.Done, actionId, screenId ?? actionId);
101+
const done = isActionCurrently(state, ActionStateEnum.Done, actionId, screenId);
102102

103103
return done;
104104
}),

server/providers/actions/action-queue.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,36 @@ export class ActionQueue {
2424

2525
const actionConfig = fullState.clips[triggerAction.id];
2626

27-
if (actionConfig.queueName) {
28-
if (isVisibleMedia(actionConfig.type)) {
29-
const currentState = this.actionState.getActiveStateEntry(triggerAction.id, triggerAction.targetScreen);
30-
const mediaInScreenConfig = fullState.screen[triggerAction.targetScreen]?.clips[triggerAction.id];
27+
if (!actionConfig.queueName) {
28+
// no queue needed, "just do it"
29+
await this.executeTriggerWithoutQueueAndWait(triggerAction);
30+
return;
31+
}
3132

32-
const visibilityOfOverrides =currentState?.currentOverrides?.screenMedia?.visibility;
33-
const visibilityOfMedia = mediaInScreenConfig?.visibility;
33+
// Special: handle already visible / toggled media
34+
if (isVisibleMedia(actionConfig.type)) {
35+
const currentState = this.actionState.getActiveStateEntry(triggerAction.id, triggerAction.targetScreen);
36+
const mediaInScreenConfig = fullState.screen[triggerAction.targetScreen]?.clips[triggerAction.id];
3437

35-
const currentVisibilityConfig = visibilityOfOverrides ?? visibilityOfMedia;
38+
const visibilityOfOverrides = currentState?.currentOverrides?.screenMedia?.visibility;
39+
const visibilityOfMedia = mediaInScreenConfig?.visibility;
3640

37-
if (currentState?.state === ActionStateEnum.Active && currentVisibilityConfig === VisibilityEnum.Toggle) {
38-
await this.executeTriggerWithoutQueueAndWait(triggerAction);
39-
return;
40-
}
41+
const currentVisibilityConfig = visibilityOfOverrides ?? visibilityOfMedia;
42+
43+
if (currentState?.state === ActionStateEnum.Active && currentVisibilityConfig === VisibilityEnum.Toggle) {
44+
await this.executeTriggerWithoutQueueAndWait(triggerAction);
45+
return;
4146
}
47+
}
4248

43-
const subject = this.createOrGetQueueSubject(actionConfig.queueName);
44-
subject.next(triggerAction);
49+
const subject = this.createOrGetQueueSubject(actionConfig.queueName);
4550

46-
await this._queueDone$.pipe(
47-
filter(uniqueDone => uniqueDone === triggerAction.uniqueId),
48-
take(1),
49-
).toPromise();
50-
} else {
51-
// no queue needed, "just do it"
51+
subject.next(triggerAction);
5252

53-
await this.executeTriggerWithoutQueueAndWait(triggerAction);
54-
}
53+
await this._queueDone$.pipe(
54+
filter(uniqueDone => uniqueDone === triggerAction.uniqueId),
55+
take(1)
56+
).toPromise();
5557
}
5658

5759
private createOrGetQueueSubject (queueName: string) {

src/app/pages/debug/activity-state/activity-state.component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ActivityQueries, AppQueries, AppService} from "@memebox/app-state";
33
import {filter, map} from "rxjs/operators";
44
import {ACTION_TYPE_INFORMATION, ActionStateEnum, ActionType} from "@memebox/contracts";
55
import {combineLatest} from "rxjs";
6+
import {ActionStateEntry} from "@memebox/shared-state";
67

78
function actionStateEnumToString (activity: ActionStateEnum) {
89
switch (activity) {
@@ -31,23 +32,23 @@ export class ActivityStateComponent {
3132
)
3233
]).pipe(
3334
map(([activityState, actionMap]) => {
34-
const actionKeys = Object.keys(activityState);
35+
const actionKeys = Object.keys(activityState.actionState ?? {});
3536

3637
return actionKeys.map(actionId => {
37-
const statesOfAction = activityState[actionId];
38+
const statesOfAction: Record<string, ActionStateEntry> = activityState.actionState[actionId];
3839
const keysOfStates = Object.keys(statesOfAction);
3940

4041
let activityOfAction = '';
4142

4243
if (keysOfStates.includes(actionId)) {
43-
activityOfAction = actionStateEnumToString(statesOfAction[actionId])
44+
activityOfAction = actionStateEnumToString(statesOfAction[actionId].state)
4445
}
4546

4647
const stateInScreen = keysOfStates.filter(key => key !== actionId)
4748
.map(key => {
4849
return {
4950
screenId: key,
50-
state: actionStateEnumToString(statesOfAction[key])
51+
state: actionStateEnumToString(statesOfAction[key].state)
5152
}
5253
});
5354

0 commit comments

Comments
 (0)