|
1 | 1 | import { createAsyncThunk } from "@reduxjs/toolkit"; |
2 | 2 | import { ProfileDescription } from "core/config/ConfigHandler"; |
3 | | -import { OrganizationDescription } from "core/config/ProfileLifecycleManager"; |
4 | 3 | import { ThunkApiType } from "../../store"; |
5 | | -import { |
6 | | - setAvailableProfiles, |
7 | | - setOrganizations, |
8 | | - setSelectedOrganizationId, |
9 | | - setSelectedProfile, |
10 | | -} from "./slice"; |
| 4 | +import { setAvailableProfiles, setSelectedProfile } from "./slice"; |
11 | 5 |
|
12 | 6 | export const selectProfileThunk = createAsyncThunk< |
13 | 7 | void, |
@@ -89,45 +83,3 @@ export const updateProfilesThunk = createAsyncThunk< |
89 | 83 | // This will trigger reselection if needed |
90 | 84 | dispatch(selectProfileThunk(selectedProfileId)); |
91 | 85 | }); |
92 | | - |
93 | | -export const selectOrgThunk = createAsyncThunk< |
94 | | - void, |
95 | | - string | null, |
96 | | - ThunkApiType |
97 | | ->("session/selectOrg", async (id, { dispatch, extra, getState }) => { |
98 | | - const state = getState(); |
99 | | - const initialId = state.profiles.selectedOrganizationId; |
100 | | - let newId = id; |
101 | | - |
102 | | - // If no orgs, force clear |
103 | | - if (state.profiles.organizations.length === 0) { |
104 | | - newId = null; |
105 | | - } else if (newId) { |
106 | | - // If new id doesn't match an existing org, clear it |
107 | | - if (!state.profiles.organizations.find((o) => o.id === newId)) { |
108 | | - newId = null; |
109 | | - } |
110 | | - } |
111 | | - // Unlike profiles, don't fallback to the first org, |
112 | | - // Fallback to Personal (org = null) |
113 | | - |
114 | | - if (initialId !== newId) { |
115 | | - dispatch(setAvailableProfiles(null)); |
116 | | - dispatch(setSelectedOrganizationId(newId)); |
117 | | - extra.ideMessenger.post("didChangeSelectedOrg", { |
118 | | - id: newId, |
119 | | - }); |
120 | | - } |
121 | | -}); |
122 | | - |
123 | | -export const updateOrgsThunk = createAsyncThunk< |
124 | | - void, |
125 | | - OrganizationDescription[], |
126 | | - ThunkApiType |
127 | | ->("session/updateOrgs", async (orgs, { dispatch, getState }) => { |
128 | | - const state = getState(); |
129 | | - dispatch(setOrganizations(orgs)); |
130 | | - |
131 | | - // This will trigger reselection if needed |
132 | | - dispatch(selectOrgThunk(state.profiles.selectedOrganizationId)); |
133 | | -}); |
0 commit comments