perf: server navigation
This commit is contained in:
@@ -12,7 +12,8 @@ import {
|
||||
of,
|
||||
from,
|
||||
EMPTY,
|
||||
merge
|
||||
merge,
|
||||
timer
|
||||
} from 'rxjs';
|
||||
import {
|
||||
map,
|
||||
@@ -60,6 +61,8 @@ type BlockedRoomAccessAction =
|
||||
| ReturnType<typeof RoomsActions.forgetRoom>
|
||||
| ReturnType<typeof RoomsActions.joinRoomFailure>;
|
||||
|
||||
const VIEW_SERVER_LOAD_DELAY_MS = 75;
|
||||
|
||||
@Injectable()
|
||||
export class RoomsEffects {
|
||||
private actions$ = inject(Actions);
|
||||
@@ -608,7 +611,12 @@ export class RoomsEffects {
|
||||
navigationRequestVersion
|
||||
});
|
||||
|
||||
this.router.navigate(['/room', room.id]);
|
||||
window.setTimeout(() => {
|
||||
if (this.signalingConnection.isCurrentRoomNavigation(room.id, navigationRequestVersion)) {
|
||||
void this.router.navigate(['/room', room.id]);
|
||||
}
|
||||
}, 0);
|
||||
|
||||
return of(RoomsActions.viewServerSuccess({ room }));
|
||||
};
|
||||
|
||||
@@ -634,7 +642,9 @@ export class RoomsEffects {
|
||||
onViewServerSuccess$ = createEffect(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(RoomsActions.viewServerSuccess),
|
||||
mergeMap(({ room }) => [MessagesActions.loadMessages({ roomId: room.id }), UsersActions.loadBans()])
|
||||
switchMap(({ room }) => timer(VIEW_SERVER_LOAD_DELAY_MS).pipe(
|
||||
mergeMap(() => [MessagesActions.loadMessages({ roomId: room.id }), UsersActions.loadBans()])
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user