Skip to content

Commit ff83090

Browse files
Tim020claude
andcommitted
Refactor frontend components to use Promise.all for parallel data fetching
Converts sequential await chains to parallel Promise.all calls in 10 Vue components, significantly improving page load times by running independent API calls concurrently. High priority refactors (largest impact): - ScriptEditor.vue: 14 sequential awaits → parallel groups - CueEditor.vue: 13 sequential awaits → parallel groups - ConfigMics.vue: 6 sequential awaits → single Promise.all Medium priority refactors: - ConfigSystem.vue: 4 parallel fetches - ConfigCharacters.vue: 2 parallel fetches - CharacterGroups.vue: 2 parallel fetches - PropsList.vue: 2 parallel fetches - SceneryList.vue: 2 parallel fetches Additional optimizations: - App.vue: Parallelize RBAC roles with WebSocket state check; parallelize user RBAC and settings after user fetch - ShowLiveView.vue: Parallelize session data and act list fetches Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 3985876 commit ff83090

File tree

10 files changed

+68
-76
lines changed

10 files changed

+68
-76
lines changed

client/src/App.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -324,19 +324,15 @@ export default {
324324
async awaitWSConnect() {
325325
if (this.WEBSOCKET_HEALTHY) {
326326
clearTimeout(this.loadTimer);
327-
await this.GET_RBAC_ROLES();
328327
329-
// Check WebSocket state for any pending operations
330-
if (this.WEBSOCKET_HAS_PENDING_OPERATIONS) {
331-
await this.CHECK_WEBSOCKET_STATE();
332-
}
328+
await Promise.all([
329+
this.GET_RBAC_ROLES(),
330+
this.WEBSOCKET_HAS_PENDING_OPERATIONS ? this.CHECK_WEBSOCKET_STATE() : Promise.resolve(),
331+
]);
333332
334-
// Check for authentication via token first
335333
if (this.AUTH_TOKEN) {
336-
// Then get user data
337334
await this.GET_CURRENT_USER();
338-
await this.GET_CURRENT_RBAC();
339-
await this.GET_USER_SETTINGS();
335+
await Promise.all([this.GET_CURRENT_RBAC(), this.GET_USER_SETTINGS()]);
340336
}
341337
342338
if (this.SETTINGS.current_show != null) {

client/src/views/show/ShowLiveView.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,13 @@ export default {
166166
},
167167
},
168168
async mounted() {
169-
await this.GET_SHOW_SESSION_DATA();
169+
await Promise.all([this.GET_SHOW_SESSION_DATA(), this.GET_ACT_LIST()]);
170170
this.loadedSessionData = true;
171171
172172
if (this.CURRENT_SHOW_INTERVAL != null) {
173173
this.setupIntervalTimer();
174174
}
175175
176-
// Load act list (needed for interval overlay heading)
177-
await this.GET_ACT_LIST();
178-
179176
// Setup elapsed time tracking
180177
this.updateElapsedTime();
181178
this.startTime = this.createDateAsUTC(

client/src/views/show/config/ConfigCharacters.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ export default {
218218
},
219219
},
220220
async mounted() {
221-
await this.GET_CHARACTER_LIST();
222-
await this.GET_CAST_LIST();
221+
await Promise.all([this.GET_CHARACTER_LIST(), this.GET_CAST_LIST()]);
223222
},
224223
methods: {
225224
resetNewForm() {

client/src/views/show/config/ConfigMics.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ export default {
5252
};
5353
},
5454
async mounted() {
55-
await this.GET_SCENE_LIST();
56-
await this.GET_ACT_LIST();
57-
await this.GET_CHARACTER_LIST();
58-
await this.GET_CAST_LIST();
59-
await this.GET_MICROPHONE_LIST();
60-
await this.GET_MIC_ALLOCATIONS();
55+
await Promise.all([
56+
this.GET_SCENE_LIST(),
57+
this.GET_ACT_LIST(),
58+
this.GET_CHARACTER_LIST(),
59+
this.GET_CAST_LIST(),
60+
this.GET_MICROPHONE_LIST(),
61+
this.GET_MIC_ALLOCATIONS(),
62+
]);
6163
this.loaded = true;
6264
},
6365
methods: {

client/src/vue_components/config/ConfigSystem.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,12 @@ export default {
301301
...mapGetters(['SCRIPT_MODES']),
302302
},
303303
async mounted() {
304-
await this.getAvailableShows();
305-
await this.getConnectedClients();
306-
await this.GET_SCRIPT_MODES();
307-
await this.getVersionStatus();
304+
await Promise.all([
305+
this.getAvailableShows(),
306+
this.getConnectedClients(),
307+
this.GET_SCRIPT_MODES(),
308+
this.getVersionStatus(),
309+
]);
308310
this.loading = false;
309311
310312
// Start time update interval for reactive "time ago" display

client/src/vue_components/show/config/characters/CharacterGroups.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,7 @@ export default {
207207
...mapGetters(['CHARACTER_LIST', 'CHARACTER_GROUP_LIST', 'IS_SHOW_EDITOR']),
208208
},
209209
async mounted() {
210-
await this.GET_CHARACTER_LIST();
211-
await this.GET_CHARACTER_GROUP_LIST();
210+
await Promise.all([this.GET_CHARACTER_LIST(), this.GET_CHARACTER_GROUP_LIST()]);
212211
this.loading = false;
213212
},
214213
methods: {

client/src/vue_components/show/config/cues/CueEditor.vue

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,30 +183,28 @@ export default {
183183
},
184184
},
185185
async beforeMount() {
186-
// Get the current user
187-
await this.GET_CURRENT_USER();
188-
// Config status
189-
await this.GET_SCRIPT_CONFIG_STATUS();
190-
// Show details
191-
await this.GET_ACT_LIST();
192-
await this.GET_SCENE_LIST();
193-
await this.GET_CHARACTER_LIST();
194-
await this.GET_CHARACTER_GROUP_LIST();
195-
await this.GET_CUE_TYPES();
196-
await this.LOAD_CUES();
197-
await this.GET_CUTS();
198-
await this.GET_STAGE_DIRECTION_STYLES();
186+
await Promise.all([
187+
this.GET_CURRENT_USER().then(() => {
188+
if (this.CURRENT_USER != null) {
189+
return Promise.all([
190+
this.GET_STAGE_DIRECTION_STYLE_OVERRIDES(),
191+
this.GET_CUE_COLOUR_OVERRIDES(),
192+
]);
193+
}
194+
return Promise.resolve();
195+
}),
196+
this.GET_SCRIPT_CONFIG_STATUS(),
197+
this.GET_ACT_LIST(),
198+
this.GET_SCENE_LIST(),
199+
this.GET_CHARACTER_LIST(),
200+
this.GET_CHARACTER_GROUP_LIST(),
201+
this.GET_CUE_TYPES(),
202+
this.LOAD_CUES(),
203+
this.GET_CUTS(),
204+
this.GET_STAGE_DIRECTION_STYLES(),
205+
this.getMaxScriptPage(),
206+
]);
199207
200-
// User related stuff
201-
if (this.CURRENT_USER != null) {
202-
await this.GET_STAGE_DIRECTION_STYLE_OVERRIDES();
203-
await this.GET_CUE_COLOUR_OVERRIDES();
204-
}
205-
206-
// Get the max page of the saved version of the script
207-
await this.getMaxScriptPage();
208-
209-
// Initialisation of page data
210208
// Initialisation of page data
211209
const storedPage = localStorage.getItem('cueEditPage');
212210
if (storedPage != null) {

client/src/vue_components/show/config/script/ScriptEditor.vue

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -325,29 +325,30 @@ export default {
325325
},
326326
},
327327
async beforeMount() {
328-
// Get the current user
329-
await this.GET_CURRENT_USER();
330-
await this.GET_USER_SETTINGS();
331-
// Config status
332-
await this.GET_SCRIPT_CONFIG_STATUS();
333-
// Show details
334-
await this.GET_ACT_LIST();
335-
await this.GET_SCENE_LIST();
336-
await this.GET_CHARACTER_LIST();
337-
await this.GET_CHARACTER_GROUP_LIST();
338-
// Stage direction styles
339-
await this.GET_STAGE_DIRECTION_STYLES();
340-
// User related stuff
341-
if (this.CURRENT_USER != null) {
342-
await this.GET_STAGE_DIRECTION_STYLE_OVERRIDES();
343-
await this.GET_CUE_COLOUR_OVERRIDES();
344-
}
345-
// Handle script cuts
346-
await this.GET_CUTS();
347-
this.resetCutsToSaved();
328+
await Promise.all([
329+
this.GET_CURRENT_USER()
330+
.then(() => this.GET_USER_SETTINGS())
331+
.then(() => {
332+
if (this.CURRENT_USER != null) {
333+
return Promise.all([
334+
this.GET_STAGE_DIRECTION_STYLE_OVERRIDES(),
335+
this.GET_CUE_COLOUR_OVERRIDES(),
336+
]);
337+
}
338+
return Promise.resolve();
339+
}),
340+
this.GET_SCRIPT_CONFIG_STATUS(),
341+
this.GET_ACT_LIST(),
342+
this.GET_SCENE_LIST(),
343+
this.GET_CHARACTER_LIST(),
344+
this.GET_CHARACTER_GROUP_LIST(),
345+
this.GET_STAGE_DIRECTION_STYLES(),
346+
this.GET_CUTS(),
347+
this.getMaxScriptPage(),
348+
]);
348349
349-
// Get the max page of the saved version of the script
350-
await this.getMaxScriptPage();
350+
// Handle script cuts (depends on GET_CUTS completing)
351+
this.resetCutsToSaved();
351352
352353
// Initialisation of page data
353354
const storedPage = localStorage.getItem('scriptEditPage');

client/src/vue_components/show/config/stage/PropsList.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,7 @@ export default {
337337
...mapGetters(['PROPS_LIST', 'PROP_TYPES', 'IS_SHOW_EDITOR', 'PROP_TYPE_BY_ID']),
338338
},
339339
async mounted() {
340-
await this.GET_PROP_TYPES();
341-
await this.GET_PROPS_LIST();
340+
await Promise.all([this.GET_PROP_TYPES(), this.GET_PROPS_LIST()]);
342341
},
343342
methods: {
344343
resetNewPropTypeForm() {

client/src/vue_components/show/config/stage/SceneryList.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@ export default {
348348
...mapGetters(['SCENERY_LIST', 'SCENERY_TYPES', 'IS_SHOW_EDITOR', 'SCENERY_TYPE_BY_ID']),
349349
},
350350
async mounted() {
351-
await this.GET_SCENERY_TYPES();
352-
await this.GET_SCENERY_LIST();
351+
await Promise.all([this.GET_SCENERY_TYPES(), this.GET_SCENERY_LIST()]);
353352
},
354353
methods: {
355354
resetNewSceneryTypeForm() {

0 commit comments

Comments
 (0)