fix: model list not refresh
This commit is contained in:
@@ -35,6 +35,7 @@ export function useUpdateChunkedList(options: {
|
||||
const ids = data?.ids || [];
|
||||
// CREATE
|
||||
if (data?.type === WatchEventType.CREATE) {
|
||||
const newDataList = _.cloneDeep(dataList);
|
||||
_.each(collections, (item: any) => {
|
||||
const updateIndex = _.findIndex(
|
||||
dataList,
|
||||
@@ -42,12 +43,13 @@ export function useUpdateChunkedList(options: {
|
||||
);
|
||||
if (updateIndex === -1) {
|
||||
const updateItem = _.cloneDeep(item);
|
||||
options.setDataList?.((preDataList: any) => {
|
||||
return _.concat(updateItem, preDataList);
|
||||
});
|
||||
newDataList.push(updateItem);
|
||||
}
|
||||
console.log('create=========', updateIndex, dataList, collections);
|
||||
});
|
||||
options.setDataList?.(() => {
|
||||
return newDataList;
|
||||
});
|
||||
}
|
||||
// DELETE
|
||||
if (data?.type === WatchEventType.DELETE) {
|
||||
@@ -71,6 +73,9 @@ export function useUpdateChunkedList(options: {
|
||||
if (updateIndex > -1) {
|
||||
const updateItem = _.cloneDeep(item);
|
||||
updatedDataList[updateIndex] = updateItem;
|
||||
} else if (updateIndex === -1) {
|
||||
const updateItem = _.cloneDeep(item);
|
||||
updatedDataList.push(updateItem);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user