Skip to content

Commit

Permalink
loading
Browse files Browse the repository at this point in the history
  • Loading branch information
solhosty committed Aug 30, 2023
1 parent e9db19f commit 4d9d81b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/components/Request.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import capitalize from "$lib/utils/capitalize";
import { updateParams } from "$lib/utils/params";
import { handleRun } from "$lib/utils/handle-run";
import { isLoading } from "$lib/stores/response-store";
let selectedMethod;
let rpcError = false;
Expand All @@ -35,12 +36,14 @@
}
async function runMethod() {
isLoading.set(true);
const { rpcError: error, result } = await handleRun(
selectedMethod,
params,
$currentRPC
);
rpcError = error;
isLoading.set(false);
}
</script>

Expand Down
10 changes: 9 additions & 1 deletion src/lib/components/Response.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
isResponse,
responseTime,
copyResponse,
isLoading,
} from "$lib/stores/response-store.js";
import { currentMethod } from "$lib/stores/current-method.js";
import formatHighlight from "json-format-highlight";
Expand Down Expand Up @@ -58,7 +59,14 @@
);
</script>

{#if selectedMethod && responseStatus == "true"}
{#if $isLoading == true}
<img
class="m-auto w-20 justify-center"
src="spinner.svg"
alt=""
/>
{/if}
{#if selectedMethod && responseStatus == "true" && $isLoading == false}
<div class="max-h-100 p-2 text-white opacity-80">
<div
class="max-h-100 rounded-xl border border-zinc-900 border-opacity-50 p-4 shadow-lg"
Expand Down
1 change: 1 addition & 0 deletions src/lib/stores/response-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export const responseStore = writable("");
export const isResponse = writable("false");
export const responseTime = writable("");
export const copyResponse = writable("");
export const isLoading = writable(false);
52 changes: 52 additions & 0 deletions static/spinner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4d9d81b

Please sign in to comment.