FIX: ensures we have a post (#63)

FIX: ensures we have a post (#63)

This could fail in specific cases like discourse-styleguide where we don’t get a real post.

diff --git a/assets/javascripts/initializers/discourse-group-timezones.js.es6 b/assets/javascripts/initializers/discourse-group-timezones.js.es6
index c199c16..79cc43a 100644
--- a/assets/javascripts/initializers/discourse-group-timezones.js.es6
+++ b/assets/javascripts/initializers/discourse-group-timezones.js.es6
@@ -53,8 +53,11 @@ export default {
       function _attachPostWithGroupTimezones($elem, helper) {
         if (helper) {
           const post = helper.getModel();
-          api.preventCloak(post.id);
-          _attachGroupTimezones($elem, post);
+
+          if (post) {
+            api.preventCloak(post.id);
+            _attachGroupTimezones($elem, post);
+          }
         }
       }
 
diff --git a/assets/javascripts/initializers/discourse-post-event-decorator.js.es6 b/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
index f89641e..083271a 100644
--- a/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
+++ b/assets/javascripts/initializers/discourse-post-event-decorator.js.es6
@@ -195,7 +195,7 @@ function initializeDiscoursePostEventDecorator(api) {
       if (helper) {
         const post = helper.getModel();
 
-        if (post.event) {
+        if (post?.event) {
           _decorateEvent(api, cooked, post.event);
         }
       }

GitHub sha: e2445e1d

This commit appears in #63 which was approved by ZogStriP. It was merged by jjaffeux.