FIX: Use `canEdit` property rather than comparing user (#6)
* FIX: Use `canEdit` property rather than comparing user * DEV: Remove unused currentUser variable
This commit is contained in:
parent
695980a250
commit
993a1bbd43
|
@ -9,7 +9,6 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
|
|
||||||
export default apiInitializer("0.11.1", (api) => {
|
export default apiInitializer("0.11.1", (api) => {
|
||||||
const site = api.container.lookup("site:main");
|
const site = api.container.lookup("site:main");
|
||||||
const currentUser = api.getCurrentUser();
|
|
||||||
|
|
||||||
function createButton() {
|
function createButton() {
|
||||||
const openPopupBtn = document.createElement("button");
|
const openPopupBtn = document.createElement("button");
|
||||||
|
@ -69,9 +68,9 @@ export default apiInitializer("0.11.1", (api) => {
|
||||||
|
|
||||||
api.decorateCookedElement(
|
api.decorateCookedElement(
|
||||||
(post, helper) => {
|
(post, helper) => {
|
||||||
const postOwner = helper.widget.attrs.username;
|
const canEdit = helper.widget.attrs.canEdit;
|
||||||
|
|
||||||
if (postOwner !== currentUser.username) {
|
if (!canEdit) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue