Skip to content

Commit

Permalink
fix (admin): auth middleware toggle state
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Mar 11, 2024
1 parent 9e5d978 commit 0326a67
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default async function(render) {
effect(init$.pipe(
rxjs.mergeMap(($nodes) => $nodes),
rxjs.mergeMap(($node) => onClick($node)),
rxjs.map(($node) => toggleMiddleware($node.getAttribute("data-label"))),
rxjs.mergeMap(($node) => toggleMiddleware($node.getAttribute("data-label"))),
saveMiddleware(),
));

Expand Down
11 changes: 8 additions & 3 deletions public/assets/pages/adminpage/ctrl_backend_state.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,14 @@ export function getMiddlewareEnabled() {
}

export function toggleMiddleware(type) {
const newValue = middlewareEnabled$.value === type ? null : type;
middlewareEnabled$.next(newValue);
return newValue;
return middlewareEnabled$.pipe(
rxjs.first(),
rxjs.map((oldValue) => {
const newValue = oldValue === type ? null : type;
middlewareEnabled$.next(newValue);
return newValue;
}),
);
}

export function getState() {
Expand Down

0 comments on commit 0326a67

Please sign in to comment.