|
1 |
| -import { call, put, select, takeLatest, all } from 'redux-saga/effects'; |
| 1 | +import { call, put, select, takeLatest, all, take } from 'redux-saga/effects'; |
2 | 2 | import { fetchSubscriptionsAction } from 'redux/reduxActions/subscriptionActions';
|
3 | 3 | import { searchCustomersSubscriptions, Subscription } from 'api/subscriptionApi';
|
4 | 4 | import { fetchSubscriptionsSuccess, fetchSubscriptionsError } from 'redux/reduxActions/subscriptionActions';
|
5 | 5 | import { LowcoderSearchCustomer } from 'api/subscriptionApi';
|
6 | 6 | import { getUser, getCurrentUser } from 'redux/selectors/usersSelectors';
|
| 7 | +import { getDeploymentId } from "redux/selectors/configSelectors"; |
7 | 8 | import { CurrentUser, User } from '@lowcoder-ee/constants/userConstants';
|
8 | 9 | import { ReduxActionTypes } from '@lowcoder-ee/constants/reduxActionConstants';
|
9 | 10 |
|
10 | 11 | function* fetchSubscriptionsSaga(action: ReturnType<typeof fetchSubscriptionsAction>) {
|
11 | 12 |
|
12 | 13 | try {
|
| 14 | + |
| 15 | + // wait for deploymentId to be available |
| 16 | + yield take(ReduxActionTypes.FETCH_DEPLOYMENT_ID_SUCCESS); |
| 17 | + |
13 | 18 | const user: User = yield select(getUser);
|
14 | 19 | const currentUser: CurrentUser = yield select(getCurrentUser);
|
15 | 20 | const orgID = user.currentOrgId;
|
16 | 21 | const domain = `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}`;
|
17 |
| - const hostIdenticator = "lowcoder-test"; |
| 22 | + |
| 23 | + let hostIdenticator : string = yield select(getDeploymentId); |
| 24 | + |
| 25 | + // Poll until deploymentId is available |
| 26 | + while (!hostIdenticator) { |
| 27 | + yield delay(100); // wait for 100ms |
| 28 | + hostIdenticator = yield select(getDeploymentId); |
| 29 | + } |
18 | 30 |
|
19 | 31 | const subscriptionSearchCustomer: LowcoderSearchCustomer = {
|
20 | 32 | hostname: domain,
|
|
0 commit comments