diff --git a/nostr-followback/README.md b/nostr-followback/README.md index 7c312f2..5015273 100644 --- a/nostr-followback/README.md +++ b/nostr-followback/README.md @@ -5,8 +5,7 @@ Let promote some reciprocity here! 😹 ## ToDo -- Actually load builds at minimo.io/app/ or something alike. -- Ask community for help about the bug (see below) so I can keep understanding the protocol and the library. +- Create groups to checks to fire simultaneously instad of one by one (to remember: fireing all the `fetchProfile` at once for a given npub resulted in a permanent halt of the process -mainly for big users). Maybe using https://lodash.com/docs `_.chunk(array, [size=1])` - Polish the proof-of-concept code, making it TS code and remove `// @ts-nocheck`! - Create interfaces or new types instead of loose variables - Save followbackers and not followbackers in lists to see details. @@ -15,10 +14,6 @@ Let promote some reciprocity here! 😹 - Show the relay list to be used - Upload a localStorage list of relays +- ~~Actually load builds at minimo.io/app/ or something alike.~~ - ~~Configure Vite for the miniapp to be loaded in the article's url as base.~~ - ~~Remove SvelteKit (just Vite + Svelte).~~ - -## BUG - -- **When user follows lots of people, progress freezes:**
- [NDK](https://github.com/nostr-dev-kit/ndk) keeps trying to re-connect to relays, and progress slows down or halts completly. Maybe slow requests down? Are they blocking the requests because they are too many too fast? diff --git a/nostr-followback/package.json b/nostr-followback/package.json index 1cccb3f..47dcd7f 100644 --- a/nostr-followback/package.json +++ b/nostr-followback/package.json @@ -1,24 +1,24 @@ { - "name": "nostr-followback", - "private": true, - "version": "0.0.0", - "type": "module", - "scripts": { - "dev": "vite", - "build": "vite build", - "preview": "vite preview", - "check": "svelte-check --tsconfig ./tsconfig.json" - }, - "devDependencies": { - "@sveltejs/vite-plugin-svelte": "^3.0.2", - "@tsconfig/svelte": "^5.0.2", - "svelte": "^4.2.12", - "svelte-check": "^3.6.7", - "tslib": "^2.6.2", - "typescript": "^5.2.2", - "vite": "^5.2.0" - }, - "dependencies": { - "@nostr-dev-kit/ndk": "^2.8.1" - } + "name": "nostr-followback", + "private": true, + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "vite", + "build": "vite build", + "preview": "vite preview", + "check": "svelte-check --tsconfig ./tsconfig.json" + }, + "devDependencies": { + "@sveltejs/vite-plugin-svelte": "^3.0.2", + "@tsconfig/svelte": "^5.0.2", + "svelte": "^4.2.12", + "svelte-check": "^3.6.7", + "tslib": "^2.6.2", + "typescript": "^5.2.2", + "vite": "^5.2.0" + }, + "dependencies": { + "@nostr-dev-kit/ndk": "^2.8.1" + } } diff --git a/nostr-followback/src/App.svelte b/nostr-followback/src/App.svelte index 48cf683..4b16857 100644 --- a/nostr-followback/src/App.svelte +++ b/nostr-followback/src/App.svelte @@ -1,23 +1,23 @@
- + { querying = true; - userName = ""; - userThumb = ""; + userProfile = null; originalFollow = []; notFollowersBack = []; followBackCount = 0; @@ -116,43 +126,35 @@ />
- - -{#if userThumb} +{#if userProfile}
- user-thumb + user-thumb User: - {userName} + {userProfile.displayName} |  Follows: {followsCount}
- Unknown: {unknownFollowBack} | Follow_Back: {followBackCount} | + Unknown: {unknownFollowBack} - Follow_Back: {followBackCount} - 👉 Not_Follow_Back : - {notFollowersBack.length}
{#if progress < 100}

- Progress = - {progress}% + Progress = {progress}% - {totalCountOfContactsChecked} of {followsCount} -

{:else} -

Completed!

+

✅ Completed!

{/if}

- Results ({originalFollow.length}) + Not followers + : {notFollowersBack.length} of + {originalFollow.length} ({notFollowBackPercentage}%) -
-{:else if !querying} +{:else if querying == "uninitiated"} {:else}
Loading data...
diff --git a/nostr-followback/src/lib/data/relays.js b/nostr-followback/src/lib/data/relays.js index 30a52d7..65b960a 100644 --- a/nostr-followback/src/lib/data/relays.js +++ b/nostr-followback/src/lib/data/relays.js @@ -9,11 +9,11 @@ export const relays = [ "wss://nostr.mom", "wss://nostrelay.yeghro.site", "wss://relay.damus.io", - "wss://relay.nostr.bg", + // "wss://relay.nostr.bg", "wss://relay.snort.social", "wss://relay.primal.net", "wss://nostr.bitcoiner.social", "wss://nostr.mutinywallet.com", "wss://relay.current.fyi", - "wss://brb.io", + // "wss://brb.io", ]; diff --git a/nostr-followback/src/lib/fetchs.js b/nostr-followback/src/lib/fetchs.js deleted file mode 100644 index d6461f0..0000000 --- a/nostr-followback/src/lib/fetchs.js +++ /dev/null @@ -1,9 +0,0 @@ -export async function fetchUserProfile(npub, ndk) { - const user = ndk.getUser({ npub }); - await user.fetchProfile(); - return user; -} -export async function fetchNotes(hexkey, ndk) { - const kind1filter = { kinds: [3], authors: [hexkey] }; - return ndk.fetchEvent(kind1filter); -} diff --git a/nostr-followback/src/lib/types.ts b/nostr-followback/src/lib/types.ts new file mode 100644 index 0000000..80a1771 --- /dev/null +++ b/nostr-followback/src/lib/types.ts @@ -0,0 +1,3 @@ +export type userFollowData = { + followsCount: number; +}; diff --git a/nostr-followback/tsconfig.json b/nostr-followback/tsconfig.json index 5fb548f..3977457 100644 --- a/nostr-followback/tsconfig.json +++ b/nostr-followback/tsconfig.json @@ -1,20 +1,20 @@ { - "extends": "@tsconfig/svelte/tsconfig.json", - "compilerOptions": { - "target": "ESNext", - "useDefineForClassFields": true, - "module": "ESNext", - "resolveJsonModule": true, - /** - * Typecheck JS in `.svelte` and `.js` files by default. - * Disable checkJs if you'd like to use dynamic types in JS. - * Note that setting allowJs false does not prevent the use - * of JS in `.svelte` files. - */ - "allowJs": true, - "checkJs": true, - "isolatedModules": true - }, - "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], - "references": [{ "path": "./tsconfig.node.json" }] + "extends": "@tsconfig/svelte/tsconfig.json", + "compilerOptions": { + "target": "ESNext", + "useDefineForClassFields": true, + "module": "ESNext", + "resolveJsonModule": true, + /** + * Typecheck JS in `.svelte` and `.js` files by default. + * Disable checkJs if you'd like to use dynamic types in JS. + * Note that setting allowJs false does not prevent the use + * of JS in `.svelte` files. + */ + "allowJs": true, + "checkJs": true, + "isolatedModules": true + }, + "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"], + "references": [{ "path": "./tsconfig.node.json" }] }