Don't use browser's confirm
dialog when logging out
Refs https://github.com/conversejs/converse-desktop/issues/18
This commit is contained in:
parent
b5bcc05947
commit
a3c0f90476
@ -1,7 +1,6 @@
|
|||||||
import UserSettingsModal from 'modals/user-settings';
|
import UserSettingsModal from 'modals/user-settings';
|
||||||
import tpl_profile from './templates/profile.js';
|
import tpl_profile from './templates/profile.js';
|
||||||
import { CustomElement } from 'shared/components/element.js';
|
import { CustomElement } from 'shared/components/element.js';
|
||||||
import { __ } from 'i18n';
|
|
||||||
import { _converse, api } from '@converse/headless/core';
|
import { _converse, api } from '@converse/headless/core';
|
||||||
|
|
||||||
class Profile extends CustomElement {
|
class Profile extends CustomElement {
|
||||||
@ -31,14 +30,6 @@ class Profile extends CustomElement {
|
|||||||
ev?.preventDefault();
|
ev?.preventDefault();
|
||||||
api.modal.show(UserSettingsModal, {model: this.model, _converse}, ev);
|
api.modal.show(UserSettingsModal, {model: this.model, _converse}, ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
logout (ev) { // eslint-disable-line class-methods-use-this
|
|
||||||
ev?.preventDefault();
|
|
||||||
const result = confirm(__("Are you sure you want to log out?"));
|
|
||||||
if (result === true) {
|
|
||||||
api.user.logout();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api.elements.define('converse-user-profile', Profile);
|
api.elements.define('converse-user-profile', Profile);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import 'shared/avatar/avatar.js';
|
import 'shared/avatar/avatar.js';
|
||||||
import { __ } from 'i18n';
|
import { __ } from 'i18n';
|
||||||
import { _converse, api } from "@converse/headless/core";
|
import { _converse, api } from "@converse/headless/core";
|
||||||
import { getPrettyStatus } from '../utils.js';
|
import { getPrettyStatus, logOut } from '../utils.js';
|
||||||
import { html } from "lit";
|
import { html } from "lit";
|
||||||
|
|
||||||
|
|
||||||
function tpl_signout (o) {
|
function tpl_signout () {
|
||||||
const i18n_logout = __('Log out');
|
const i18n_logout = __('Log out');
|
||||||
return html`<a class="controlbox-heading__btn logout align-self-center" title="${i18n_logout}" @click=${o.logout}>
|
return html`<a class="controlbox-heading__btn logout align-self-center" title="${i18n_logout}" @click=${logOut}>
|
||||||
<converse-icon class="fa fa-sign-out-alt" size="1em"></converse-icon>
|
<converse-icon class="fa fa-sign-out-alt" size="1em"></converse-icon>
|
||||||
</a>`
|
</a>`
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ export default (el) => {
|
|||||||
</a>
|
</a>
|
||||||
<span class="username w-100 align-self-center">${fullname}</span>
|
<span class="username w-100 align-self-center">${fullname}</span>
|
||||||
${show_settings_button ? tpl_user_settings_button(el) : ''}
|
${show_settings_button ? tpl_user_settings_button(el) : ''}
|
||||||
${api.settings.get('allow_logout') ? tpl_signout(el) : ''}
|
${api.settings.get('allow_logout') ? tpl_signout() : ''}
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex xmpp-status">
|
<div class="d-flex xmpp-status">
|
||||||
<a class="change-status" title="${i18n_change_status}" data-toggle="modal" data-target="#changeStatusModal" @click=${el.showStatusChangeModal}>
|
<a class="change-status" title="${i18n_change_status}" data-toggle="modal" data-target="#changeStatusModal" @click=${el.showStatusChangeModal}>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { __ } from 'i18n';
|
import { __ } from 'i18n';
|
||||||
|
import { api } from '@converse/headless/core';
|
||||||
|
|
||||||
export function getPrettyStatus (stat) {
|
export function getPrettyStatus (stat) {
|
||||||
if (stat === 'chat') {
|
if (stat === 'chat') {
|
||||||
@ -15,3 +16,11 @@ export function getPrettyStatus (stat) {
|
|||||||
return __(stat) || __('online');
|
return __(stat) || __('online');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function logOut (ev) {
|
||||||
|
ev?.preventDefault();
|
||||||
|
const result = await api.confirm(__("Are you sure you want to log out?"));
|
||||||
|
if (result) {
|
||||||
|
api.user.logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user