Starting with form

This commit is contained in:
minimo-io 2024-04-22 19:55:49 -03:00
parent 15a3de3a3d
commit d40206c74d
3 changed files with 54 additions and 12 deletions

View File

@ -5,7 +5,6 @@ Let promote some reciprocity here! 😹
## ToDo ## ToDo
- Add % value for progress.
- Add forms - Add forms
- Query for userdata, at least for no-followers - Query for userdata, at least for no-followers
- Remove SvelteKit (just Vite + Svelte). - Remove SvelteKit (just Vite + Svelte).

View File

@ -1,4 +1,5 @@
export const relays = [ export const relays = [
"wss://cache2.primal.net/v1",
"wss://relay.hodl.ar", "wss://relay.hodl.ar",
"wss://relay.current.fyi", "wss://relay.current.fyi",
"wss://nostr.wine", "wss://nostr.wine",
@ -14,7 +15,8 @@ export const relays = [
"wss://nostr.bitcoiner.social", "wss://nostr.bitcoiner.social",
"wss://nostr.mutinywallet.com", "wss://nostr.mutinywallet.com",
"wss://relay.current.fyi", "wss://relay.current.fyi",
"wss://relay.plebstr.com", // "wss://relay.plebstr.com",
// "wss://nostr-pub.wellorder.net", // "wss://nostr-pub.wellorder.net",
// "wss://brb.io", // "wss://brb.io",
// "wss://eden.nostr.land", // "wss://eden.nostr.land",

View File

@ -4,9 +4,11 @@
import { fetchUserProfile } from "$lib/fetchs"; import { fetchUserProfile } from "$lib/fetchs";
import { relays } from "$lib/data/relays"; import { relays } from "$lib/data/relays";
let npubToQuery = "npub1wujhdsytm3w6g0mpsqh8v7ezx83jcm64dlkwuqgm5v8lv0pds55ssudkw0"; // let npubToQuery = "npub1wujhdsytm3w6g0mpsqh8v7ezx83jcm64dlkwuqgm5v8lv0pds55ssudkw0";
let userName; let npubToQuery = "";
let userThumb; let querying = false;
let userName = "";
let userThumb = "";
let followsCount; let followsCount;
let followBackCount = 0; let followBackCount = 0;
@ -14,11 +16,11 @@
let unknownFollowBack = 0; let unknownFollowBack = 0;
let totalCountOfContactsChecked = 0; let totalCountOfContactsChecked = 0;
$: progress = ((totalCountOfContactsChecked / followsCount) * 100).toFixed();
let originalFollow = []; let originalFollow = [];
let notFollowersBack = []; let notFollowersBack = [];
function updateNpub() {}
async function bootstrap() { async function bootstrap() {
try { try {
const ndk = new NDK({ const ndk = new NDK({
@ -89,14 +91,37 @@
} }
} }
bootstrap(); //bootstrap();
</script> </script>
<h1>Who does not follows you on Nostr</h1> <h1>Who does not follows you on Nostr</h1>
{#if !userThumb}
<form class="npub-form">
<input type="text" bind:value={npubToQuery} placeholder={npubToQuery} />
<input
type="button"
on:click={async () => {
querying = true;
userName = "";
userThumb = "";
originalFollow = [];
notFollowersBack = [];
followBackCount = 0;
notFollowBackCount = 0;
unknownFollowBack = 0;
totalCountOfContactsChecked = 0;
bootstrap();
}}
value="Analyze"
/>
</form>
{#if !querying}
{npubToQuery} {npubToQuery}
{/if} {/if}
<hr /> <hr />
{#if userThumb} {#if userThumb}
<div class="user-box"> <div class="user-box">
<img src={userThumb} width="50" style="border-radius:100%;" alt="user-thumb" /> <img src={userThumb} width="50" style="border-radius:100%;" alt="user-thumb" />
@ -108,9 +133,16 @@
<span title="Actually Counted">{notFollowBackCount}</span> <span title="Actually Counted">{notFollowBackCount}</span>
/ <span title="Actualy counted">{notFollowersBack.length}</span> / <span title="Actualy counted">{notFollowersBack.length}</span>
<br /> <br />
<p> {#if progress < 100}
Progress = {totalCountOfContactsChecked} of {followBackCount + notFollowBackCount + unknownFollowBack} <p>
</p> Progress =
<strong>{progress}%</strong> - {totalCountOfContactsChecked} of {followBackCount +
notFollowBackCount +
unknownFollowBack}
</p>
{:else}
<p><strong>Completed!</strong></p>
{/if}
<hr /> <hr />
<br /> <br />
Results ({originalFollow.length}) Results ({originalFollow.length})
@ -140,6 +172,15 @@
{/each} {/each}
</ul> --> </ul> -->
</div> </div>
{:else if !querying}
<p>Let's find out who does not follow you back in Nostr!</p>
{:else} {:else}
<div class="loader">Loading data...</div> <div class="loader">Loading data...</div>
{/if} {/if}
<style>
.npub-form input[type="text"] {
padding: 5px;
width: 50%;
}
</style>