Rename the stanza
TTL to stx
to avoid name clashes
This commit is contained in:
parent
c5588e3c49
commit
f1cc8c85f4
@ -762,7 +762,7 @@ Object.assign(converse, {
|
|||||||
log,
|
log,
|
||||||
sizzle,
|
sizzle,
|
||||||
sprintf,
|
sprintf,
|
||||||
stanza: u.stanza,
|
stx: u.stx,
|
||||||
u,
|
u,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,7 +16,7 @@ import { Strophe } from 'strophe.js/src/strophe.js';
|
|||||||
import { getOpenPromise } from '@converse/openpromise';
|
import { getOpenPromise } from '@converse/openpromise';
|
||||||
import { setUserJID, } from '@converse/headless/utils/init.js';
|
import { setUserJID, } from '@converse/headless/utils/init.js';
|
||||||
import { settings_api } from '@converse/headless/shared/settings/api.js';
|
import { settings_api } from '@converse/headless/shared/settings/api.js';
|
||||||
import { stanza, toStanza } from './stanza.js';
|
import { stx , toStanza } from './stanza.js';
|
||||||
|
|
||||||
export function isEmptyMessage (attrs) {
|
export function isEmptyMessage (attrs) {
|
||||||
if (attrs instanceof Model) {
|
if (attrs instanceof Model) {
|
||||||
@ -577,5 +577,5 @@ export default Object.assign({
|
|||||||
isEmptyMessage,
|
isEmptyMessage,
|
||||||
getUniqueId,
|
getUniqueId,
|
||||||
toStanza,
|
toStanza,
|
||||||
stanza,
|
stx,
|
||||||
}, u);
|
}, u);
|
||||||
|
@ -11,7 +11,13 @@ export function toStanza (string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function stanza (strings, ...values) {
|
/**
|
||||||
|
* Tagged template literal function which can be used to generate XML stanzas.
|
||||||
|
* Similar to the `html` function, from Lit.
|
||||||
|
*
|
||||||
|
* @example stx`<presence type="${type}"><show>${show}</show></presence>`
|
||||||
|
*/
|
||||||
|
export function stx (strings, ...values) {
|
||||||
return toStanza(
|
return toStanza(
|
||||||
strings.reduce((acc, str) => {
|
strings.reduce((acc, str) => {
|
||||||
const idx = strings.indexOf(str);
|
const idx = strings.indexOf(str);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*global mock, converse */
|
/*global mock, converse */
|
||||||
|
|
||||||
const { $msg, $pres, Strophe, u, stanza } = converse.env;
|
const { $msg, $pres, Strophe, u, stx } = converse.env;
|
||||||
|
|
||||||
describe("A Groupchat Message", function () {
|
describe("A Groupchat Message", function () {
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ describe('A Groupchat Message XEP-0308 correction ', function () {
|
|||||||
|
|
||||||
const msg_id = u.getUniqueId();
|
const msg_id = u.getUniqueId();
|
||||||
await model.handleMessageStanza(
|
await model.handleMessageStanza(
|
||||||
stanza`
|
stx`
|
||||||
<message
|
<message
|
||||||
from="lounge@montague.lit/newguy"
|
from="lounge@montague.lit/newguy"
|
||||||
to="_converse.connection.jid"
|
to="_converse.connection.jid"
|
||||||
@ -291,7 +291,7 @@ describe('A Groupchat Message XEP-0308 correction ', function () {
|
|||||||
expect(model.messages.at(0).get('body')).toBe('But soft, what light through yonder airlock breaks?');
|
expect(model.messages.at(0).get('body')).toBe('But soft, what light through yonder airlock breaks?');
|
||||||
|
|
||||||
await model.handleMessageStanza(
|
await model.handleMessageStanza(
|
||||||
stanza`
|
stx`
|
||||||
<message
|
<message
|
||||||
from="lounge@montague.lit/newguy"
|
from="lounge@montague.lit/newguy"
|
||||||
to="_converse.connection.jid"
|
to="_converse.connection.jid"
|
||||||
@ -312,7 +312,7 @@ describe('A Groupchat Message XEP-0308 correction ', function () {
|
|||||||
expect(model.messages.at(1).get('edited')).toBeFalsy();
|
expect(model.messages.at(1).get('edited')).toBeFalsy();
|
||||||
|
|
||||||
await model.handleMessageStanza(
|
await model.handleMessageStanza(
|
||||||
stanza`
|
stx`
|
||||||
<message
|
<message
|
||||||
from="lounge@montague.lit/newguy"
|
from="lounge@montague.lit/newguy"
|
||||||
to="_converse.connection.jid"
|
to="_converse.connection.jid"
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
/*global mock, converse */
|
/*global mock, converse */
|
||||||
|
|
||||||
const { $pres, $iq, Strophe, sizzle, u } = converse.env;
|
const { $pres, $iq, Strophe, sizzle, u, stx } = converse.env;
|
||||||
|
|
||||||
describe("A MUC", function () {
|
describe("A MUC", function () {
|
||||||
|
|
||||||
it("allows you to change your nickname via a modal",
|
it("allows you to change your nickname via a modal",
|
||||||
mock.initConverse([], {'view_mode': 'fullscreen'}, async function (_converse) {
|
mock.initConverse([], {'view_mode': 'fullscreen'}, async function (_converse) {
|
||||||
|
|
||||||
const { stanza } = converse.env;
|
|
||||||
const muc_jid = 'lounge@montague.lit';
|
const muc_jid = 'lounge@montague.lit';
|
||||||
const nick = 'romeo';
|
const nick = 'romeo';
|
||||||
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, nick);
|
const model = await mock.openAndEnterChatRoom(_converse, muc_jid, nick);
|
||||||
@ -39,7 +38,7 @@ describe("A MUC", function () {
|
|||||||
|
|
||||||
// Two presence stanzas are received from the MUC service
|
// Two presence stanzas are received from the MUC service
|
||||||
_converse.connection._dataRecv(mock.createRequest(
|
_converse.connection._dataRecv(mock.createRequest(
|
||||||
stanza`
|
stx`
|
||||||
<presence
|
<presence
|
||||||
from='${muc_jid}/${nick}'
|
from='${muc_jid}/${nick}'
|
||||||
id='DC352437-C019-40EC-B590-AF29E879AF98'
|
id='DC352437-C019-40EC-B590-AF29E879AF98'
|
||||||
@ -59,7 +58,7 @@ describe("A MUC", function () {
|
|||||||
expect(model.get('nick')).toBe(newnick);
|
expect(model.get('nick')).toBe(newnick);
|
||||||
|
|
||||||
_converse.connection._dataRecv(mock.createRequest(
|
_converse.connection._dataRecv(mock.createRequest(
|
||||||
stanza`
|
stx`
|
||||||
<presence
|
<presence
|
||||||
from='${muc_jid}/${newnick}'
|
from='${muc_jid}/${newnick}'
|
||||||
id='5B4F27A4-25ED-43F7-A699-382C6B4AFC67'
|
id='5B4F27A4-25ED-43F7-A699-382C6B4AFC67'
|
||||||
|
Loading…
Reference in New Issue
Block a user