diff --git a/android/app/src/main/java/com/nostros/classes/Event.java b/android/app/src/main/java/com/nostros/classes/Event.java index f4e7361..09f3169 100644 --- a/android/app/src/main/java/com/nostros/classes/Event.java +++ b/android/app/src/main/java/com/nostros/classes/Event.java @@ -42,33 +42,27 @@ public class Event { } public void save(SQLiteDatabase database, String userPubKey, String relayUrl) { - if (isValid()) { - try { - if (kind.equals("0")) { - saveUserMeta(database); - } else if (kind.equals("1") || kind.equals("2")) { - saveNote(database, userPubKey, relayUrl); - } else if (kind.equals("3")) { - if (pubkey.equals(userPubKey)) { - savePets(database); - } else { - saveFollower(database, userPubKey); - } - } else if (kind.equals("4")) { - saveDirectMessage(database); - } else if (kind.equals("7")) { - saveReaction(database); + try { + if (kind.equals("0")) { + saveUserMeta(database); + } else if (kind.equals("1") || kind.equals("2")) { + saveNote(database, userPubKey, relayUrl); + } else if (kind.equals("3")) { + if (pubkey.equals(userPubKey)) { + savePets(database); + } else { + saveFollower(database, userPubKey); } - } catch (JSONException e) { - e.printStackTrace(); + } else if (kind.equals("4")) { + saveDirectMessage(database); + } else if (kind.equals("7")) { + saveReaction(database); } + } catch (JSONException e) { + e.printStackTrace(); } } - protected boolean isValid() { - return !id.isEmpty() && !sig.isEmpty() && created_at <= System.currentTimeMillis() / 1000L; - } - protected String getMainEventId() { JSONArray eTags = filterTags("e"); String mainEventId = null; diff --git a/android/app/src/main/java/com/nostros/modules/DatabaseModule.java b/android/app/src/main/java/com/nostros/modules/DatabaseModule.java index 8c8fec6..533cf28 100644 --- a/android/app/src/main/java/com/nostros/modules/DatabaseModule.java +++ b/android/app/src/main/java/com/nostros/modules/DatabaseModule.java @@ -120,8 +120,8 @@ public class DatabaseModule { database.execSQL("CREATE INDEX nostros_reactions_created_at_reacted_event_id_index ON nostros_reactions(created_at, reacted_event_id); "); - database.execSQL("CREATE INDEX nostros_users_contact_index ON nostros_users(contact, follower); "); - database.execSQL("CREATE INDEX nostros_users_contact_index ON nostros_users(id, name); "); + database.execSQL("CREATE INDEX nostros_users_contact_follower_index ON nostros_users(contact, follower); "); + database.execSQL("CREATE INDEX nostros_users_id_name_index ON nostros_users(id, name); "); } catch (SQLException e) { } try { database.execSQL("DROP TABLE IF EXISTS nostros_config;"); diff --git a/frontend/Constants/Relay/index.ts b/frontend/Constants/Relay/index.ts index 0d018d6..a71bbd1 100644 --- a/frontend/Constants/Relay/index.ts +++ b/frontend/Constants/Relay/index.ts @@ -1,6 +1,7 @@ export const defaultRelays = [ 'wss://brb.io', 'wss://damus.io', + 'wss://nostr-pub.wellorder.net', 'wss://nostr.swiss-enigma.ch', 'wss://nostr.onsats.org', 'wss://nostr-pub.semisol.dev', @@ -9,7 +10,6 @@ export const defaultRelays = [ 'wss://nostr.oxtr.dev', 'wss://nostr.ono.re', 'wss://relay.grunch.dev', - 'wss://nostr-pub.wellorder.net', 'wss://nostr.developer.li', ] diff --git a/frontend/Functions/DatabaseFunctions/Notes/index.ts b/frontend/Functions/DatabaseFunctions/Notes/index.ts index 80cadfb..503c45b 100644 --- a/frontend/Functions/DatabaseFunctions/Notes/index.ts +++ b/frontend/Functions/DatabaseFunctions/Notes/index.ts @@ -53,7 +53,6 @@ export const getMainNotes: ( if (filters?.until) notesQuery += `nostros_notes.created_at <= ${filters?.until} AND ` notesQuery += ` - nostros_users.blocked != 1 AND nostros_notes.main_event_id IS NULL ORDER BY created_at DESC LIMIT ${limit} diff --git a/frontend/Functions/RelayFunctions/Users/index.ts b/frontend/Functions/RelayFunctions/Users/index.ts index 7cc0385..aa90948 100644 --- a/frontend/Functions/RelayFunctions/Users/index.ts +++ b/frontend/Functions/RelayFunctions/Users/index.ts @@ -4,6 +4,7 @@ import RelayPool from '../../../lib/nostr/RelayPool/intex' import { getUser, getUsers, User } from '../../DatabaseFunctions/Users' import { Event } from '../../../lib/nostr/Events' import { getNpub } from '../../../lib/nostr/Nip19' +import { Kind } from 'nostr-tools' export const usersToTags: (users: User[]) => string[][] = (users) => { return users.map((user): string[] => { @@ -60,7 +61,7 @@ export const populatePets: ( const event: Event = { content: '', created_at: getUnixTime(new Date()), - kind: 3, + kind: Kind.Contacts, pubkey: publicKey, tags: usersToTags(results), } @@ -84,7 +85,7 @@ export const populateProfile: ( const event: Event = { content: JSON.stringify(profile), created_at: getUnixTime(new Date()), - kind: 0, + kind: Kind.Metadata, pubkey: publicKey, tags: usersToTags([result]), } diff --git a/frontend/Pages/ProfileLoadPage/index.tsx b/frontend/Pages/ProfileLoadPage/index.tsx index d948d6f..b16918d 100644 --- a/frontend/Pages/ProfileLoadPage/index.tsx +++ b/frontend/Pages/ProfileLoadPage/index.tsx @@ -27,9 +27,14 @@ export const ProfileLoadPage: React.FC = () => { debounce(() => { loadMeta() loadPets() - }, 500) + }, 1000) - return () => relayPool?.unsubscribe(['profile-load-notes', 'profile-load-meta-pets']) + return () => + relayPool?.unsubscribe([ + 'profile-load-meta', + 'profile-load-notes', + 'profile-load-meta-pets', + ]) }, []), ) @@ -49,11 +54,13 @@ export const ProfileLoadPage: React.FC = () => { const loadMeta: () => void = () => { if (publicKey && relayPoolReady) { - relayPool?.subscribe('profile-load-meta-pets', [ + relayPool?.subscribe('profile-load-meta', [ { - kinds: [Kind.Contacts, Kind.Metadata], + kinds: [Kind.Text, Kind.Contacts, Kind.Metadata], authors: [publicKey], }, + ]) + relayPool?.subscribe('profile-load-meta-pets', [ { kinds: [Kind.Contacts], '#p': [publicKey], @@ -70,18 +77,14 @@ export const ProfileLoadPage: React.FC = () => { const authors = [...results.map((user: User) => user.id), publicKey] relayPool?.subscribe('profile-load-notes', [ { - kinds: [Kind.Text], - authors: [publicKey], + kinds: [Kind.Metadata], + authors, }, { kinds: [Kind.Text], authors, since: getUnixTime(new Date()) - 43200, }, - { - kinds: [Kind.Metadata], - authors, - }, ]) } }) diff --git a/frontend/Pages/RelaysPage/index.tsx b/frontend/Pages/RelaysPage/index.tsx index 1ec756d..ee9a938 100644 --- a/frontend/Pages/RelaysPage/index.tsx +++ b/frontend/Pages/RelaysPage/index.tsx @@ -59,12 +59,14 @@ export const RelaysPage: React.FC = () => { const desactiveRelay: (relay: Relay) => void = (relay) => { relay.active = 0 + relay.global_feed = 0 updateRelayItem(relay).then(() => { setShowNotification('desactive') }) } const activeGlobalFeedRelay: (relay: Relay) => void = (relay) => { + relay.active = 1 relay.global_feed = 1 updateRelayItem(relay).then(() => { setShowNotification('globalFeedActive') @@ -125,7 +127,7 @@ export const RelaysPage: React.FC = () => { 0} onValueChange={() => - item.active ? desactiveGlobalFeedRelay(item) : activeGlobalFeedRelay(item) + item.global_feed ? desactiveGlobalFeedRelay(item) : activeGlobalFeedRelay(item) } /> { )} /> - - {t('relaysPage.myList')} - {myRelays.length > 0 && ( <> + + {t('relaysPage.myList')} +