Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new commit from storage #57

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/lib/components/RPCMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
// @ts-nocheck
import { methods } from "$lib/types/all-methods.js";
import { currentMethod, currentRPC } from "$lib/stores/current-method.js";
import { fly } from "svelte/transition";
Expand All @@ -8,21 +7,35 @@
let questions = Object.keys(methods).map((method, index) => {
return { id: index + 1, text: method };
});
let rpcUrlValue = "";

export let answer = "";

if (typeof window !== 'undefined') {
// Initialize from localStorage
answer = localStorage.getItem('rpcUrl') || "";
}

let isVisible = false;

$: {
rpcUrlValue = answer;
if (!answer && typeof window !== 'undefined') {
answer = localStorage.getItem('rpcUrl') || "";
}

let rpcUrlValue = answer;

if (!rpcUrlValue) {
currentRPC.set("https://api.mainnet-beta.solana.com");
}
// Check if the URL starts with "https://"
if (!rpcUrlValue.startsWith("https://") && rpcUrlValue !== "") {
rpcUrlValue = "https://" + rpcUrlValue;
}
currentRPC.set(rpcUrlValue);
}

export let answer = "";
let isVisible = false;
if (typeof window !== 'undefined') {
localStorage.setItem('rpcUrl', rpcUrlValue); // Save to localStorage
}
}

onMount(() => {
setTimeout(() => {
Expand All @@ -34,7 +47,7 @@
{#if isVisible}
<div
class="my-2 flex justify-center"
transition:fly={{ y: 200, duration: 1800 }}

Check warning on line 50 in src/lib/components/RPCMenu.svelte

View workflow job for this annotation

GitHub Actions / build (18.x)

Expected object keys to be in ascending order. 'duration' should be before 'y'
>
<form class="flex w-full justify-center">
<div
Expand Down Expand Up @@ -62,7 +75,7 @@
type="text"
bind:value={answer}
placeholder="Drop a Solana RPC endpoint here"
class="input-bordered input input w-full border-zinc-900 bg-transparent text-gray-300"
class="input-bordered input w-full border-zinc-900 bg-transparent text-gray-300"
/>
</div>
</div>
Expand Down
Loading