fix: model list not refresh

This commit is contained in:
jialin
2024-07-12 16:17:47 +08:00
parent d839464a05
commit 0a0b96735c
13 changed files with 63 additions and 35 deletions
+7
View File
@@ -1,3 +1,4 @@
import _ from 'lodash';
import { useRef } from 'react';
export default function useContainerScroll(
@@ -8,8 +9,14 @@ export default function useContainerScroll(
const scroller = useRef(container);
const optionsRef = useRef(options);
const toBottomFlag = useRef(options?.toBottom);
const debunceResetWheeled = _.debounce(() => {
isWheeled.current = false;
}, 5000);
const handleContentWheel = (e: any) => {
isWheeled.current = true;
debunceResetWheeled();
};
const scrollerRun = () => {
+8 -3
View File
@@ -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);
}
});