Make collection list loading async

This commit is contained in:
2026-06-30 16:14:08 +02:00
parent 96a5a6ac34
commit f2e531c0f6
6 changed files with 333 additions and 157 deletions

View File

@@ -4,14 +4,23 @@ import { service } from '@ember/service';
export default class ListsListRoute extends Route {
@service storage;
async model(params) {
const listId = params.list_id;
try {
const places = await this.storage.getPlacesInList(listId);
return { listId, places };
} catch (e) {
console.error('Failed to load places in list', listId, e);
return { listId, places: [] };
model(params) {
// Resolve instantly so transition happens in 0ms!
return { list_id: params.list_id };
}
setupController(controller, model) {
console.debug('DEBUG: setupController controller is:', controller);
console.debug(
'DEBUG: controller.loadPlacesTask is:',
controller?.loadPlacesTask
);
controller.model = model;
super.setupController(controller, model);
if (controller && controller.loadPlacesTask) {
controller.loadPlacesTask.perform(model.list_id);
} else {
console.error('DEBUG: ERROR! controller.loadPlacesTask is undefined!');
}
}
}