diff --git a/app/renderer/js/notification/index.js b/app/renderer/js/notification/index.ts similarity index 53% rename from app/renderer/js/notification/index.js rename to app/renderer/js/notification/index.ts index d82b8323..2a143d34 100644 --- a/app/renderer/js/notification/index.js +++ b/app/renderer/js/notification/index.ts @@ -1,12 +1,12 @@ 'use strict'; -const { - remote: { app } -} = require('electron'); +import { remote } from 'electron'; -const params = require('../utils/params-util.js'); -const DefaultNotification = require('./default-notification'); -const { appId, loadBots } = require('./helpers'); +import * as params from '../utils/params-util'; +import DefaultNotification from './default-notification'; +import { appId, loadBots } from './helpers'; + +const { app } = remote; // From https://github.com/felixrieseberg/electron-windows-notifications#appusermodelid // On windows 8 we have to explicitly set the appUserModelId otherwise notification won't work. @@ -15,12 +15,11 @@ app.setAppUserModelId(appId); window.Notification = DefaultNotification; if (process.platform === 'darwin') { - const DarwinNotification = require('./darwin-notifications'); - window.Notification = DarwinNotification; + window.Notification = require('./darwin-notifications'); } window.addEventListener('load', () => { - // eslint-disable-next-line no-undef, camelcase + // eslint-disable-next-line no-undef, @typescript-eslint/camelcase if (params.isPageParams() && page_params.realm_uri) { loadBots(); } diff --git a/typings.d.ts b/typings.d.ts index d7943988..109bc4ae 100644 --- a/typings.d.ts +++ b/typings.d.ts @@ -4,7 +4,7 @@ // are not supported declare module '*'; -declare var page_params: object; +declare var page_params: any; // since requestIdleCallback didn't make it into lib.dom.d.ts yet declare function requestIdleCallback(callback: Function, options?: object): void; @@ -12,5 +12,6 @@ declare function requestIdleCallback(callback: Function, options?: object): void // This is mostly zulip side of code we access from window interface Window { $: any; - narrow: any; + narrow: any + Notification: typeof Notification; }