mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2024-04-21 12:32:08 +00:00
fix ([data-bind=backend-enabled]): remove quickfix and fix root cause of cf83f7507c
This commit is contained in:
@@ -12,7 +12,10 @@ const backendsEnabled$ = new rxjs.BehaviorSubject();
|
||||
export async function initStorage() {
|
||||
return await getConfig().pipe(
|
||||
rxjs.map(({ connections }) => connections),
|
||||
rxjs.tap((connections) => backendsEnabled$.next(Array.isArray(connections) ? connections : [])),
|
||||
rxjs.tap((connections) => {
|
||||
if (backendsEnabled$.value !== undefined) return;
|
||||
backendsEnabled$.next(Array.isArray(connections) ? connections : [])
|
||||
}),
|
||||
).toPromise();
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import { isAdmin$ } from "./model_admin_session.js";
|
||||
export default function AdminOnly(ctrlWrapped) {
|
||||
return (render) => {
|
||||
effect(isAdmin$().pipe(
|
||||
rxjs.distinctUntilChanged(),
|
||||
rxjs.map((isAdmin) => isAdmin ? ctrlWrapped : ctrlLogin),
|
||||
rxjs.tap((ctrl) => ctrl(render)),
|
||||
rxjs.catchError(ctrlError(render)),
|
||||
|
||||
@@ -9,9 +9,11 @@ const adminSession$ = rxjs.merge(
|
||||
rxjs.startWith(null),
|
||||
rxjs.mergeMap(() => ajax({ url: "/admin/api/session", responseType: "json" })),
|
||||
rxjs.map(({ responseJSON }) => responseJSON.result),
|
||||
rxjs.distinctUntilChanged(),
|
||||
)
|
||||
).pipe(rxjs.shareReplay(1));
|
||||
).pipe(
|
||||
rxjs.distinctUntilChanged(),
|
||||
rxjs.shareReplay(1)
|
||||
);
|
||||
|
||||
export function isAdmin$() {
|
||||
return adminSession$;
|
||||
|
||||
Reference in New Issue
Block a user