|
|
@ -8,14 +8,15 @@ import {
|
|
|
|
SingleFilterExpression
|
|
|
|
SingleFilterExpression
|
|
|
|
} from "./FilterExpression";
|
|
|
|
} from "./FilterExpression";
|
|
|
|
import {SortKey} from "./SortKey";
|
|
|
|
import {SortKey} from "./SortKey";
|
|
|
|
import {debounceTime} from "rxjs/operators";
|
|
|
|
|
|
|
|
import {TagQuery} from "./TagQuery";
|
|
|
|
import {TagQuery} from "./TagQuery";
|
|
|
|
|
|
|
|
import {debounceTime} from "rxjs/operators";
|
|
|
|
|
|
|
|
|
|
|
|
export class TabState {
|
|
|
|
export class TabState {
|
|
|
|
public uuid: number;
|
|
|
|
public uuid: number;
|
|
|
|
public category: TabCategory;
|
|
|
|
public category: TabCategory;
|
|
|
|
public mode = new BehaviorSubject<"grid" | "gallery">("grid");
|
|
|
|
public mode = new BehaviorSubject<"grid" | "gallery">("grid");
|
|
|
|
public selectedFileHash = new BehaviorSubject<string | undefined>(undefined);
|
|
|
|
public selectedFileHash = new BehaviorSubject<string | undefined>(undefined);
|
|
|
|
|
|
|
|
public loading = new BehaviorSubject<boolean>(false);
|
|
|
|
|
|
|
|
|
|
|
|
public files = new BehaviorSubject<File[]>([]);
|
|
|
|
public files = new BehaviorSubject<File[]>([]);
|
|
|
|
public filters = new BehaviorSubject<FilterExpression[]>([]);
|
|
|
|
public filters = new BehaviorSubject<FilterExpression[]>([]);
|
|
|
@ -29,16 +30,20 @@ export class TabState {
|
|
|
|
this.category = category;
|
|
|
|
this.category = category;
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.uuid = uuid;
|
|
|
|
this.fileService = fileService;
|
|
|
|
this.fileService = fileService;
|
|
|
|
this.filters.pipe(debounceTime(500))
|
|
|
|
if (this.category === TabCategory.Files) {
|
|
|
|
.subscribe(async () => await this.findFiles());
|
|
|
|
this.filters.pipe(debounceTime(500))
|
|
|
|
this.sortKeys.pipe(debounceTime(100))
|
|
|
|
.subscribe(async () => await this.findFiles());
|
|
|
|
.subscribe(async () => await this.findFiles());
|
|
|
|
this.sortKeys.pipe(debounceTime(100))
|
|
|
|
|
|
|
|
.subscribe(async () => await this.findFiles());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async findFiles() {
|
|
|
|
public async findFiles() {
|
|
|
|
|
|
|
|
this.loading.next(true);
|
|
|
|
const files = await this.fileService.findFiles(this.filters.value,
|
|
|
|
const files = await this.fileService.findFiles(this.filters.value,
|
|
|
|
this.sortKeys.value);
|
|
|
|
this.sortKeys.value);
|
|
|
|
this.files.next(files);
|
|
|
|
this.files.next(files);
|
|
|
|
|
|
|
|
this.loading.next(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public setFilters(filters: FilterExpression[]) {
|
|
|
|
public setFilters(filters: FilterExpression[]) {
|
|
|
@ -46,7 +51,7 @@ export class TabState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public setSortKeys(keys: SortKey[]) {
|
|
|
|
public setSortKeys(keys: SortKey[]) {
|
|
|
|
this.sortKeys.next(keys)
|
|
|
|
this.sortKeys.next(keys);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static fromDTO(dto: any, fileService: FileService): TabState {
|
|
|
|
public static fromDTO(dto: any, fileService: FileService): TabState {
|
|
|
@ -64,7 +69,8 @@ export class TabState {
|
|
|
|
state.filters.next(filters);
|
|
|
|
state.filters.next(filters);
|
|
|
|
state.sortKeys.next(sortKeys);
|
|
|
|
state.sortKeys.next(sortKeys);
|
|
|
|
state.mode.next(dto.mode ?? "grid");
|
|
|
|
state.mode.next(dto.mode ?? "grid");
|
|
|
|
state.selectedFileHash.next(dto.selectedFileHash)
|
|
|
|
state.selectedFileHash.next(dto.selectedFileHash);
|
|
|
|
|
|
|
|
state.files.next(dto.files);
|
|
|
|
|
|
|
|
|
|
|
|
return state
|
|
|
|
return state
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -76,7 +82,8 @@ export class TabState {
|
|
|
|
filters: this.filters.value,
|
|
|
|
filters: this.filters.value,
|
|
|
|
sortKeys: this.sortKeys.value,
|
|
|
|
sortKeys: this.sortKeys.value,
|
|
|
|
mode: this.mode.value,
|
|
|
|
mode: this.mode.value,
|
|
|
|
selectedFileHash: this.selectedFileHash.value
|
|
|
|
selectedFileHash: this.selectedFileHash.value,
|
|
|
|
|
|
|
|
files: this.files.value,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|