From 478ba50282b2d4e0af411a8dc73dc5ae408d184c Mon Sep 17 00:00:00 2001 From: Eugen Ciur <eugen@papermerge.com> Date: Sun, 31 Oct 2021 13:52:41 +0100 Subject: [PATCH] fix minor bug --- app/adapters/application.js | 3 ++- app/routes/authenticated/index.js | 23 ++++------------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/app/adapters/application.js b/app/adapters/application.js index fa01ec2..962b6b7 100644 --- a/app/adapters/application.js +++ b/app/adapters/application.js @@ -2,6 +2,7 @@ import JSONAPIAdapter from '@ember-data/adapter/json-api'; import { computed } from '@ember/object'; import { inject as service } from '@ember/service'; + export default class ApplicationAdapter extends JSONAPIAdapter { namespace = 'api'; host = 'http://127.0.0.1:8000'; @@ -19,7 +20,7 @@ export default class ApplicationAdapter extends JSONAPIAdapter { // or a Document if (modelName == 'folder') { return 'nodes'; - } else if (modeName == 'document') { + } else if (modelName == 'document') { return 'nodes'; } diff --git a/app/routes/authenticated/index.js b/app/routes/authenticated/index.js index 0ddce9e..69ee43e 100644 --- a/app/routes/authenticated/index.js +++ b/app/routes/authenticated/index.js @@ -1,6 +1,7 @@ import { inject as service } from '@ember/service'; import BaseRoute from 'papermerge/base/routing'; + export default class IndexRoute extends BaseRoute { @service store; @service currentUser; @@ -13,27 +14,11 @@ export default class IndexRoute extends BaseRoute { if (!params.node_id) { // when node_id is not provided, use as default // user's home folder ID. - return adapter.findNode(this.home_folder_id); + return this.currentUser.user.home_folder.then((home_folder) => { + return adapter.findNode(home_folder.id); + }); } return adapter.findNode(params.node_id); } - - get home_folder_id() { - /* - Another way to get home folder would be: - - this.currentUser.user.get('home_folder').get('id') - - However, last call will issue following background http API call: - - GET /api/folders/<folder_id>/. - - The workaround/the trick to avoid this background call, is to - convert user to json object, and then just get `home_folder` attribute - which is just an id. - */ - let user_json = this.currentUser.user.toJSON(); - return user_json['home_folder']; - } } -- GitLab