From b04fd88cc222cd5f628c77b7e87c6536842d6df1 Mon Sep 17 00:00:00 2001
From: Eugen Ciur <eugen@papermerge.com>
Date: Wed, 23 Feb 2022 20:52:56 +0100
Subject: [PATCH] fix tag refresh issue

---
 app/components/tag/table_row.js |  6 +++++-
 app/routes/application.js       |  5 -----
 app/routes/authenticated.js     | 11 +++++++++++
 3 files changed, 16 insertions(+), 6 deletions(-)
 create mode 100644 app/routes/authenticated.js

diff --git a/app/components/tag/table_row.js b/app/components/tag/table_row.js
index 8df00e9..248c793 100644
--- a/app/components/tag/table_row.js
+++ b/app/components/tag/table_row.js
@@ -9,6 +9,7 @@ export default class TableRowComponent extends Component {
   // being edited i.e. in edit mode
   @tracked edit_mode_id = 0;
   @service store;
+  @service router;
 
   @action
   async onRemove(tag) {
@@ -40,7 +41,10 @@ export default class TableRowComponent extends Component {
       this.store.findRecord('tag', tag.id).then((found_tag) => {
         found_tag.name = tag.name;
         found_tag.description = tag.description;
-        found_tag.save();
+        found_tag.save().then(() => {
+          // refresh pinned tags on the sidebar
+          that.router.refresh();
+        });
       });
     } else {
       console.warn(`onSaveChanges received tag=${tag} object without tag ID`);
diff --git a/app/routes/application.js b/app/routes/application.js
index 5d98cac..6734f7b 100644
--- a/app/routes/application.js
+++ b/app/routes/application.js
@@ -3,9 +3,4 @@ import BaseRoute from 'papermerge/routes/base';
 
 export default class ApplicationRoute extends BaseRoute {
 
-  async model() {
-    return this.store.findAll('tag').then((tags) => {
-      return tags.filter(tag => tag.pinned);
-    });
-  }
 }
diff --git a/app/routes/authenticated.js b/app/routes/authenticated.js
new file mode 100644
index 0000000..3aeff0a
--- /dev/null
+++ b/app/routes/authenticated.js
@@ -0,0 +1,11 @@
+import BaseRoute from 'papermerge/routes/base';
+
+
+export default class AuthenticatedRoute extends BaseRoute {
+
+  async model() {
+    return this.store.findAll('tag').then((tags) => {
+      return tags.filter(tag => tag.pinned);
+    });
+  }
+}
-- 
GitLab