mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
common: do not render undefined items
This commit is contained in:
@@ -39,7 +39,8 @@ export function useResolvedItem<TItemType extends ItemType>(
|
|||||||
[index, items]
|
[index, items]
|
||||||
);
|
);
|
||||||
|
|
||||||
if (result.status === "rejected" || !result.value) return null;
|
if (result.status === "rejected" || !result.value || !result.value.item)
|
||||||
|
return null;
|
||||||
if (type && result.value.item.type !== type) return null;
|
if (type && result.value.item.type !== type) return null;
|
||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
@@ -53,7 +54,8 @@ export function useUnresolvedItem<TItemType extends ItemType>(
|
|||||||
const { index, items, type } = options;
|
const { index, items, type } = options;
|
||||||
const result = usePromise(() => items.item(index), [index, items]);
|
const result = usePromise(() => items.item(index), [index, items]);
|
||||||
|
|
||||||
if (result.status === "rejected" || !result.value) return null;
|
if (result.status === "rejected" || !result.value || !result.value.item)
|
||||||
|
return null;
|
||||||
if (type && result.value.item.type !== type) return null;
|
if (type && result.value.item.type !== type) return null;
|
||||||
return result.value;
|
return result.value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,11 +81,11 @@ export class VirtualizedGrouping<T> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
item(index: number): Promise<{ item: T; group?: GroupHeader }>;
|
item(index: number): Promise<{ item?: T; group?: GroupHeader }>;
|
||||||
item(
|
item(
|
||||||
index: number,
|
index: number,
|
||||||
operate: BatchOperator<T>
|
operate: BatchOperator<T>
|
||||||
): Promise<{ item: T; group?: GroupHeader; data: unknown }>;
|
): Promise<{ item?: T; group?: GroupHeader; data: unknown }>;
|
||||||
async item(index: number, operate?: BatchOperator<T>) {
|
async item(index: number, operate?: BatchOperator<T>) {
|
||||||
const batchIndex = Math.floor(index / this.batchSize);
|
const batchIndex = Math.floor(index / this.batchSize);
|
||||||
const { items, groups, data } =
|
const { items, groups, data } =
|
||||||
|
|||||||
Reference in New Issue
Block a user