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
c1be16aa
Commit
c1be16aa
authored
Jul 19, 2016
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix. Store and find occupant views by id, not jid
because we don't always have a jid...
parent
93a8dfc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
25 deletions
+36
-25
src/converse-muc.js
src/converse-muc.js
+36
-25
No files found.
src/converse-muc.js
View file @
c1be16aa
...
...
@@ -1069,9 +1069,9 @@
},
onOccupantAdded
:
function
(
item
)
{
var
view
=
this
.
get
(
item
.
get
(
'
j
id
'
));
var
view
=
this
.
get
(
item
.
get
(
'
id
'
));
if
(
!
view
)
{
view
=
this
.
add
(
item
.
get
(
'
j
id
'
),
new
converse
.
ChatRoomOccupantView
({
model
:
item
}));
view
=
this
.
add
(
item
.
get
(
'
id
'
),
new
converse
.
ChatRoomOccupantView
({
model
:
item
}));
}
else
{
delete
view
.
model
;
// Remove ref to old model to help garbage collection
view
.
model
=
item
;
...
...
@@ -1117,22 +1117,30 @@
return
data
;
},
updateOccupantsOnPresence
:
function
(
pres
)
{
var
occupant
,
attributes
;
var
data
=
this
.
parsePresence
(
pres
);
if
(
data
.
type
===
'
error
'
)
{
return
true
;
}
// If we have a JID, we use that to look up the user,
// otherwise we use the nick. We don't always have both,
// but should have at least one or the other.
findOccupant
:
function
(
data
)
{
/* Try to find an existing occupant based on the passed in
* data object.
*
* If we have a JID, we use that as lookup variable,
* otherwise we use the nick. We don't always have both,
* but should have at least one or the other.
*/
var
jid
=
Strophe
.
getBareJidFromJid
(
data
.
jid
);
if
(
jid
!==
null
)
{
occupant
=
this
.
model
.
where
({
'
jid
'
:
jid
}).
pop
();
return
this
.
model
.
where
({
'
jid
'
:
jid
}).
pop
();
}
else
{
occupant
=
this
.
model
.
where
({
'
nick
'
:
data
.
nick
}).
pop
();
return
this
.
model
.
where
({
'
nick
'
:
data
.
nick
}).
pop
();
}
},
updateOccupantsOnPresence
:
function
(
pres
)
{
var
attributes
;
var
data
=
this
.
parsePresence
(
pres
);
var
jid
=
Strophe
.
getBareJidFromJid
(
data
.
jid
);
if
(
data
.
type
===
'
error
'
)
{
return
true
;
}
var
occupant
=
this
.
findOccupant
(
data
);
switch
(
data
.
type
)
{
case
'
unavailable
'
:
if
(
_
.
contains
([
'
owner
'
,
'
admin
'
,
'
member
'
],
occupant
.
get
(
'
affiliation
'
)))
{
...
...
@@ -1156,18 +1164,21 @@
},
updateOccupantsOnMembersList
:
function
(
iq
)
{
/* <iq from='coven@chat.shakespeare.lit'
id='member3'
to='crone1@shakespeare.lit/desktop'
type='result'>
<query xmlns='http://jabber.org/protocol/muc#admin'>
<item affiliation='member'
jid='hag66@shakespeare.lit'
nick='thirdwitch'
role='participant'/>
</query>
</iq>
*/
/* Create occupants based upon a received IQ stanza
* containing a member-list.
*
* <iq from='coven@chat.shakespeare.lit'
* id='member3'
* to='crone1@shakespeare.lit/desktop'
* type='result'>
* <query xmlns='http://jabber.org/protocol/muc#admin'>
* <item affiliation='member'
* jid='hag66@shakespeare.lit'
* nick='thirdwitch'
* role='participant'/>
* </query>
* </iq>
*/
_
.
each
(
$
(
iq
).
find
(
'
query item
'
),
function
(
item
)
{
var
jid
=
item
.
getAttribute
(
'
jid
'
);
var
occupant
=
this
.
model
.
where
({
'
jid
'
:
jid
}).
pop
();
...
...
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