Add interaction and triggered conditions.

This commit is contained in:
Dermot Duffy
2024-01-25 22:06:21 -08:00
parent 06f2151bab
commit 5e72070c96
27 changed files with 379 additions and 90 deletions
+14 -9
View File
@@ -16,32 +16,37 @@ export class InteractionManager {
this._reportInteraction();
}, 1 * 1000);
public initialize(): void {
this._api.getConditionsManager().setState({ interaction: false });
}
public hasInteraction(): boolean {
return this._timer.isRunning();
}
/**
* Start the user interaction ('screensaver') timer to reset the view to
* default `view.timeout_seconds` after user interaction.
* default `view.interaction_seconds` after user interaction.
*/
protected _reportInteraction(): void {
this._timer.stop();
const timeoutSeconds = this._api.getConfigManager().getConfig()
?.view.timeout_seconds;
?.view.interaction_seconds;
if (timeoutSeconds) {
this._api.getConditionsManager().setState({ interaction: true });
this._timer.start(timeoutSeconds, () => {
if (this._isAutomatedUpdateAllowed()) {
this._api.getViewManager().setViewDefault();
this._api.getConditionsManager().setState({ interaction: false });
if (!this._api.getTriggersManager().isTriggered()) {
if (this._api.getConfigManager().getConfig()?.view.reset_after_interaction) {
this._api.getViewManager().setViewDefault();
}
this._api.getStyleManager().setLightOrDarkMode();
}
});
}
this._api.getStyleManager().setLightOrDarkMode();
}
protected _isAutomatedUpdateAllowed(): boolean {
return !this._api.getTriggersManager().isTriggered();
}
}