Skip to content

Commit

Permalink
remove logic from template
Browse files Browse the repository at this point in the history
  • Loading branch information
udanieli committed May 31, 2023
1 parent dacc9ea commit ea3c51e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 9 additions & 0 deletions src/plugins/profile/modals/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ export default class ProfileModal extends BaseModal {
});
}
}

async isBlockingAvailable() {
if (_converse.pluggable.plugins['converse-blocking']?.enabled(_converse)) {
const is_available = await api.isBlockingAvailable();
return is_available;
}

return false;
}
}

api.elements.define('converse-profile-modal', ProfileModal);
8 changes: 3 additions & 5 deletions src/plugins/profile/templates/profile_modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "shared/components/image-picker.js";
import { __ } from 'i18n';
import { _converse, api } from "@converse/headless/core";
import { _converse } from "@converse/headless/core";
import { html } from "lit";


Expand Down Expand Up @@ -57,9 +57,7 @@ export default (el) => {
</li>`
);

const blocking_available = (_converse.pluggable.plugins['converse-blocking']?.enabled(_converse) && api.isBlockingAvailable());

if (blocking_available) {
if (el.isBlockingAvailable()) {
navigation_tabs.push(html`<li role="presentation" class="nav-item">
<a class="nav-link ${el.tab === "blockedusers" ? "active" : ""}"
id="blockedusers-tab"
Expand Down Expand Up @@ -135,7 +133,7 @@ export default (el) => {
${ el.tab === 'passwordreset' ? html`<converse-change-password-form></converse-change-password-form>` : '' }
</div>
${blocking_available ? tplBlockUsersPage(el) : '' }
${el.isBlockingAvailable() ? tplBlockUsersPage(el) : '' }
${ _converse.pluggable.plugins['converse-omemo']?.enabled(_converse) ? tplOmemoPage(el) : '' }
</div>
</div>`;
Expand Down

0 comments on commit ea3c51e

Please sign in to comment.