Commit 4a452d50 authored by Olivia Madrid's avatar Olivia Madrid

(fix): Hovering over bulb icon to toggle dark mode disabled for touch screens

parent 6c190be0
Pipeline #69296266 passed with stages
in 30 minutes and 23 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