mirror of
https://github.com/Funkoala14/CreatorCenter_OOIN.git
synced 2025-06-08 05:28:14 +08:00
[dev]fix creators slice
This commit is contained in:
parent
4c22e12101
commit
443c253014
@ -54,7 +54,7 @@ export default function CreatorList({ path }) {
|
|||||||
// 处理全选/取消全选
|
// 处理全选/取消全选
|
||||||
const handleSelectAll = (e) => {
|
const handleSelectAll = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
dispatch(selectAllCreators());
|
dispatch(selectAllCreators('database'));
|
||||||
} else {
|
} else {
|
||||||
dispatch(clearCreatorSelection());
|
dispatch(clearCreatorSelection());
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ export default function PrivateCreatorList({ path }) {
|
|||||||
// 处理全选/取消全选
|
// 处理全选/取消全选
|
||||||
const handleSelectAll = (e) => {
|
const handleSelectAll = (e) => {
|
||||||
if (e.target.checked) {
|
if (e.target.checked) {
|
||||||
dispatch(selectAllCreators());
|
dispatch(selectAllCreators('database'));
|
||||||
} else {
|
} else {
|
||||||
dispatch(clearCreatorSelection());
|
dispatch(clearCreatorSelection());
|
||||||
}
|
}
|
||||||
|
@ -259,8 +259,12 @@ const creatorsSlice = createSlice({
|
|||||||
state.selectedCreators.push(creatorId);
|
state.selectedCreators.push(creatorId);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectAllCreators: (state) => {
|
selectAllCreators: (state, action) => {
|
||||||
state.selectedCreators = state.creators.map((creator) => creator.id);
|
if (action.payload === 'database') {
|
||||||
|
state.selectedCreators = state.publicCreators.map((creator) => creator.id);
|
||||||
|
} else {
|
||||||
|
state.selectedCreators = state.privateCreators.map((creator) => creator.id);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
clearCreatorSelection: (state) => {
|
clearCreatorSelection: (state) => {
|
||||||
state.selectedCreators = [];
|
state.selectedCreators = [];
|
||||||
@ -279,7 +283,7 @@ const creatorsSlice = createSlice({
|
|||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder
|
builder
|
||||||
.addCase(fetchCreators.pending, (state) => {
|
.addCase(fetchCreators.pending, (state) => {
|
||||||
if (state.creators.length === 0) {
|
if (state.publicCreators.length === 0) {
|
||||||
state.status = 'loading';
|
state.status = 'loading';
|
||||||
} else {
|
} else {
|
||||||
state.isLoadingMore = true;
|
state.isLoadingMore = true;
|
||||||
@ -303,7 +307,7 @@ const creatorsSlice = createSlice({
|
|||||||
state.error = action.error.message;
|
state.error = action.error.message;
|
||||||
})
|
})
|
||||||
.addCase(fetchPrivateCreators.pending, (state) => {
|
.addCase(fetchPrivateCreators.pending, (state) => {
|
||||||
if (state.creators?.length === 0) {
|
if (state.privateCreators?.length === 0) {
|
||||||
state.status = 'loading';
|
state.status = 'loading';
|
||||||
} else {
|
} else {
|
||||||
state.isLoadingMore = true;
|
state.isLoadingMore = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user