Kavita/UI/Web/src/app/_services/toggle.service.ts
Joseph Milazzo a062341564
Release Shakeout (#1266)
* Fixed an issue with fit to screen where spread images would fail to generate a paging area long enough.

* Fixed pagination placement on original scaling

* Fixed an issue with webtoon reader not reporting scroll events due to a fix from manga reader.

* Fixing select on black book-reader theme

* Fixing canvas split centering

* Fixed a bug with white mode in book reader not rendering correctly. When bookmarking new pages after previously have viewing bookmarks for a series, ensure we clear out the temp cache else your new files wont be visible till next day.

* Use grid on related tab

* Clear bookmarks was not hooked up. Bulk add to collection didn't have label hidden

* Fixed bug where filter might stay open between pages

* Fixed typo on relationship for Adaptation

* Contains was missing from series relation modal

* Tweaked some methods and wording on reading list page

* Cleaned up the phrasing when we abort a scan.

* Fixed issue where typeahead wasn't reopening and it wasn't filtering selected options

* Fixed some typeahead bugs and decreased interval for docker health check

* Cleaned up and fixed some logic with receiving cover image update events

Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
2022-05-20 17:50:17 -05:00

39 lines
1,005 B
TypeScript

import { Injectable } from '@angular/core';
import { NavigationStart, Router } from '@angular/router';
import { filter, ReplaySubject, take } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ToggleService {
toggleState: boolean = false;
private toggleStateSource: ReplaySubject<boolean> = new ReplaySubject<boolean>(1);
public toggleState$ = this.toggleStateSource.asObservable();
constructor(router: Router) {
router.events
.pipe(filter(event => event instanceof NavigationStart))
.subscribe((event) => {
this.toggleState = false;
this.toggleStateSource.next(this.toggleState);
});
this.toggleStateSource.next(false);
}
toggle() {
this.toggleState = !this.toggleState;
this.toggleStateSource.pipe(take(1)).subscribe(state => {
this.toggleState = !state;
this.toggleStateSource.next(this.toggleState);
});
}
set(state: boolean) {
this.toggleState = state;
this.toggleStateSource.next(state);
}
}