mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-23 05:13:12 +03:00
fix(core): fix active view undefined (#7161)
This commit is contained in:
parent
6abb401a2c
commit
d791ab73ba
@ -37,6 +37,7 @@ export class Workbench extends Entity {
|
||||
);
|
||||
|
||||
active(index: number) {
|
||||
index = Math.max(0, Math.min(index, this.views$.value.length - 1));
|
||||
this.activeViewIndex$.next(index);
|
||||
}
|
||||
|
||||
@ -122,9 +123,14 @@ export class Workbench extends Entity {
|
||||
}
|
||||
|
||||
moveView(from: number, to: number) {
|
||||
from = Math.max(0, Math.min(from, this.views$.value.length - 1));
|
||||
to = Math.max(0, Math.min(to, this.views$.value.length - 1));
|
||||
if (from === to) return;
|
||||
const views = [...this.views$.value];
|
||||
const [removed] = views.splice(from, 1);
|
||||
views.splice(to, 0, removed);
|
||||
const fromView = views[from];
|
||||
const toView = views[to];
|
||||
views[to] = fromView;
|
||||
views[from] = toView;
|
||||
this.views$.next(views);
|
||||
this.active(to);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user