From d6d5dd28eda913c4327a0527b09b56d9d1741d5b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= <skunk@xover.mud.at>
Date: Sat, 2 Jan 2021 13:33:35 +0100
Subject: [PATCH] ObjectDisplay: update body content from category update

---
 src/ObjectDisplay.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/ObjectDisplay.js b/src/ObjectDisplay.js
index b637f7e2..3f047c73 100644
--- a/src/ObjectDisplay.js
+++ b/src/ObjectDisplay.js
@@ -4,6 +4,8 @@ const displayBlock = require('./displayBlock')
 
 module.exports = class ObjectDisplay {
   constructor ({feature, category, dom, displayId, fallbackIds}, callback) {
+    this.category = category
+
     if (!fallbackIds) {
       fallbackIds = []
     }
@@ -49,6 +51,13 @@ module.exports = class ObjectDisplay {
       body.innerHTML = result
       feature.sublayer.updateAssets(body, feature)
     })
+
+    category.on('update', this.updateListener = () => {
+      category.renderTemplate(feature, displayId + 'Body', (err, result) => {
+        body.innerHTML = result
+        feature.sublayer.updateAssets(body, feature)
+      })
+    })
     
     displayBlock({
       dom,
@@ -104,6 +113,9 @@ module.exports = class ObjectDisplay {
   }
 
   close () {
+    if (this.updateListener) {
+      this.category.off('update', this.updateListener)
+    }
   }
 }