Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
c82e3e9b
Commit
c82e3e9b
authored
Jun 03, 2020
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `api.vcard.set` to also update the VCard model
parent
b4e4248f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
src/converse-profile.js
src/converse-profile.js
+8
-7
src/headless/converse-vcard.js
src/headless/converse-vcard.js
+24
-2
No files found.
src/converse-profile.js
View file @
c82e3e9b
...
...
@@ -83,16 +83,17 @@ converse.plugins.add('converse-profile', {
reader
.
readAsDataURL
(
file
);
},
setVCard
(
data
)
{
api
.
vcard
.
set
(
_converse
.
bare_jid
,
data
)
.
then
(()
=>
api
.
vcard
.
update
(
this
.
model
.
vcard
,
true
))
.
catch
((
err
)
=>
{
async
setVCard
(
data
)
{
try
{
await
api
.
vcard
.
set
(
_converse
.
bare_jid
,
data
);
}
catch
(
err
)
{
log
.
fatal
(
err
);
api
.
show
(
'
error
'
,
__
(
'
Error
'
),
[
this
.
alert
(
[
__
(
"
Sorry, an error happened while trying to save your profile data.
"
),
__
(
"
You can check your browser's developer console for any error output.
"
)
]);
});
].
join
(
"
"
));
return
;
}
this
.
modal
.
hide
();
},
...
...
src/headless/converse-vcard.js
View file @
c82e3e9b
...
...
@@ -67,6 +67,12 @@ converse.plugins.add('converse-vcard', {
api
.
promises
.
add
(
'
VCardsInitialized
'
);
/**
* Represents a VCard
* @class
* @namespace _converse.VCard
* @memberOf _converse
*/
_converse
.
VCard
=
Model
.
extend
({
defaults
:
{
'
image
'
:
_converse
.
DEFAULT_IMAGE
,
...
...
@@ -268,6 +274,10 @@ converse.plugins.add('converse-vcard', {
/**
* Enables setting new values for a VCard.
*
* Sends out an IQ stanza to set the user's VCard and if
* successful, it updates the {@link _converse.VCard}
* for the passed in JID.
*
* @method _converse.api.vcard.set
* @param {string} jid The JID for which the VCard should be set
* @param {object} data A map of VCard keys and values
...
...
@@ -282,12 +292,19 @@ converse.plugins.add('converse-vcard', {
* // Failure
* }).
*/
set
(
jid
,
data
)
{
async
set
(
jid
,
data
)
{
if
(
!
jid
)
{
throw
Error
(
"
No jid provided for the VCard data
"
);
}
const
vcard_el
=
Strophe
.
xmlHtmlNode
(
tpl_vcard
(
data
)).
firstElementChild
;
return
api
.
sendIQ
(
createStanza
(
"
set
"
,
jid
,
vcard_el
));
let
result
;
try
{
result
=
await
api
.
sendIQ
(
createStanza
(
"
set
"
,
jid
,
vcard_el
));
}
catch
(
e
)
{
throw
(
e
);
}
await
api
.
vcard
.
update
(
jid
,
true
);
return
result
;
},
/**
...
...
@@ -345,6 +362,11 @@ converse.plugins.add('converse-vcard', {
*/
async
update
(
model
,
force
)
{
const
data
=
await
this
.
get
(
model
,
force
);
model
=
isString
(
model
)
?
_converse
.
vcards
.
findWhere
({
'
jid
'
:
model
})
:
model
;
if
(
!
model
)
{
log
.
error
(
`Could not find a VCard model for
${
model
}
`
);
return
;
}
delete
data
[
'
stanza
'
]
model
.
save
(
data
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment