#48 Added types for notification enhancements

This commit is contained in:
Serraniel 2020-12-28 23:10:56 +01:00
parent 413f35f35d
commit 43b5fb7b14
Signed by: Serraniel
GPG key ID: 3690B4E7364525D3

View file

@ -2,7 +2,7 @@ import { getGlobalConfiguration, SETTINGS_websiteShowNotificationsCountInTab } f
import * as core from '../utils/aniwatchCore';
import * as helper from '../utils/helpers';
export function init() {
export function init(): void {
getGlobalConfiguration().getProperty(SETTINGS_websiteShowNotificationsCountInTab, value => {
if (value) {
core.runAfterLoad(() => {
@ -16,17 +16,17 @@ export function init() {
});
}
function getNotificationCount() {
function getNotificationCount(): number {
if (core.isLoggedIn()) {
let menuUserText = document.getElementById('materialize-menu-dropdown').innerText.split('\n')[4];
let notificationCount = menuUserText.match(/\d+/)?.[0] ?? 0;
let notificationCount = parseInt(menuUserText.match(/\d+/)?.[0]) ?? 0;
return notificationCount;
} else {
return 0;
}
}
function updateNotificationsInTitle() {
function updateNotificationsInTitle(): void {
let count = getNotificationCount();
if (helper.assigned(count) && count > 0) {