fix:修复部分情况下数据不同步问题

This commit is contained in:
fanxb 2020-02-01 22:56:06 +08:00
parent 8a82006a0b
commit b7c8fdc40a
3 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@ import httpUtil from "../../../util/httpUtil";
import * as action from "../../../redux/action/BookmarkTreeOverview";
import { connect } from "react-redux";
import { addNode } from "../../../util/cacheUtil";
import { addNode, getBookmarkList } from "../../../util/cacheUtil";
function mapStateToProps(state) {
return state[action.DATA_NAME];
@ -173,7 +173,7 @@ class AddModal extends React.Component {
if (!currentAddFolder) {
treeData.push(res);
}
updateTreeData(treeData);
updateTreeData([...getBookmarkList("")]);
closeModal();
this.setState({ isLoading: false });
}

View File

@ -4,7 +4,7 @@ import { Modal, Button, Tree, message, Menu, Dropdown } from "antd";
import styles from "./index.module.less";
import IconFont from "../../../components/IconFont";
import { stopTransfer } from "../../../util/eventUtil";
import { deleteNodes, moveNode } from "../../../util/cacheUtil";
import { deleteNodes, moveNode, getBookmarkList } from "../../../util/cacheUtil";
const { TreeNode } = Tree;
function menuVisible(item, visible) {
@ -175,7 +175,7 @@ function deleteBookmark(nodeList) {
treeData.splice(treeData.indexOf(item), 1);
});
changeCheckedKeys([], null);
updateTreeData([...treeData]);
updateTreeData([...getBookmarkList("")]);
resolve();
})
.catch(() => reject());
@ -207,7 +207,7 @@ export async function onDrop(info) {
.post("/bookmark/moveNode", body)
.then(res => {
message.success("移动完成");
updateTreeData([...treeData]);
updateTreeData([...getBookmarkList("")]);
this.setState({ isLoading: false });
})
.catch(() => {

View File

@ -50,7 +50,7 @@ class OverView extends React.Component {
async componentDidMount() {
this.props.refresh();
await cacheBookmarkData();
this.props.updateTreeData([...getBookmarkList("")]);
this.props.updateTreeData(getBookmarkList(""));
this.props.changeIsInit(true);
}
@ -58,12 +58,12 @@ class OverView extends React.Component {
* 异步加载
*/
loadData = e => {
const { loadedKeys, treeData } = this.props;
const { loadedKeys } = this.props;
return new Promise(resolve => {
const item = e.props.dataRef;
const newPath = item.path + "." + item.bookmarkId;
item.children = getBookmarkList(newPath);
this.props.updateTreeData([...treeData]);
this.props.updateTreeData([...getBookmarkList("")]);
loadedKeys.push(item.bookmarkId.toString());
this.props.changeLoadedKeys(loadedKeys);
resolve();