mirror of
https://github.com/ascribe/onion.git
synced 2025-02-14 21:10:27 +01:00
Update PR with fixes
This commit is contained in:
parent
7ce98d0433
commit
4ee26d7259
@ -8,23 +8,20 @@
|
|||||||
*/
|
*/
|
||||||
function getUnreadCount() {
|
function getUnreadCount() {
|
||||||
const match = document.title.match(/^\((\d+)\)/);
|
const match = document.title.match(/^\((\d+)\)/);
|
||||||
return match ? match[1] : null;
|
return parseInt((match ? match[1] : 0), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the title in the browser window while keeping the unread notification count (if any).
|
* Set the title in the browser window while keeping the unread notification count (if any).
|
||||||
*
|
|
||||||
* @return {string} the new document title
|
|
||||||
*/
|
*/
|
||||||
export function setDocumentTitle(title) {
|
export function setDocumentTitle(title) {
|
||||||
const count = getUnreadCount();
|
const count = getUnreadCount();
|
||||||
let newTitle = title;
|
let newTitle = title;
|
||||||
|
|
||||||
if (count) {
|
if (count > 0) {
|
||||||
newTitle = `(${count}) ` + newTitle;
|
newTitle = `(${count}) ${newTitle}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
document.title = newTitle;
|
document.title = newTitle;
|
||||||
return newTitle;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user