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
6de07c5c
Commit
6de07c5c
authored
Nov 04, 2020
by
Ariel Fuggini
Committed by
JC Brand
Nov 05, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds setting to toggle showing unread message counter in page title
parent
cf94a519
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
18 deletions
+46
-18
docs/source/configuration.rst
docs/source/configuration.rst
+7
-0
spec/chatbox.js
spec/chatbox.js
+17
-4
src/headless/converse-chatboxes.js
src/headless/converse-chatboxes.js
+22
-14
No files found.
docs/source/configuration.rst
View file @
6de07c5c
...
@@ -1954,6 +1954,13 @@ Converse render the emojis with `Twemoji <https://twemoji.twitter.com/>`_.
...
@@ -1954,6 +1954,13 @@ Converse render the emojis with `Twemoji <https://twemoji.twitter.com/>`_.
See also `emoji_image_path`_.
See also `emoji_image_path`_.
update_title
------------
* Default: ``true``
Determines whether to shows unread messages counter in the page title.
visible_toolbar_buttons
visible_toolbar_buttons
-----------------------
-----------------------
...
...
spec/chatbox.js
View file @
6de07c5c
...
@@ -1058,16 +1058,16 @@ describe("Chatboxes", function () {
...
@@ -1058,16 +1058,16 @@ describe("Chatboxes", function () {
await
mock
.
openControlBox
(
_converse
);
await
mock
.
openControlBox
(
_converse
);
expect
(
document
.
title
).
toBe
(
'
Converse Tests
'
);
expect
(
document
.
title
).
toBe
(
'
Converse Tests
'
);
_converse
.
api
.
settings
.
set
(
'
update_title
'
,
false
);
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
const
sender_jid
=
mock
.
cur_names
[
0
].
replace
(
/ /g
,
'
.
'
).
toLowerCase
()
+
'
@montague.lit
'
;
const
previous_state
=
_converse
.
windowState
;
const
previous_state
=
_converse
.
windowState
;
const
message
=
'
This message will increment the message counter
'
;
const
msg
=
$msg
({
const
msg
=
$msg
({
from
:
sender_jid
,
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
()
id
:
u
.
getUniqueId
()
}).
c
(
'
body
'
).
t
(
message
).
up
()
}).
c
(
'
body
'
).
t
(
'
This message will increment the message counter
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
.
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
_converse
.
windowState
=
'
hidden
'
;
_converse
.
windowState
=
'
hidden
'
;
...
@@ -1078,8 +1078,21 @@ describe("Chatboxes", function () {
...
@@ -1078,8 +1078,21 @@ describe("Chatboxes", function () {
await
_converse
.
handleMessageStanza
(
msg
);
await
_converse
.
handleMessageStanza
(
msg
);
expect
(
_converse
.
incrementMsgCounter
).
toHaveBeenCalled
();
expect
(
_converse
.
incrementMsgCounter
).
toHaveBeenCalled
();
expect
(
_converse
.
clearMsgCounter
).
not
.
toHaveBeenCalled
();
expect
(
_converse
.
clearMsgCounter
).
not
.
toHaveBeenCalled
();
expect
(
document
.
title
).
toBe
(
'
Messages (1)
Converse Tests
'
);
expect
(
document
.
title
).
toBe
(
'
Converse Tests
'
);
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
expect
(
_converse
.
api
.
trigger
).
toHaveBeenCalledWith
(
'
message
'
,
jasmine
.
any
(
Object
));
_converse
.
api
.
settings
.
set
(
'
update_title
'
,
true
);
const
msg2
=
$msg
({
from
:
sender_jid
,
to
:
_converse
.
connection
.
jid
,
type
:
'
chat
'
,
id
:
u
.
getUniqueId
()
}).
c
(
'
body
'
).
t
(
'
This message increment the message counter AND update the page title
'
).
up
()
.
c
(
'
active
'
,
{
'
xmlns
'
:
Strophe
.
NS
.
CHATSTATES
}).
tree
();
await
_converse
.
handleMessageStanza
(
msg2
);
expect
(
document
.
title
).
toBe
(
'
Messages (2) Converse Tests
'
);
_converse
.
windowSate
=
previous_state
;
_converse
.
windowSate
=
previous_state
;
done
();
done
();
}));
}));
...
...
src/headless/converse-chatboxes.js
View file @
6de07c5c
...
@@ -32,32 +32,40 @@ converse.plugins.add('converse-chatboxes', {
...
@@ -32,32 +32,40 @@ converse.plugins.add('converse-chatboxes', {
'
privateChatsAutoJoined
'
'
privateChatsAutoJoined
'
]);
]);
api
.
settings
.
extend
({
'
update_title
'
:
true
});
let
msg_counter
=
0
;
let
msg_counter
=
0
;
const
favicon
=
new
Favico
({
type
:
'
circle
'
,
position
:
'
up
'
,
animation
:
'
none
'
});
const
favicon
=
new
Favico
({
type
:
'
circle
'
,
position
:
'
up
'
,
animation
:
'
none
'
});
_converse
.
incrementMsgCounter
=
function
()
{
_converse
.
incrementMsgCounter
=
function
()
{
msg_counter
+=
1
;
msg_counter
+=
1
;
favicon
.
badge
(
msg_counter
);
favicon
.
badge
(
msg_counter
);
const
title
=
document
.
title
;
if
(
api
.
settings
.
get
(
'
update_title
'
))
{
if
(
!
title
)
{
const
title
=
document
.
title
;
return
;
if
(
!
title
)
{
}
return
;
if
(
title
.
search
(
/^Messages
\(\d
+
\)
/
)
===
-
1
)
{
}
document
.
title
=
`Messages (
${
msg_counter
}
)
${
title
}
`
;
if
(
title
.
search
(
/^Messages
\(\d
+
\)
/
)
===
-
1
)
{
}
else
{
document
.
title
=
`Messages (
${
msg_counter
}
)
${
title
}
`
;
document
.
title
=
title
.
replace
(
/^Messages
\(\d
+
\)
/
,
`Messages (
${
msg_counter
}
) `
);
}
else
{
document
.
title
=
title
.
replace
(
/^Messages
\(\d
+
\)
/
,
`Messages (
${
msg_counter
}
) `
);
}
}
}
};
};
_converse
.
clearMsgCounter
=
function
()
{
_converse
.
clearMsgCounter
=
function
()
{
msg_counter
=
0
;
msg_counter
=
0
;
favicon
.
badge
(
msg_counter
);
favicon
.
badge
(
msg_counter
);
const
title
=
document
.
title
;
if
(
api
.
settings
.
get
(
'
update_title
'
))
{
if
(
!
title
)
{
const
title
=
document
.
title
;
return
;
if
(
!
title
)
{
}
return
;
if
(
title
.
search
(
/^Messages
\(\d
+
\)
/
)
!==
-
1
)
{
}
document
.
title
=
title
.
replace
(
/^Messages
\(\d
+
\)
/
,
""
);
if
(
title
.
search
(
/^Messages
\(\d
+
\)
/
)
!==
-
1
)
{
document
.
title
=
title
.
replace
(
/^Messages
\(\d
+
\)
/
,
""
);
}
}
}
};
};
...
...
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