mirror of
https://github.com/transmission/transmission
synced 2025-02-22 14:10:34 +00:00
* deps: change web build-dep from node-sass to sass https://sass-lang.com/blog/libsass-is-deprecated and dart sass is the recommended replacement. * deps: yarn upgrade-interactive * deps: update babel dep to 7.17 * deps: update eslint * deps: update prettier * deps: update svgo * deps: update webpack to 5.72.1 * deps: update webpack-bundle-analyzer to 4.5.0 * deps: update webpack-cli to 4.9.2 * deps: update webpack-dev-server from 3.11.3 to 4.9.0 * deps: replace svgo, svgo-loader, url-loader with webpack asset/inline * chore: rename "style" dir as "assets" * deps: update stylelint from 13.13.1 to 14.8.2 * deps: bump terser-webpack-plugin from 5.1.4 to 5.3.1 * deps: bump css-loader from 5.2.7 to 6.7.1 * deps: bump css-minimizer-webpack-plugin from 3.0.2 to 3.4.1 * deps: bump mini-css-extract-plugin from 1.6.2 to 2.6.0
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
/* @license This file Copyright (C) 2020-2022 Mnemosyne LLC.
|
|
It may be used under GPLv2 (SPDX: GPL-2.0-only), GPLv3 (SPDX: GPL-3.0-only),
|
|
or any future license endorsed by Mnemosyne LLC.
|
|
License text can be found in the licenses/ folder. */
|
|
|
|
import { setTextContent } from './utils.js';
|
|
|
|
export class Notifications {
|
|
constructor(prefs) {
|
|
this._prefs = prefs;
|
|
this._elements = {
|
|
toggle: document.querySelector('#toggle-notifications'),
|
|
};
|
|
}
|
|
|
|
_setEnabled(enabled) {
|
|
this.prefs.notifications_enabled = enabled;
|
|
setTextContent(
|
|
this._toggle,
|
|
`${enabled ? 'Disable' : 'Enable'} Notifications`
|
|
);
|
|
}
|
|
|
|
_requestPermission() {
|
|
Notification.requestPermission().then((s) =>
|
|
this._setEnabled(s === 'granted')
|
|
);
|
|
}
|
|
|
|
toggle() {
|
|
if (this._enabled) {
|
|
this._setEnabled(false);
|
|
} else if (Notification.permission === 'granted') {
|
|
this._setEnabled(true);
|
|
} else if (Notification.permission !== 'denied') {
|
|
this._requestPermission();
|
|
}
|
|
}
|
|
|
|
/*
|
|
// TODO:
|
|
// $(transmission).bind('downloadComplete seedingComplete', (event, torrent) => {
|
|
// if (notificationsEnabled) {
|
|
const title = `${event.type === 'downloadComplete' ? 'Download' : 'Seeding'} complete`;
|
|
const content = torrent.getName();
|
|
const notification = window.webkitNotifications.createNotification(
|
|
'assets/img/logo.png',
|
|
title,
|
|
content
|
|
);
|
|
notification.show();
|
|
setTimeout(() => {
|
|
notification.cancel();
|
|
}, 5000);
|
|
}
|
|
});
|
|
*/
|
|
}
|