Only warn user once when Night Light is disabled
This commit is contained in:
@@ -34,20 +34,22 @@ The Nightlighter establishes a connection with the session bus to get the
|
|||||||
current Night Light status. It listens to changes and reports them.
|
current Night Light status. It listens to changes and reports them.
|
||||||
|
|
||||||
As Night Light is essential for the extension to work, it continuously checks
|
As Night Light is essential for the extension to work, it continuously checks
|
||||||
if it is enabled and warns the user if that's not the case.
|
if it is enabled and warns the user if that's not the case. To not overwhelm
|
||||||
|
the user with notifications, it only warns once and then only listens to Night
|
||||||
|
Light changes to reactivate itself automatically.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var Nightlighter = class {
|
var Nightlighter = class {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
log_debug('Initializing Nightlighter...');
|
log_debug('Initializing Nightlighter...');
|
||||||
|
this.first_nightlight_not_enabled_warning = true;
|
||||||
this.nightlight_gsettings = new Gio.Settings({ schema: config.NIGHTLIGHT_GSETTINGS_SCHEMA });
|
this.nightlight_gsettings = new Gio.Settings({ schema: config.NIGHTLIGHT_GSETTINGS_SCHEMA });
|
||||||
log_debug('Nightlighter initialized.');
|
log_debug('Nightlighter initialized.');
|
||||||
}
|
}
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
log_debug('Enabling NightLighter...');
|
log_debug('Enabling NightLighter...');
|
||||||
// As Night Light must be enabled for the extension to work, we have to monitor any change of that setting.
|
|
||||||
try {
|
try {
|
||||||
this._listen_to_nightlight_status();
|
this._listen_to_nightlight_status();
|
||||||
this._check_nightlight_status();
|
this._check_nightlight_status();
|
||||||
@@ -57,9 +59,11 @@ var Nightlighter = class {
|
|||||||
log_debug('Nightlighter enabled.');
|
log_debug('Nightlighter enabled.');
|
||||||
}
|
}
|
||||||
catch(e) {
|
catch(e) {
|
||||||
|
if ( e.message ) {
|
||||||
main.notifyError(config.EXT_NAME, e.message);
|
main.notifyError(config.EXT_NAME, e.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
disable() {
|
disable() {
|
||||||
log_debug('Disabling Nightlighter...');
|
log_debug('Disabling Nightlighter...');
|
||||||
@@ -96,9 +100,15 @@ var Nightlighter = class {
|
|||||||
|
|
||||||
_check_nightlight_status() {
|
_check_nightlight_status() {
|
||||||
if ( !this._is_nightlight_enabled() ) {
|
if ( !this._is_nightlight_enabled() ) {
|
||||||
|
if ( this.first_nightlight_not_enabled_warning ) {
|
||||||
|
this.first_nightlight_not_enabled_warning = false;
|
||||||
const message = _('Night Light must be enabled to use this extension. Please enable it in your system settings.');
|
const message = _('Night Light must be enabled to use this extension. Please enable it in your system settings.');
|
||||||
throw new Error(message);
|
throw new Error(message);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_listen_to_nightlight_status() {
|
_listen_to_nightlight_status() {
|
||||||
|
|||||||
Reference in New Issue
Block a user