From 993a1bbd43681ec959e1c7954323ba63bff0d116 Mon Sep 17 00:00:00 2001 From: Keegan George Date: Mon, 8 Aug 2022 12:21:30 -0700 Subject: [PATCH] FIX: Use `canEdit` property rather than comparing user (#6) * FIX: Use `canEdit` property rather than comparing user * DEV: Remove unused currentUser variable --- javascripts/discourse/api-initializers/table-editor.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/javascripts/discourse/api-initializers/table-editor.js b/javascripts/discourse/api-initializers/table-editor.js index 3de1cfb..5e07b01 100644 --- a/javascripts/discourse/api-initializers/table-editor.js +++ b/javascripts/discourse/api-initializers/table-editor.js @@ -9,7 +9,6 @@ import { popupAjaxError } from "discourse/lib/ajax-error"; export default apiInitializer("0.11.1", (api) => { const site = api.container.lookup("site:main"); - const currentUser = api.getCurrentUser(); function createButton() { const openPopupBtn = document.createElement("button"); @@ -69,9 +68,9 @@ export default apiInitializer("0.11.1", (api) => { api.decorateCookedElement( (post, helper) => { - const postOwner = helper.widget.attrs.username; + const canEdit = helper.widget.attrs.canEdit; - if (postOwner !== currentUser.username) { + if (!canEdit) { return; }