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
2d507c68
Commit
2d507c68
authored
May 24, 2019
by
JC Brand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always debounce trimChats
parent
1ef29bee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
23 deletions
+11
-23
src/converse-minimize.js
src/converse-minimize.js
+11
-23
No files found.
src/converse-minimize.js
View file @
2d507c68
...
...
@@ -284,7 +284,7 @@ converse.plugins.add('converse-minimize', {
);
},
async
trimChats
(
newchat
)
{
trimChats
:
_
.
debounce
(
async
function
(
newchat
)
{
/* This method is called when a newly created chat box will
* be shown.
*
...
...
@@ -292,9 +292,11 @@ converse.plugins.add('converse-minimize', {
* another chat box. Otherwise it minimizes the oldest chat box
* to create space.
*/
const
{
_converse
}
=
this
.
__super__
,
shown_chats
=
this
.
getShownChats
(),
body_width
=
u
.
getOuterWidth
(
document
.
querySelector
(
'
body
'
),
true
);
if
(
!
_converse
.
connection
.
connected
||
_converse
.
view_mode
!==
'
overlayed
'
)
{
return
;
}
const
shown_chats
=
this
.
getShownChats
();
const
body_width
=
u
.
getOuterWidth
(
document
.
querySelector
(
'
body
'
),
true
);
if
(
_converse
.
no_trimming
||
shown_chats
.
length
<=
1
)
{
return
;
...
...
@@ -333,7 +335,7 @@ converse.plugins.add('converse-minimize', {
}
}
}
},
},
100
),
getOldestMaximizedChat
(
exclude_ids
)
{
// Get oldest view (if its id is not excluded)
...
...
@@ -561,24 +563,10 @@ converse.plugins.add('converse-minimize', {
}).
catch
(
_
.
partial
(
_converse
.
log
,
_
,
Strophe
.
LogLevel
.
FATAL
));
const
debouncedTrim
=
_
.
debounce
(
ev
=>
{
if
(
_converse
.
view_mode
!==
'
overlayed
'
||
!
_converse
.
chatboxviews
.
trimChats
)
{
return
;
}
if
(
_converse
.
connection
.
connected
)
{
_converse
.
chatboxviews
.
trimChats
();
}
},
200
);
_converse
.
api
.
listen
.
on
(
'
registeredGlobalEventHandlers
'
,
()
=>
window
.
addEventListener
(
"
resize
"
,
debouncedTrim
));
_converse
.
api
.
listen
.
on
(
'
unregisteredGlobalEventHandlers
'
,
()
=>
window
.
removeEventListener
(
"
resize
"
,
debouncedTrim
));
_converse
.
api
.
listen
.
on
(
'
controlBoxOpened
'
,
function
(
chatbox
)
{
// Wrapped in anon method because at scan time, chatboxviews
// attr not set yet.
if
(
_converse
.
connection
.
connected
)
{
_converse
.
chatboxviews
.
trimChats
(
chatbox
);
}
});
const
trimChats
=
()
=>
_converse
.
chatboxviews
.
trimChats
();
_converse
.
api
.
listen
.
on
(
'
controlBoxOpened
'
,
trimChats
);
_converse
.
api
.
listen
.
on
(
'
registeredGlobalEventHandlers
'
,
()
=>
window
.
addEventListener
(
"
resize
"
,
trimChats
));
_converse
.
api
.
listen
.
on
(
'
unregisteredGlobalEventHandlers
'
,
()
=>
window
.
removeEventListener
(
"
resize
"
,
trimChats
));
/************************ END Event Handlers ************************/
}
});
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