Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit491c8bb

Browse files
committed
remove myorg call on initial load
1 parent67643f6 commit491c8bb

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

‎client/packages/lowcoder/src/redux/reducers/uiReducers/usersReducer.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const initialState: UsersReduxState = {
2525
workspaces:{
2626
items:[],
2727
totalCount:0,
28-
currentOrg:null
28+
currentOrg:null,
29+
loading:false,
30+
isFetched:false,
2931

3032
}
3133
};
@@ -198,6 +200,14 @@ const usersReducer = createReducer(initialState, {
198200
apiKeys:action.payload,
199201
}),
200202

203+
[ReduxActionTypes.FETCH_WORKSPACES_INIT]:(state:UsersReduxState)=>({
204+
...state,
205+
workspaces:{
206+
...state.workspaces,
207+
loading:true,
208+
},
209+
}),
210+
201211

202212
[ReduxActionTypes.FETCH_WORKSPACES_SUCCESS]:(
203213
state:UsersReduxState,
@@ -208,7 +218,9 @@ const usersReducer = createReducer(initialState, {
208218
items:action.payload.isLoadMore
209219
?[...state.workspaces.items, ...action.payload.items]// Append for load more
210220
:action.payload.items,// Replace for new search/initial load
211-
totalCount:action.payload.totalCount
221+
totalCount:action.payload.totalCount,
222+
isFetched:true,
223+
loading:false,
212224
}
213225
}),
214226

@@ -234,6 +246,8 @@ export interface UsersReduxState {
234246
items:Org[];// Current page of workspaces
235247
totalCount:number;// Total workspaces available
236248
currentOrg:Org|null;
249+
loading:boolean;
250+
isFetched:boolean;
237251
};
238252
}
239253

‎client/packages/lowcoder/src/redux/sagas/userSagas.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ export function* getUserSaga() {
7777
type:ReduxActionTypes.FETCH_USER_DETAILS_SUCCESS,
7878
payload:user,
7979
});
80-
// fetch all workspaces and store in redux
81-
yieldput(fetchWorkspacesAction(1,10));
80+
8281
}
8382
}catch(error:any){
8483
yieldput({

‎client/packages/lowcoder/src/util/useWorkspaceManager.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import{useReducer,useEffect,useCallback,useMemo}from'react';
2-
import{useSelector}from'react-redux';
2+
import{useDispatch,useSelector}from'react-redux';
33
import{debounce}from'lodash';
44
import{Org}from'constants/orgConstants';
55
import{getWorkspaces}from'redux/selectors/orgSelectors';
6+
import{fetchWorkspacesAction}from'redux/reduxActions/orgActions';
67
importUserApifrom'api/userApi';
78

89
// State interface for the workspace manager
@@ -73,6 +74,7 @@ export function useWorkspaceManager({
7374
}:UseWorkspaceManagerOptions){
7475
// Get workspaces from Redux
7576
constworkspaces=useSelector(getWorkspaces);
77+
constreduxDispatch=useDispatch();
7678

7779
// Initialize reducer with Redux total count
7880
const[state,dispatch]=useReducer(workspaceReducer,{
@@ -81,6 +83,14 @@ export function useWorkspaceManager({
8183
});
8284

8385

86+
87+
/* ----- first-time fetch ------------------------------------------------ */
88+
useEffect(()=>{
89+
if(!workspaces.isFetched&&!workspaces.loading){
90+
reduxDispatch(fetchWorkspacesAction(1,pageSize));
91+
}
92+
},[workspaces.isFetched,workspaces.loading,pageSize,reduxDispatch]);
93+
8494
// API call to fetch workspaces (memoized for stable reference)
8595
constfetchWorkspacesPage=useCallback(
8696
async(page:number,search?:string)=>{
@@ -177,7 +187,7 @@ export function useWorkspaceManager({
177187
// State
178188
searchTerm:state.searchTerm,
179189
currentPage:state.currentPage,
180-
isLoading:state.isLoading,
190+
isLoading:state.isLoading||workspaces.loading,
181191
displayWorkspaces,
182192
totalCount:currentTotalCount,
183193

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp