Feature/#48 migrate to typescript #151

Merged
Serraniel merged 30 commits from feature/#48-migrate-to-typescript into develop 2020-12-30 17:24:49 +01:00
Showing only changes of commit 43b5fb7b14 - Show all commits

View file

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