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
d1bafdb3
Commit
d1bafdb3
authored
Jun 09, 2017
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-render only the tab when `num_unread` changes.
parent
f9fb13a7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
28 deletions
+37
-28
src/converse-controlbox.js
src/converse-controlbox.js
+18
-17
src/converse-muc.js
src/converse-muc.js
+15
-9
src/converse-rosterview.js
src/converse-rosterview.js
+0
-2
src/utils.js
src/utils.js
+4
-0
No files found.
src/converse-controlbox.js
View file @
d1bafdb3
...
...
@@ -43,6 +43,7 @@
"
use strict
"
;
var
USERS_PANEL_ID
=
'
users
'
;
var
CHATBOX_TYPE
=
'
chatbox
'
;
// Strophe methods for building stanzas
var
Strophe
=
converse
.
env
.
Strophe
,
Backbone
=
converse
.
env
.
Backbone
,
...
...
@@ -287,6 +288,7 @@
'
$parent
'
:
this
.
$el
.
find
(
'
.controlbox-panes
'
)
});
this
.
contactspanel
.
insertIntoDOM
();
_converse
.
xmppstatusview
=
new
_converse
.
XMPPStatusView
({
'
model
'
:
_converse
.
xmppstatus
});
...
...
@@ -585,23 +587,11 @@
initialize
:
function
(
cfg
)
{
this
.
parent_el
=
cfg
.
$parent
[
0
];
this
.
tab_el
=
document
.
createElement
(
'
li
'
);
_converse
.
chatboxes
.
on
(
'
change:num_unread
'
,
this
.
render
,
this
);
_converse
.
chatboxes
.
on
(
'
change:num_unread
'
,
this
.
render
Tab
,
this
);
},
render
:
function
()
{
var
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
);
var
is_current
=
controlbox
.
get
(
'
active-panel
'
)
===
USERS_PANEL_ID
;
var
isChatBox
=
function
(
item
)
{
return
item
.
get
(
'
type
'
)
==
'
chatbox
'
;
}
var
chatrooms
=
fp
.
filter
(
isChatBox
,
_converse
.
chatboxes
.
models
);
this
.
tab_el
.
innerHTML
=
tpl_contacts_tab
({
'
label_contacts
'
:
LABEL_CONTACTS
,
'
is_current
'
:
is_current
,
'
num_unread
'
:
fp
.
sum
(
fp
.
map
(
fp
.
curry
(
utils
.
getAttribute
)(
'
num_unread
'
),
chatrooms
))
});
this
.
renderTab
();
var
widgets
=
tpl_contacts_panel
({
label_online
:
__
(
'
Online
'
),
...
...
@@ -620,17 +610,28 @@
}
this
.
el
.
innerHTML
=
widgets
;
if
(
!
is_current
)
{
this
.
$el
.
addClass
(
'
hidden
'
);
var
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
);
if
(
controlbox
.
get
(
'
active-panel
'
)
!==
USERS_PANEL_ID
)
{
this
.
el
.
classList
.
add
(
'
hidden
'
);
}
return
this
;
},
renderTab
:
function
()
{
var
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
);
var
chats
=
fp
.
filter
(
_
.
partial
(
utils
.
isOfType
,
CHATBOX_TYPE
),
_converse
.
chatboxes
.
models
);
this
.
tab_el
.
innerHTML
=
tpl_contacts_tab
({
'
label_contacts
'
:
LABEL_CONTACTS
,
'
is_current
'
:
controlbox
.
get
(
'
active-panel
'
)
===
USERS_PANEL_ID
,
'
num_unread
'
:
fp
.
sum
(
fp
.
map
(
fp
.
curry
(
utils
.
getAttribute
)(
'
num_unread
'
),
chats
))
});
},
insertIntoDOM
:
function
()
{
this
.
parent_el
.
appendChild
(
this
.
render
().
el
);
this
.
tabs
=
this
.
parent_el
.
parentNode
.
querySelector
(
'
#controlbox-tabs
'
);
this
.
tabs
.
appendChild
(
this
.
tab_el
);
this
.
$
el
.
find
(
'
.search-xmpp ul
'
).
append
(
this
.
$
(
'
.search-xmpp ul
'
).
append
(
this
.
generateAddContactHTML
()
);
return
this
;
...
...
src/converse-muc.js
View file @
d1bafdb3
...
...
@@ -2385,7 +2385,7 @@
this
.
tab_el
=
document
.
createElement
(
'
li
'
);
this
.
model
.
on
(
'
change:muc_domain
'
,
this
.
onDomainChange
,
this
);
this
.
model
.
on
(
'
change:nick
'
,
this
.
onNickChange
,
this
);
_converse
.
chatboxes
.
on
(
'
change:num_unread
'
,
this
.
render
,
this
);
_converse
.
chatboxes
.
on
(
'
change:num_unread
'
,
this
.
render
Tab
,
this
);
},
render
:
function
()
{
...
...
@@ -2398,19 +2398,25 @@
'
label_join
'
:
__
(
'
Join Room
'
),
'
label_show_rooms
'
:
__
(
'
Show rooms
'
)
});
this
.
renderTab
();
var
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
);
var
is_current
=
controlbox
.
get
(
'
active-panel
'
)
===
ROOMS_PANEL_ID
;
var
isChatroom
=
fp
.
curry
(
utils
.
isInstance
)(
_converse
.
ChatRoom
)
var
chatrooms
=
fp
.
filter
(
isChatroom
,
_converse
.
chatboxes
.
models
);
if
(
controlbox
.
get
(
'
active-panel
'
)
!==
ROOMS_PANEL_ID
)
{
this
.
el
.
classList
.
add
(
'
hidden
'
);
}
return
this
;
},
renderTab
:
function
()
{
var
controlbox
=
_converse
.
chatboxes
.
get
(
'
controlbox
'
);
var
chatrooms
=
fp
.
filter
(
_
.
partial
(
utils
.
isOfType
,
CHATROOMS_TYPE
),
_converse
.
chatboxes
.
models
);
this
.
tab_el
.
innerHTML
=
tpl_chatrooms_tab
({
'
label_rooms
'
:
__
(
'
Rooms
'
),
'
is_current
'
:
is_current
,
'
is_current
'
:
controlbox
.
get
(
'
active-panel
'
)
===
ROOMS_PANEL_ID
,
'
num_unread
'
:
fp
.
sum
(
fp
.
map
(
fp
.
curry
(
utils
.
getAttribute
)(
'
num_unread
'
),
chatrooms
))
});
if
(
!
is_current
)
{
this
.
el
.
classList
.
add
(
'
hidden
'
);
}
return
this
;
},
insertIntoDOM
:
function
()
{
...
...
src/converse-rosterview.js
View file @
d1bafdb3
...
...
@@ -281,8 +281,6 @@
_converse
.
on
(
'
rosterGroupsFetched
'
,
this
.
positionFetchedGroups
,
this
);
_converse
.
on
(
'
rosterContactsFetched
'
,
this
.
update
,
this
);
this
.
createRosterFilter
();
},
render
:
function
()
{
...
...
src/utils.js
View file @
d1bafdb3
...
...
@@ -471,6 +471,10 @@
return
utils
.
detectLocale
(
isSupportedByLibrary
)
||
'
en
'
;
};
utils
.
isOfType
=
function
(
type
,
item
)
{
return
item
.
get
(
'
type
'
)
==
type
;
}
utils
.
isInstance
=
function
(
type
,
item
)
{
return
item
instanceof
type
;
};
...
...
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