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
33d84a0c
Commit
33d84a0c
authored
Aug 03, 2014
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store roster on converse obj.
Storing it on the rosterview causes race conditions.
parent
ce0096de
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
53 deletions
+54
-53
converse.js
converse.js
+23
-22
spec/chatbox.js
spec/chatbox.js
+1
-1
spec/controlbox.js
spec/controlbox.js
+25
-25
spec/minchats.js
spec/minchats.js
+1
-1
tests/utils.js
tests/utils.js
+4
-4
No files found.
converse.js
View file @
33d84a0c
...
...
@@ -338,7 +338,7 @@
img_type
=
$vcard
.
find
(
'
TYPE
'
).
text
(),
url
=
$vcard
.
find
(
'
URL
'
).
text
();
if
(
jid
)
{
var
contact
=
converse
.
roster
view
.
roster
.
get
(
jid
);
var
contact
=
converse
.
roster
.
get
(
jid
);
if
(
contact
)
{
fullname
=
_
.
isEmpty
(
fullname
)?
contact
.
get
(
'
fullname
'
)
||
jid
:
fullname
;
contact
.
save
({
...
...
@@ -357,7 +357,7 @@
jid
,
function
(
iq
)
{
// Error callback
var
contact
=
converse
.
roster
view
.
roster
.
get
(
jid
);
var
contact
=
converse
.
roster
.
get
(
jid
);
if
(
contact
)
{
contact
.
save
({
'
vcard_updated
'
:
moment
().
format
()
...
...
@@ -565,6 +565,7 @@
this
.
features
=
new
this
.
Features
();
this
.
enableCarbons
();
this
.
initStatus
(
$
.
proxy
(
function
()
{
this
.
roster
=
new
converse
.
RosterContacts
();
this
.
rosterview
=
new
this
.
RosterView
({
model
:
new
this
.
RosterGroups
()});
this
.
chatboxes
.
onConnected
();
this
.
connection
.
roster
.
get
(
function
()
{});
...
...
@@ -1333,7 +1334,7 @@
updateVCard
:
function
()
{
var
jid
=
this
.
model
.
get
(
'
jid
'
),
contact
=
converse
.
roster
view
.
roster
.
get
(
jid
);
contact
=
converse
.
roster
.
get
(
jid
);
if
((
contact
)
&&
(
!
contact
.
get
(
'
vcard_updated
'
)))
{
converse
.
getVCard
(
jid
,
...
...
@@ -2458,7 +2459,7 @@
resource
=
Strophe
.
getResourceFromJid
(
message_from
);
}
chatbox
=
this
.
get
(
buddy_jid
);
roster_item
=
converse
.
roster
view
.
roster
.
get
(
buddy_jid
);
roster_item
=
converse
.
roster
.
get
(
buddy_jid
);
if
(
roster_item
===
undefined
)
{
// The buddy was likely removed
...
...
@@ -2479,7 +2480,7 @@
});
}
chatbox
.
receiveMessage
(
$message
);
converse
.
roster
view
.
roster
.
addResource
(
buddy_jid
,
resource
);
converse
.
roster
.
addResource
(
buddy_jid
,
resource
);
converse
.
emit
(
'
message
'
,
message
);
return
true
;
}
...
...
@@ -2734,7 +2735,8 @@
},
updateUnreadMessagesCounter
:
function
()
{
var
ls
=
this
.
model
.
pluck
(
'
num_unread
'
),
count
=
0
;
var
ls
=
this
.
model
.
pluck
(
'
num_unread
'
),
count
=
0
,
i
;
for
(
i
=
0
;
i
<
ls
.
length
;
i
++
)
{
count
+=
ls
[
i
];
}
this
.
toggleview
.
model
.
set
({
'
num_unread
'
:
count
});
this
.
render
();
...
...
@@ -2932,6 +2934,9 @@
this
.
RosterContacts
=
Backbone
.
Collection
.
extend
({
model
:
converse
.
RosterContact
,
browserStorage
:
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
b64_sha1
(
'
converse.contacts-
'
+
converse
.
bare_jid
)),
comparator
:
function
(
contact1
,
contact2
)
{
var
name1
=
contact1
.
get
(
'
fullname
'
).
toLowerCase
();
var
status1
=
contact1
.
get
(
'
chat_status
'
)
||
'
offline
'
;
...
...
@@ -3218,7 +3223,6 @@
description
:
DESC_GROUP_TOGGLE
,
state
:
OPENED
},
attributes
))
// Collection of contacts belonging to this group.
this
.
contacts
=
new
converse
.
RosterContacts
();
}
...
...
@@ -3238,7 +3242,7 @@
},
this
);
this
.
model
.
contacts
.
on
(
"
destroy
"
,
this
.
onRemove
,
this
);
this
.
model
.
contacts
.
on
(
"
remove
"
,
this
.
onRemove
,
this
);
converse
.
roster
view
.
roster
.
on
(
'
change:groups
'
,
this
.
onContactGroupChange
,
this
);
converse
.
roster
.
on
(
'
change:groups
'
,
this
.
onContactGroupChange
,
this
);
},
render
:
function
()
{
...
...
@@ -3362,21 +3366,18 @@
id
:
'
converse-roster
'
,
initialize
:
function
()
{
this
.
roster
=
new
converse
.
RosterContacts
();
this
.
roster
.
browserStorage
=
new
Backbone
.
BrowserStorage
[
converse
.
storage
](
b64_sha1
(
'
converse.contacts-
'
+
converse
.
bare_jid
));
this
.
registerRosterHandler
();
this
.
registerRosterXHandler
();
this
.
registerPresenceHandler
();
this
.
roster
.
on
(
"
add
"
,
this
.
onAdd
,
this
);
this
.
roster
.
on
(
'
change
'
,
this
.
onChange
,
this
);
this
.
roster
.
on
(
"
remove
"
,
this
.
update
,
this
);
this
.
roster
.
on
(
"
destroy
"
,
this
.
update
,
this
);
converse
.
roster
.
on
(
"
add
"
,
this
.
onAdd
,
this
);
converse
.
roster
.
on
(
'
change
'
,
this
.
onChange
,
this
);
converse
.
roster
.
on
(
"
remove
"
,
this
.
update
,
this
);
converse
.
roster
.
on
(
"
destroy
"
,
this
.
update
,
this
);
this
.
model
.
on
(
"
reset
"
,
this
.
reset
,
this
);
this
.
render
();
this
.
model
.
fetch
({
add
:
true
});
this
.
roster
.
fetch
({
add
:
true
});
converse
.
roster
.
fetch
({
add
:
true
});
},
render
:
function
()
{
...
...
@@ -3387,7 +3388,7 @@
update
:
function
()
{
// XXX: Is this still being used/valid?
var
$count
=
$
(
'
#online-count
'
);
$count
.
text
(
'
(
'
+
this
.
roster
.
getNumOnlineContacts
()
+
'
)
'
);
$count
.
text
(
'
(
'
+
converse
.
roster
.
getNumOnlineContacts
()
+
'
)
'
);
if
(
!
$count
.
is
(
'
:visible
'
))
{
$count
.
show
();
}
...
...
@@ -3395,7 +3396,7 @@
},
reset
:
function
()
{
this
.
roster
.
reset
();
converse
.
roster
.
reset
();
this
.
removeAll
();
this
.
render
().
update
();
return
this
;
...
...
@@ -3404,20 +3405,20 @@
registerRosterHandler
:
function
()
{
// Register handlers that depend on the roster
converse
.
connection
.
roster
.
registerCallback
(
$
.
proxy
(
this
.
roster
.
rosterHandler
,
this
.
roster
),
$
.
proxy
(
converse
.
roster
.
rosterHandler
,
converse
.
roster
),
null
,
'
presence
'
,
null
);
},
registerRosterXHandler
:
function
()
{
converse
.
connection
.
addHandler
(
$
.
proxy
(
this
.
roster
.
subscribeToSuggestedItems
,
this
.
roster
),
$
.
proxy
(
converse
.
roster
.
subscribeToSuggestedItems
,
converse
.
roster
),
'
http://jabber.org/protocol/rosterx
'
,
'
message
'
,
null
);
},
registerPresenceHandler
:
function
()
{
converse
.
connection
.
addHandler
(
$
.
proxy
(
function
(
presence
)
{
this
.
roster
.
presenceHandler
(
presence
);
converse
.
roster
.
presenceHandler
(
presence
);
return
true
;
},
this
),
null
,
'
presence
'
,
null
);
},
...
...
@@ -3475,7 +3476,7 @@
return
view
;
}
view
=
new
converse
.
RosterGroupView
({
model
:
this
.
model
.
create
({
name
:
name
,
id
:
b64_sha1
(
name
)})
model
:
this
.
model
.
create
({
name
:
name
,
id
:
b64_sha1
(
name
)})
,
});
this
.
add
(
name
,
view
);
return
this
.
positionGroup
(
view
)
...
...
spec/chatbox.js
View file @
33d84a0c
...
...
@@ -682,7 +682,7 @@
beforeEach
(
function
()
{
utils
.
closeAllChatBoxes
();
utils
.
removeControlBox
();
converse
.
roster
view
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
createContacts
();
utils
.
openControlBox
();
...
...
spec/controlbox.js
View file @
33d84a0c
This diff is collapsed.
Click to expand it.
spec/minchats.js
View file @
33d84a0c
...
...
@@ -13,7 +13,7 @@
runs
(
function
()
{
utils
.
closeAllChatBoxes
();
utils
.
removeControlBox
();
converse
.
roster
view
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
utils
.
initConverse
();
utils
.
createContacts
();
utils
.
openControlBox
();
...
...
tests/utils.js
View file @
33d84a0c
...
...
@@ -36,7 +36,7 @@
};
utils
.
initRoster
=
function
()
{
converse
.
roster
view
.
roster
.
browserStorage
.
_clear
();
converse
.
roster
.
browserStorage
.
_clear
();
converse
.
initRoster
();
};
...
...
@@ -80,13 +80,13 @@
var
i
=
0
,
jid
,
views
=
[];
for
(
i
;
i
<
amount
;
i
++
)
{
jid
=
mock
.
cur_names
[
i
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@localhost
'
;
views
[
i
]
=
converse
.
roster
view
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
views
[
i
]
=
converse
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
}
return
views
;
};
utils
.
openChatBoxFor
=
function
(
jid
)
{
return
converse
.
roster
view
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
return
converse
.
roster
.
get
(
jid
).
trigger
(
"
open
"
);
};
utils
.
removeRosterContacts
=
function
()
{
...
...
@@ -134,7 +134,7 @@
ask
=
null
;
}
for
(
i
=
0
;
i
<
names
.
length
;
i
++
)
{
converse
.
roster
view
.
roster
.
create
({
converse
.
roster
.
create
({
ask
:
ask
,
fullname
:
names
[
i
],
is_last
:
i
===
(
names
.
length
-
1
),
...
...
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