Skip to content

Commit 014391b

Browse files
committed
component: ConnectedVideoList: refactor getLoadFn
- enclose shared query inside async return - move shared variable "res" outside if/else scope to allow change in next commit
1 parent cd79d97 commit 014391b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/components/video/ConnectedVideoList.vue

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,12 @@ export default {
426426
}),
427427
max_upcoming_hours: 1,
428428
};
429+
return async (offset: any, limit: any) => {
430+
let res = null;
431+
// Handle backend query depending on page
429432
if (this.isFavPage) {
430-
return async (offset, limit) => {
431-
const res = await backendApi
433+
// Favourites Page
434+
res = await backendApi
432435
.favoritesVideos(this.$store.state.userdata.jwt, {
433436
...query,
434437
limit,
@@ -439,18 +442,18 @@ export default {
439442
this.$store.dispatch("loginVerify", { bounceToLogin: true }); // check if the user is actually logged in.
440443
throw err;
441444
});
442-
return res.data;
443-
};
444-
}
445-
// home page function
446-
return async (offset, limit) => {
447-
const res = await backendApi.videos({
445+
} else {
446+
// Home Page
447+
res = await backendApi
448+
.videos({
448449
...query,
449450
org: this.$store.state.currentOrg.name,
450451
limit,
451452
offset,
452453
});
453-
return res.data;
454+
}
455+
456+
return res?.data;
454457
};
455458
},
456459
},

0 commit comments

Comments
 (0)