Skip to content

Commit de6294c

Browse files
committed
chore(ui): async frontend pt1
1 parent 516f962 commit de6294c

25 files changed

Lines changed: 76 additions & 92 deletions

src/backend/effects/builtin/conditional-effects/conditions/condition-manager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class ConditionManager extends EventEmitter {
9797

9898
const manager = new ConditionManager();
9999

100-
frontendCommunicator.on("getConditionTypes", (trigger) => {
101-
logger.info("got 'getConditionTypes' request");
100+
frontendCommunicator.onAsync("conditions:get-condition-types", async (trigger) => {
101+
logger.info(`Got "conditions:get-condition-types" request`);
102102

103103
let conditionTypes = manager.getAllConditionTypes();
104104
if (trigger != null) {

src/backend/effects/effect-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class EffectManager extends TypedEmitter<{
4444
return mapped;
4545
});
4646

47-
frontendCommunicator.onAsync("getEffectDefinitions", async (triggerData: {
47+
frontendCommunicator.onAsync("effects:get-effect-defintitions", async (triggerData: {
4848
triggerType: TriggerType;
4949
triggerMeta: TriggerMeta;
5050
}) => {
@@ -95,7 +95,7 @@ class EffectManager extends TypedEmitter<{
9595
return filteredEffectDefs;
9696
});
9797

98-
frontendCommunicator.on("getEffectDefinition", (effectId) => {
98+
frontendCommunicator.onAsync("effects:get-effect-definition", async (effectId) => {
9999
this.logger.debug("got effect request", effectId);
100100
return this.mapEffectForFrontEnd(
101101
this.getEffectById(effectId)

src/backend/events/activity-feed-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ActivityFeedManager {
4242
this.retriggerActivity(activity);
4343
});
4444

45-
frontendCommunicator.on("activity-feed:get-activity-feed-supported-events", () => {
45+
frontendCommunicator.onAsync("activity-feed:get-activity-feed-supported-events", async () => {
4646
return EventManager
4747
.getAllEventSources()
4848
.map(es =>

src/backend/events/event-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ class EventManager extends TypedEmitter<{
3535

3636
this.setMaxListeners(0);
3737

38-
frontendCommunicator.on("events:get-all-event-sources", () => {
38+
frontendCommunicator.onAsync("events:get-all-event-sources", async () => {
3939
this.logger.info("got 'get all event sources' request");
4040
return simpleClone(this.getAllEventSources());
4141
});
4242

43-
frontendCommunicator.on("events:get-all-events", () => {
43+
frontendCommunicator.onAsync("events:get-all-events", async () => {
4444
this.logger.info("got 'get all events' request");
4545
return simpleClone(this.getAllEvents());
4646
});
@@ -90,7 +90,7 @@ class EventManager extends TypedEmitter<{
9090
}
9191
});
9292

93-
frontendCommunicator.on("events:get-event-source", (event: {
93+
frontendCommunicator.onAsync("events:get-event-source", async (event: {
9494
sourceId: string;
9595
eventId: string;
9696
}) => {

src/backend/events/filters/filter-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class FilterManager extends EventEmitter {
1818
constructor() {
1919
super();
2020

21-
frontendCommunicator.on("getFiltersForEvent", (data: EventSourceAndId) => {
21+
frontendCommunicator.onAsync("filters:get-for-event", async (data: EventSourceAndId) => {
2222
this.logger.info("got 'get all filters' request");
2323
const { eventSourceId, eventId } = data;
2424
return this.getFiltersForEvent(eventSourceId, eventId).map((f) => {

src/backend/restrictions/restriction-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class RestrictionsManager extends TypedEmitter<Events> {
2525
constructor() {
2626
super();
2727

28-
frontendCommunicator.on("getRestrictions", (triggerData: {
28+
frontendCommunicator.onAsync("restrictions:get-restrictions", async (triggerData: {
2929
triggerType: TriggerType;
3030
triggerMeta: TriggerMeta;
3131
}) => {

src/backend/setups/setup-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class SetupManager {
5656
}) => await this.importSetup(setup, selectedCurrency)
5757
);
5858

59-
frontendCommunicator.on("setups:remove-setup-components",
60-
({ components }: { components: FirebotSetup["components"] }) =>
59+
frontendCommunicator.onAsync("setups:remove-setup-components",
60+
async ({ components }: { components: FirebotSetup["components"] }) =>
6161
this.removeSetupComponents(components));
6262
}
6363

src/gui/app/controllers/events.controller.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
$scope.getEventSets();
5555
};
5656

57-
const sources = backendCommunicator.fireEventSync("events:get-all-event-sources");
57+
let sources = [];
58+
$scope.loadEventSources = async () => {
59+
sources = await backendCommunicator.fireEventAsync("events:get-all-event-sources");
60+
};
5861

5962
function friendlyEventTypeName(sourceId, eventId) {
6063
const source = sources.find(s => s.id === sourceId);
@@ -518,7 +521,7 @@
518521

519522
$scope.simulateEventsByType = function() {
520523
utilityService.showModal({
521-
component: "simulateGroupEventsModal",
524+
component: "simulateEventModal",
522525
size: "sm"
523526
});
524527
};
@@ -544,5 +547,7 @@
544547
});
545548
}
546549
};
550+
551+
$scope.loadEventSources();
547552
});
548553
}());

src/gui/app/directives/conditional-effect/conditionDisplay.js renamed to src/gui/app/directives/conditional-effect/condition-display.js

File renamed without changes.

src/gui/app/directives/conditional-effect/conditionList.js renamed to src/gui/app/directives/conditional-effect/condition-list.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,8 @@
8383
}
8484
}
8585

86-
function getConditionTypes(triggerData) {
87-
return backendCommunicator
88-
.fireEventSync("getConditionTypes", triggerData)
86+
async function getConditionTypes(triggerData) {
87+
return (await backendCommunicator.fireEventAsync("conditions:get-condition-types", triggerData))
8988
.map((ct) => {
9089
ct.getRightSidePresetValues = eval(ct.getRightSidePresetValues); // eslint-disable-line no-eval
9190
ct.getLeftSidePresetValues = eval(ct.getLeftSidePresetValues); // eslint-disable-line no-eval
@@ -96,7 +95,7 @@
9695
});
9796
}
9897

99-
function reloadConditions() {
98+
async function reloadConditions() {
10099
if ($ctrl.conditionData == null) {
101100
$ctrl.conditionData = {
102101
mode: "exclusive",
@@ -110,7 +109,7 @@
110109
/*
111110
,
112111
*/
113-
conditionDefintions = getConditionTypes();
112+
conditionDefintions = await getConditionTypes();
114113
}
115114

116115
$ctrl.getConditionModeDisplay = function() {
@@ -121,13 +120,13 @@
121120
return conditionDefintions.find(fd => fd.id === typeId);
122121
};
123122

124-
$ctrl.$onInit = function() {
125-
reloadConditions();
123+
$ctrl.$onInit = async () => {
124+
await reloadConditions();
126125
validateConditionValues();
127126
};
128127

129-
$ctrl.$onChanges = function() {
130-
reloadConditions();
128+
$ctrl.$onChanges = async () => {
129+
await reloadConditions();
131130
};
132131

133132
$ctrl.hasConditionsAvailable = function() {

0 commit comments

Comments
 (0)