mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
fix: view api
This commit is contained in:
@@ -77,10 +77,9 @@ export const useRecastView = () => {
|
|||||||
|
|
||||||
const addView = useCallback(
|
const addView = useCallback(
|
||||||
async (newView: RecastViewWithoutId) => {
|
async (newView: RecastViewWithoutId) => {
|
||||||
await setViews([
|
const newViewWithId = { ...newView, id: genViewId() } as RecastView;
|
||||||
...recastViews,
|
await setViews([...recastViews, newViewWithId]);
|
||||||
{ ...newView, id: genViewId() } as RecastView,
|
return newViewWithId;
|
||||||
]);
|
|
||||||
},
|
},
|
||||||
[recastViews, setViews]
|
[recastViews, setViews]
|
||||||
);
|
);
|
||||||
@@ -88,7 +87,7 @@ export const useRecastView = () => {
|
|||||||
const updateView = useCallback(
|
const updateView = useCallback(
|
||||||
async (newView: RecastView) => {
|
async (newView: RecastView) => {
|
||||||
const idx = recastViews.findIndex(v => v.id === newView.id);
|
const idx = recastViews.findIndex(v => v.id === newView.id);
|
||||||
if (!idx) {
|
if (idx === -1) {
|
||||||
throw new Error('Failed to find view with id ' + newView.id);
|
throw new Error('Failed to find view with id ' + newView.id);
|
||||||
}
|
}
|
||||||
await setViews([
|
await setViews([
|
||||||
@@ -141,7 +140,7 @@ export const useRecastView = () => {
|
|||||||
recastViews,
|
recastViews,
|
||||||
setCurrentView,
|
setCurrentView,
|
||||||
addView,
|
addView,
|
||||||
// updateView,
|
updateView,
|
||||||
renameView,
|
renameView,
|
||||||
removeView,
|
removeView,
|
||||||
// TODO reorder API
|
// TODO reorder API
|
||||||
|
|||||||
Reference in New Issue
Block a user