_converse.api.alert.show
is now _converse.api.show
Instead of taking an integer for the `type`, "info", "warn" or "error" should be passed in.
This commit is contained in:
parent
17dfa3d7ba
commit
23797dee21
|
@ -35,6 +35,8 @@
|
||||||
|
|
||||||
- The `show_only_online_users` setting has been removed.
|
- The `show_only_online_users` setting has been removed.
|
||||||
- The order of certain events have now changed: `statusInitialized` is now triggered after `initialized` and `connected` and `reconnected`.
|
- The order of certain events have now changed: `statusInitialized` is now triggered after `initialized` and `connected` and `reconnected`.
|
||||||
|
- `_converse.api.alert.show` is now `_converse.api.show` and instead of taking
|
||||||
|
an integer for the `type`, "info", "warn" or "error" should be passed in.
|
||||||
|
|
||||||
## 5.0.4 (2019-10-08)
|
## 5.0.4 (2019-10-08)
|
||||||
- New config option [allow_message_corrections](https://conversejs.org/docs/html/configuration.html#allow-message-corrections)
|
- New config option [allow_message_corrections](https://conversejs.org/docs/html/configuration.html#allow-message-corrections)
|
||||||
|
|
|
@ -207,13 +207,10 @@ converse.plugins.add('converse-chatview', {
|
||||||
() => this.model.contact.destroy(),
|
() => this.model.contact.destroy(),
|
||||||
(err) => {
|
(err) => {
|
||||||
_converse.log(err, Strophe.LogLevel.ERROR);
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
_converse.api.alert.show(
|
_converse.api.alert('error', __('Error'), [
|
||||||
Strophe.LogLevel.ERROR,
|
__('Sorry, there was an error while trying to remove %1$s as a contact.',
|
||||||
__('Error'),
|
this.model.contact.getDisplayName())
|
||||||
[__('Sorry, there was an error while trying to remove %1$s as a contact.',
|
]);
|
||||||
this.model.contact.getDisplayName())
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
import "backbone.vdomview";
|
import "backbone.vdomview";
|
||||||
import bootstrap from "bootstrap.native";
|
import bootstrap from "bootstrap.native";
|
||||||
import converse from "@converse/headless/converse-core";
|
import converse from "@converse/headless/converse-core";
|
||||||
|
import { isString } from "lodash";
|
||||||
import tpl_alert from "templates/alert.html";
|
import tpl_alert from "templates/alert.html";
|
||||||
import tpl_alert_modal from "templates/alert_modal.html";
|
import tpl_alert_modal from "templates/alert_modal.html";
|
||||||
|
|
||||||
const { Strophe, Backbone, sizzle, _ } = converse.env;
|
const { Backbone, sizzle } = converse.env;
|
||||||
const u = converse.env.utils;
|
const u = converse.env.utils;
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,35 +107,40 @@ converse.plugins.add('converse-modal', {
|
||||||
let alert;
|
let alert;
|
||||||
|
|
||||||
Object.assign(_converse.api, {
|
Object.assign(_converse.api, {
|
||||||
'alert': {
|
/**
|
||||||
show (type, title, messages) {
|
* Show an alert modal to the user.
|
||||||
if (_.isString(messages)) {
|
* @method _converse.api.alert
|
||||||
messages = [messages];
|
* @param { ('info'|'warn'|'error') } type - The type of alert.
|
||||||
}
|
* @returns { String } title - The header text for the alert.
|
||||||
if (type === Strophe.LogLevel.ERROR) {
|
* @returns { (String[]|String) } messages - The alert text to show to the user.
|
||||||
type = 'alert-danger';
|
*/
|
||||||
} else if (type === Strophe.LogLevel.INFO) {
|
alert (type, title, messages) {
|
||||||
type = 'alert-info';
|
if (isString(messages)) {
|
||||||
} else if (type === Strophe.LogLevel.WARN) {
|
messages = [messages];
|
||||||
type = 'alert-warning';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alert === undefined) {
|
|
||||||
const model = new Backbone.Model({
|
|
||||||
'title': title,
|
|
||||||
'messages': messages,
|
|
||||||
'type': type
|
|
||||||
})
|
|
||||||
alert = new _converse.Alert({'model': model});
|
|
||||||
} else {
|
|
||||||
alert.model.set({
|
|
||||||
'title': title,
|
|
||||||
'messages': messages,
|
|
||||||
'type': type
|
|
||||||
});
|
|
||||||
}
|
|
||||||
alert.show();
|
|
||||||
}
|
}
|
||||||
|
if (type === 'error') {
|
||||||
|
type = 'alert-danger';
|
||||||
|
} else if (type === 'info') {
|
||||||
|
type = 'alert-info';
|
||||||
|
} else if (type === 'warn') {
|
||||||
|
type = 'alert-warning';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (alert === undefined) {
|
||||||
|
const model = new Backbone.Model({
|
||||||
|
'title': title,
|
||||||
|
'messages': messages,
|
||||||
|
'type': type
|
||||||
|
})
|
||||||
|
alert = new _converse.Alert({'model': model});
|
||||||
|
} else {
|
||||||
|
alert.model.set({
|
||||||
|
'title': title,
|
||||||
|
'messages': messages,
|
||||||
|
'type': type
|
||||||
|
});
|
||||||
|
}
|
||||||
|
alert.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ converse.plugins.add('converse-omemo', {
|
||||||
const { _converse } = this.__super__,
|
const { _converse } = this.__super__,
|
||||||
{ __ } = _converse;
|
{ __ } = _converse;
|
||||||
_converse.log(err, Strophe.LogLevel.ERROR);
|
_converse.log(err, Strophe.LogLevel.ERROR);
|
||||||
_converse.api.alert.show(
|
_converse.api.alert(
|
||||||
Strophe.LogLevel.ERROR,
|
Strophe.LogLevel.ERROR,
|
||||||
__('Error'), [__('Sorry, an error occurred while trying to remove the devices.')]
|
__('Error'), [__('Sorry, an error occurred while trying to remove the devices.')]
|
||||||
)
|
)
|
||||||
|
@ -413,10 +413,10 @@ converse.plugins.add('converse-omemo', {
|
||||||
err_msgs.push(__("Unable to send an encrypted message due to an unexpected error."));
|
err_msgs.push(__("Unable to send an encrypted message due to an unexpected error."));
|
||||||
err_msgs.push(e.iq.outerHTML);
|
err_msgs.push(e.iq.outerHTML);
|
||||||
}
|
}
|
||||||
_converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), err_msgs);
|
_converse.api.alert('error', __('Error'), err_msgs);
|
||||||
_converse.log(e, Strophe.LogLevel.ERROR);
|
_converse.log(e, Strophe.LogLevel.ERROR);
|
||||||
} else if (e.user_facing) {
|
} else if (e.user_facing) {
|
||||||
_converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), [e.message]);
|
_converse.api.alert('error', __('Error'), [e.message]);
|
||||||
_converse.log(e, Strophe.LogLevel.ERROR);
|
_converse.log(e, Strophe.LogLevel.ERROR);
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -470,7 +470,7 @@ converse.plugins.add('converse-omemo', {
|
||||||
this.model.contact.getDisplayName()
|
this.model.contact.getDisplayName()
|
||||||
)];
|
)];
|
||||||
}
|
}
|
||||||
return _converse.api.alert.show(Strophe.LogLevel.ERROR, __('Error'), messages);
|
return _converse.api.alert('error', __('Error'), messages);
|
||||||
}
|
}
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this.model.save({'omemo_active': !this.model.get('omemo_active')});
|
this.model.save({'omemo_active': !this.model.get('omemo_active')});
|
||||||
|
|
|
@ -103,13 +103,10 @@ converse.plugins.add('converse-profile', {
|
||||||
.then(() => _converse.api.vcard.update(this.model.vcard, true))
|
.then(() => _converse.api.vcard.update(this.model.vcard, true))
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
_converse.log(err, Strophe.LogLevel.FATAL);
|
_converse.log(err, Strophe.LogLevel.FATAL);
|
||||||
_converse.api.alert.show(
|
_converse.api.show('error', __('Error'), [
|
||||||
Strophe.LogLevel.ERROR,
|
__("Sorry, an error happened while trying to save your profile data."),
|
||||||
__('Error'), [
|
__("You can check your browser's developer console for any error output.")
|
||||||
__("Sorry, an error happened while trying to save your profile data."),
|
]);
|
||||||
__("You can check your browser's developer console for any error output.")
|
|
||||||
]
|
|
||||||
)
|
|
||||||
});
|
});
|
||||||
this.modal.hide();
|
this.modal.hide();
|
||||||
},
|
},
|
||||||
|
|
|
@ -505,11 +505,9 @@ converse.plugins.add('converse-rosterview', {
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
_converse.log(e, Strophe.LogLevel.ERROR);
|
_converse.log(e, Strophe.LogLevel.ERROR);
|
||||||
_converse.api.alert.show(
|
_converse.api.alert('error', __('Error'),
|
||||||
Strophe.LogLevel.ERROR,
|
|
||||||
__('Error'),
|
|
||||||
[__('Sorry, there was an error while trying to remove %1$s as a contact.', this.model.getDisplayName())]
|
[__('Sorry, there was an error while trying to remove %1$s as a contact.', this.model.getDisplayName())]
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,9 @@ converse.plugins.add('converse-bookmarks', {
|
||||||
onBookmarkError (iq, options) {
|
onBookmarkError (iq, options) {
|
||||||
_converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR);
|
_converse.log("Error while trying to add bookmark", Strophe.LogLevel.ERROR);
|
||||||
_converse.log(iq);
|
_converse.log(iq);
|
||||||
_converse.api.alert.show(
|
_converse.api.alert(
|
||||||
Strophe.LogLevel.ERROR,
|
'error', __('Error'), [__("Sorry, something went wrong while trying to save your bookmark.")]
|
||||||
__('Error'), [__("Sorry, something went wrong while trying to save your bookmark.")]
|
);
|
||||||
)
|
|
||||||
this.findWhere({'jid': options.jid}).destroy();
|
this.findWhere({'jid': options.jid}).destroy();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -234,9 +233,7 @@ converse.plugins.add('converse-bookmarks', {
|
||||||
onBookmarksReceivedError (deferred, iq) {
|
onBookmarksReceivedError (deferred, iq) {
|
||||||
if (iq === null) {
|
if (iq === null) {
|
||||||
_converse.log('Error: timeout while fetching bookmarks', Strophe.LogLevel.ERROR);
|
_converse.log('Error: timeout while fetching bookmarks', Strophe.LogLevel.ERROR);
|
||||||
_converse.api.alert.show(
|
_converse.api.alert('error', __('Timeout Error'),
|
||||||
Strophe.LogLevel.ERROR,
|
|
||||||
__('Timeout Error'),
|
|
||||||
[__("The server did not return your bookmarks within the allowed time. "+
|
[__("The server did not return your bookmarks within the allowed time. "+
|
||||||
"You can reload the page to request them again.")]
|
"You can reload the page to request them again.")]
|
||||||
);
|
);
|
||||||
|
|
|
@ -1516,7 +1516,7 @@ converse.plugins.add('converse-chatboxes', {
|
||||||
return chat;
|
return chat;
|
||||||
} else if (Array.isArray(jids)) {
|
} else if (Array.isArray(jids)) {
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
jids.map(j => _converse.api.chats.create(j, attrs).then(c => c ? c.maybeShow(force) : null))
|
jids.map(j => _converse.api.chats.create(j, attrs).then(c => c && c.maybeShow(force)))
|
||||||
.filter(c => c)
|
.filter(c => c)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user