mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-12-11 10:13:55 -06:00
Ensured server is properly loaded before trying to render any children component
This commit is contained in:
parent
853032ac7f
commit
bc8905ee7f
@ -31,7 +31,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
|
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
|
||||||
dispatch({ type: CREATE_SHORT_URL_START });
|
dispatch({ type: CREATE_SHORT_URL_START });
|
||||||
|
|
||||||
const { createShortUrl } = await buildShlinkApiClient(getState);
|
const { createShortUrl } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -32,7 +32,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
||||||
dispatch({ type: DELETE_SHORT_URL_START });
|
dispatch({ type: DELETE_SHORT_URL_START });
|
||||||
|
|
||||||
const { deleteShortUrl } = await buildShlinkApiClient(getState);
|
const { deleteShortUrl } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -58,7 +58,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const listShortUrls = (buildShlinkApiClient) => (params = {}) => async (dispatch, getState) => {
|
export const listShortUrls = (buildShlinkApiClient) => (params = {}) => async (dispatch, getState) => {
|
||||||
dispatch({ type: LIST_SHORT_URLS_START });
|
dispatch({ type: LIST_SHORT_URLS_START });
|
||||||
|
|
||||||
const { listShortUrls } = await buildShlinkApiClient(getState);
|
const { listShortUrls } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -26,7 +26,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => {
|
export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => {
|
||||||
dispatch({ type: DELETE_TAG_START });
|
dispatch({ type: DELETE_TAG_START });
|
||||||
|
|
||||||
const { deleteTags } = await buildShlinkApiClient(getState);
|
const { deleteTags } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -31,7 +31,6 @@ export const editTag = (buildShlinkApiClient, colorGenerator) => (oldName, newNa
|
|||||||
getState
|
getState
|
||||||
) => {
|
) => {
|
||||||
dispatch({ type: EDIT_TAG_START });
|
dispatch({ type: EDIT_TAG_START });
|
||||||
|
|
||||||
const { editTag } = await buildShlinkApiClient(getState);
|
const { editTag } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,21 +1,16 @@
|
|||||||
import { wait } from '../utils';
|
|
||||||
import ShlinkApiClient from './ShlinkApiClient';
|
import ShlinkApiClient from './ShlinkApiClient';
|
||||||
|
|
||||||
const apiClients = {};
|
const apiClients = {};
|
||||||
|
|
||||||
const getSelectedServerFromState = async (getState) => {
|
const getSelectedServerFromState = (getState) => {
|
||||||
const { selectedServer } = getState();
|
const { selectedServer } = getState();
|
||||||
|
|
||||||
if (!selectedServer) {
|
|
||||||
return wait(250).then(() => getSelectedServerFromState(getState));
|
|
||||||
}
|
|
||||||
|
|
||||||
return selectedServer;
|
return selectedServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
const buildShlinkApiClient = (axios) => async (getStateOrSelectedServer) => {
|
const buildShlinkApiClient = (axios) => async (getStateOrSelectedServer) => {
|
||||||
const { url, apiKey } = typeof getStateOrSelectedServer === 'function'
|
const { url, apiKey } = typeof getStateOrSelectedServer === 'function'
|
||||||
? await getSelectedServerFromState(getStateOrSelectedServer)
|
? getSelectedServerFromState(getStateOrSelectedServer)
|
||||||
: getStateOrSelectedServer;
|
: getStateOrSelectedServer;
|
||||||
const clientKey = `${url}_${apiKey}`;
|
const clientKey = `${url}_${apiKey}`;
|
||||||
|
|
||||||
|
|||||||
@ -53,8 +53,6 @@ export const useToggle = (initialValue = false) => {
|
|||||||
return [ flag, () => setFlag(!flag) ];
|
return [ flag, () => setFlag(!flag) ];
|
||||||
};
|
};
|
||||||
|
|
||||||
export const wait = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
||||||
|
|
||||||
export const compareVersions = (firstVersion, operator, secondVersion) => compare(
|
export const compareVersions = (firstVersion, operator, secondVersion) => compare(
|
||||||
firstVersion,
|
firstVersion,
|
||||||
secondVersion,
|
secondVersion,
|
||||||
|
|||||||
@ -28,7 +28,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const getShortUrlDetail = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
export const getShortUrlDetail = (buildShlinkApiClient) => (shortCode, domain) => async (dispatch, getState) => {
|
||||||
dispatch({ type: GET_SHORT_URL_DETAIL_START });
|
dispatch({ type: GET_SHORT_URL_DETAIL_START });
|
||||||
|
|
||||||
const { getShortUrl } = await buildShlinkApiClient(getState);
|
const { getShortUrl } = await buildShlinkApiClient(getState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -51,7 +51,6 @@ export default handleActions({
|
|||||||
|
|
||||||
export const getShortUrlVisits = (buildShlinkApiClient) => (shortCode, query) => async (dispatch, getState) => {
|
export const getShortUrlVisits = (buildShlinkApiClient) => (shortCode, query) => async (dispatch, getState) => {
|
||||||
dispatch({ type: GET_SHORT_URL_VISITS_START });
|
dispatch({ type: GET_SHORT_URL_VISITS_START });
|
||||||
|
|
||||||
const { getShortUrlVisits } = await buildShlinkApiClient(getState);
|
const { getShortUrlVisits } = await buildShlinkApiClient(getState);
|
||||||
const itemsPerPage = 5000;
|
const itemsPerPage = 5000;
|
||||||
const isLastPage = ({ currentPage, pagesCount }) => currentPage >= pagesCount;
|
const isLastPage = ({ currentPage, pagesCount }) => currentPage >= pagesCount;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user