diff --git a/js/src/forum/components/UserPoliciesStateModal.js b/js/src/forum/components/UserPoliciesStateModal.js index d602f26..3aac9a8 100644 --- a/js/src/forum/components/UserPoliciesStateModal.js +++ b/js/src/forum/components/UserPoliciesStateModal.js @@ -2,29 +2,10 @@ import app from 'flarum/forum/app'; import humanTime from 'flarum/common/helpers/humanTime'; import Modal from 'flarum/common/components/Modal'; import sortByAttribute from '../../common/helpers/sortByAttribute'; -import LoadingIndicator from 'flarum/common/components/LoadingIndicator'; /* global m */ export default class UserPoliciesStateModal extends Modal { - user = null; - loading = false; - - oninit(vnode) { - super.oninit(vnode); - - if (this.attrs.user.fofTermsPoliciesState() === undefined) { - this.loading = true; - app.store.find('users', this.attrs.user.id()).then((user) => { - this.user = user; - this.loading = false; - m.redraw(); - }); - } else { - this.user = this.attrs.user; - } - } - title() { return app.translator.trans('fof-terms.forum.state-modal.title', { username: this.attrs.user.username(), @@ -32,20 +13,12 @@ export default class UserPoliciesStateModal extends Modal { } content() { - if (this.loading) { - return ( -
- -
- ); - } - return m( '.Modal-body', m( 'ul', sortByAttribute(app.store.all('fof-terms-policies')).map((policy) => { - const state = this.user.fofTermsPoliciesState()[policy.id()]; + const state = this.attrs.user.fofTermsPoliciesState()[policy.id()]; return m('li', [ policy.name() + ': ', diff --git a/src/Extenders/UserPoliciesRelationship.php b/src/Extenders/UserPoliciesRelationship.php index 1412e25..fc24b7f 100644 --- a/src/Extenders/UserPoliciesRelationship.php +++ b/src/Extenders/UserPoliciesRelationship.php @@ -12,7 +12,6 @@ namespace FoF\Terms\Extenders; use Flarum\Api\Serializer\BasicUserSerializer; -use Flarum\Api\Serializer\CurrentUserSerializer; use Flarum\User\User; use FoF\Terms\Repositories\PolicyRepository; @@ -30,13 +29,8 @@ public function __construct(PolicyRepository $policies) public function __invoke(BasicUserSerializer $serializer, User $user, array $attributes) { - $request = $serializer->getRequest(); - - if ($request->getAttribute('routeName') === 'users.show' && $serializer->getActor()->can('seeFoFTermsPoliciesState', $user)) { + if ($serializer->getActor()->can('seeFoFTermsPoliciesState', $user)) { $attributes['fofTermsPoliciesState'] = $this->policies->state($user); - } - - if ($serializer instanceof CurrentUserSerializer) { $attributes['fofTermsPoliciesHasUpdate'] = $this->policies->hasPoliciesUpdate($user); $attributes['fofTermsPoliciesMustAccept'] = $this->policies->mustAcceptNewPolicies($user); }