Commit c14a0032 authored by Mark Harding's avatar Mark Harding

Merge branch 'fix/DisableDarkModeBulbToggleForTouchscreens' into 'master'

[Sprint/InterestingIguana](fix): Hovering over bulb icon to toggle dark mode disabled for touch screens

See merge request !416
parents 6c190be0 4a452d50
Pipeline #69361073 passed with stages
in 28 minutes and 44 seconds
......@@ -40,6 +40,7 @@
i18n-title
>
<img [src]="minds.cdn_assets_url + 'assets/logos/bulb.svg'"
(touchstart)="touchStart()"
(mouseenter)="mouseEnter()"
(mouseleave)="mouseLeave()"
/>
......
......@@ -4,6 +4,7 @@ import {
Component,
ComponentFactoryResolver,
OnInit,
OnDestroy,
ViewChild
} from "@angular/core";
import { Session } from "../../../services/session";
......@@ -16,9 +17,10 @@ import { ThemeService } from "../../../common/services/theme.service";
templateUrl: 'v2-topbar.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class V2TopbarComponent implements OnInit {
export class V2TopbarComponent implements OnInit, OnDestroy {
minds = window.Minds;
timeout;
isTouchScreen = false;
@ViewChild(DynamicHostDirective, { static: true }) notificationsToasterHost: DynamicHostDirective;
......@@ -57,10 +59,16 @@ export class V2TopbarComponent implements OnInit {
this.cd.detectChanges();
}
touchStart() {
this.isTouchScreen = true;
}
mouseEnter() {
if (this.session.isLoggedIn()) {
this.timeout = setTimeout(() => {
this.themeService.toggleUserThemePreference();
if (!this.isTouchScreen) {
this.themeService.toggleUserThemePreference();
}
}, 5000);
}
}
......@@ -70,8 +78,9 @@ export class V2TopbarComponent implements OnInit {
}
ngOnDestroy() {
if (this.timeout)
if (this.timeout) {
clearTimeout(this.timeout);
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment