diff --git a/frontend/Contexts/WalletContext.tsx b/frontend/Contexts/WalletContext.tsx index 4138f43..b92d140 100644 --- a/frontend/Contexts/WalletContext.tsx +++ b/frontend/Contexts/WalletContext.tsx @@ -58,6 +58,10 @@ export const WalletContextProvider = ({ children }: WalletContextProviderProps): }) }, []) + useEffect(() => { + if (config && type) updateWallet() + }, [config, type]) + const getClient: (params?: any, clientType?: string) => LndHub | LnBits | undefined = ( params, clientType, diff --git a/frontend/Pages/HomePage/HomeFeed/MyFeed/index.tsx b/frontend/Pages/HomePage/HomeFeed/MyFeed/index.tsx index c7538e3..d59f069 100644 --- a/frontend/Pages/HomePage/HomeFeed/MyFeed/index.tsx +++ b/frontend/Pages/HomePage/HomeFeed/MyFeed/index.tsx @@ -92,11 +92,12 @@ export const MyFeed: React.FC = ({ const message: RelayFilters = { kinds: [Kind.Text, Kind.RecommendRelay], - authors: contacts, - limit: pageSize, + authors: contacts } - if (results.length === pageSize) { + if (results.length >= pageSize) { message.since = results[pageSize - 1].created_at + } else { + message.limit = pageSize } relayPool?.subscribe('homepage-myfeed-main', [message]) diff --git a/frontend/Pages/HomePage/NotificationsFeed/index.tsx b/frontend/Pages/HomePage/NotificationsFeed/index.tsx index 6d36f40..98ef5d2 100644 --- a/frontend/Pages/HomePage/NotificationsFeed/index.tsx +++ b/frontend/Pages/HomePage/NotificationsFeed/index.tsx @@ -119,14 +119,16 @@ export const NotificationsFeed: React.FC = () => { { kinds: [Kind.Text], '#p': [publicKey], + since: limitDate }, { kinds: [Kind.Text], '#e': [publicKey], + since: limitDate }, { kinds: [30001], - authors: [publicKey], + authors: [publicKey] }, ]) } @@ -316,6 +318,7 @@ export const NotificationsFeed: React.FC = () => { refreshing={refreshing} ListEmptyComponent={ListEmptyComponent} horizontal={false} + estimatedItemSize={100} ListFooterComponent={ mentionNotes.length > 0 ? ( diff --git a/frontend/Pages/NotePage/index.tsx b/frontend/Pages/NotePage/index.tsx index 112af39..fd7bf19 100644 --- a/frontend/Pages/NotePage/index.tsx +++ b/frontend/Pages/NotePage/index.tsx @@ -14,6 +14,8 @@ import { useFocusEffect } from '@react-navigation/native' import { SkeletonNote } from '../../Components/SkeletonNote/SkeletonNote' import { ScrollView } from 'react-native-gesture-handler' import { type RelayFilters } from '../../lib/nostr/RelayPool/intex' +import { getGroup } from '../../Functions/DatabaseFunctions/Groups' +import { formatId } from '../../Functions/RelayFunctions/Users' interface NotePageProps { route: { params: { noteId: string } } @@ -44,8 +46,22 @@ export const NotePage: React.FC = ({ route }) => { useEffect(() => { loadNote() + loadGroup() }, [lastEventId]) + const loadGroup: () => void = async () => { + if (database) { + getGroup(database, route.params.noteId).then((result) => { + if (result) { + navigate('Group', { + groupId: result.id, + title: result.name ?? formatId(result.id), + }) + } + }) + } + } + const loadNote: () => void = async () => { if (database && publicKey) { const events = await getNotes(database, { filters: { id: [route.params.noteId] } }) @@ -86,7 +102,7 @@ export const NotePage: React.FC = ({ route }) => { if (database && route.params.noteId) { relayPool?.subscribe(`notepage${route.params.noteId.substring(0, 8)}`, [ { - kinds: [Kind.Text], + kinds: [Kind.Text, Kind.ChannelCreation], ids: [route.params.noteId], }, ]) diff --git a/frontend/Pages/WalletPage/index.tsx b/frontend/Pages/WalletPage/index.tsx index 4d4f775..b585a3f 100644 --- a/frontend/Pages/WalletPage/index.tsx +++ b/frontend/Pages/WalletPage/index.tsx @@ -19,6 +19,8 @@ import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityI import Logo from '../../Components/Logo' import NostrosAvatar from '../../Components/NostrosAvatar' import { AppContext } from '../../Contexts/AppContext' +import { RelayPoolContext } from '../../Contexts/RelayPoolContext' +import { UserContext } from '../../Contexts/UserContext' import { WalletContext } from '../../Contexts/WalletContext' import { getZaps, type Zap } from '../../Functions/DatabaseFunctions/Zaps' import type WalletAction from '../../lib/Lightning' @@ -27,6 +29,8 @@ import { navigate } from '../../lib/Navigation' export const WalletPage: React.FC = () => { const theme = useTheme() const { getSatoshiSymbol, database, setDisplayUserDrawer } = React.useContext(AppContext) + const { publicKey } = React.useContext(UserContext) + const { relayPool, lastEventId } = React.useContext(RelayPoolContext) const { refreshWallet, updateWallet, type, balance, transactions, invoices, updatedAt } = React.useContext(WalletContext) const [lnHubAddress, setLndHubAddress] = React.useState() @@ -42,26 +46,42 @@ export const WalletPage: React.FC = () => { useFocusEffect( React.useCallback(() => { updateWallet() - return () => {} + return () => { + if (publicKey) relayPool?.unsubscribe([`profile-zaps${publicKey.substring(0, 8)}`]) + } }, []), ) useEffect(() => { - const array = [...transactions, ...invoices].sort( - (item1, item2) => item2.timestamp - item1.timestamp, - ) - setActions(array) - if (database) { - getZaps(database, { preimages: array.map((item) => item.id) }).then((results) => { - if (results) { - const map: Record = {} - results.forEach((zap) => { - map[zap.preimage] = zap - }) - setZaps(map) - } - }) + if (database && publicKey) { + const preimages: string[] = actions.filter((item) => item.id !== '').map((item) => item.id) + + getZaps(database, { preimages }).then( + (results) => { + if (results) { + const map: Record = {} + results.forEach((zap) => { + if (!zap.preimage || zap.preimage === '') return + map[zap.preimage] = zap + }) + setZaps(map) + } + }, + ) + relayPool?.subscribe(`profile-zaps${publicKey.substring(0, 8)}`, [ + { + kinds: [9735], + '#preimage': preimages, + }, + ]) } + }, [lastEventId]) + + useEffect(() => { + const array = [...transactions, ...invoices] + .filter((item) => item.id !== '') + .sort((item1, item2) => item2.timestamp - item1.timestamp) + setActions(array) }, [updatedAt]) const paste: (setFunction: (value: string) => void) => void = (setFunction) => { @@ -140,10 +160,10 @@ export const WalletPage: React.FC = () => { const formatPattern = differenceInDays(new Date(), date) < 7 ? 'EEEE' : 'MM-dd-yy' - const zap = zaps[item.id] + const zap = item.id !== '' ? zaps[item.id] : undefined return ( - + {(index === 0 || !isSameDay(date, prevDate)) && ( {format(date, formatPattern)} )} @@ -223,7 +243,12 @@ export const WalletPage: React.FC = () => { - + item.id + item.timestamp} + /> ) : ( diff --git a/frontend/lib/nostr/RelayPool/intex.ts b/frontend/lib/nostr/RelayPool/intex.ts index 2ec6fbb..3d390c1 100644 --- a/frontend/lib/nostr/RelayPool/intex.ts +++ b/frontend/lib/nostr/RelayPool/intex.ts @@ -8,6 +8,7 @@ export interface RelayFilters { '#e'?: string[] '#p'?: string[] '#t'?: string[] + '#preimage'?: string[] since?: number limit?: number until?: number diff --git a/package.json b/package.json index 15715e9..84acfe0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "cryptr": "^6.1.0", "date-fns": "^2.29.3", "events": "^3.3.0", - "i18next": "^22.4.10", + "i18next": "^22.4.13", "lnurl-pay": "^2.2.0", "lodash.debounce": "^4.0.8", "nostr-tools": "^1.7.5", @@ -45,7 +45,7 @@ "react-native-gesture-handler": "^2.8.0", "react-native-image-picker": "^5.1.0", "react-native-pager-view": "^6.1.4", - "react-native-paper": "^5.4.0", + "react-native-paper": "^5.5.1", "react-native-parsed-text": "^0.0.22", "react-native-qrcode-svg": "^6.2.0", "react-native-quick-sqlite": "^8.0.2", @@ -74,7 +74,7 @@ "@types/jest": "^29.4.0", "@types/linkify-it": "^3.0.2", "@types/lodash.debounce": "^4.0.7", - "@types/react-native": "^0.71.4", + "@types/react-native": "^0.71.5", "@types/react-native-sqlite-storage": "^6.0.0", "@types/react-native-vector-icons": "^6.4.13", "@types/react-test-renderer": "^18.0.0", @@ -82,10 +82,10 @@ "@typescript-eslint/eslint-plugin": "^5.56.0", "babel-jest": "^29.4.3", "eslint": "^8.36.0", - "eslint-config-prettier": "^8.6.0", + "eslint-config-prettier": "^8.8.0", "eslint-config-standard-with-typescript": "^34.0.1", "eslint-import-resolver-typescript": "^3.5.3", - "eslint-plugin-i18next": "^6.0.0-6", + "eslint-plugin-i18next": "^6.0.0-8", "eslint-plugin-import": "^2.27.5", "eslint-plugin-n": "^15.6.0", "eslint-plugin-prettier": "^4.2.1", diff --git a/yarn.lock b/yarn.lock index 821abe8..d318e30 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1717,10 +1717,10 @@ dependencies: "@types/react" "*" -"@types/react-native@^0.71.4": - version "0.71.4" - resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.71.4.tgz#0d0afb7784edc2f618add87c87445cbd45afa7b7" - integrity sha512-83wkRqauxJUtLrQN9S8P5HUSx7FalE8sDHBmvtxXGk3eb0bOsyOaOgEIfy59P/ypCDXY0oc3GiJejs/ko94tJg== +"@types/react-native@^0.71.5": + version "0.71.5" + resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.71.5.tgz#229bc670433f97fe1e03d62758d4fccf34a07714" + integrity sha512-Tp5druh7DGwNDvWYH09PCE++hbH4zYz0OOvGFb3/QFIFKXgfezaT/txJeKlBkbiqs45QJzllp9S0qo0WpWyijA== dependencies: "@types/react" "*" @@ -3209,15 +3209,6 @@ depd@2.0.0: resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== -deprecated-react-native-prop-types@^2.2.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-2.3.0.tgz#c10c6ee75ff2b6de94bb127f142b814e6e08d9ab" - integrity sha512-pWD0voFtNYxrVqvBMYf5gq3NA2GCpfodS1yNynTPc93AYA/KEMGeWDqqeUB6R2Z9ZofVhks2aeJXiuQqKNpesA== - dependencies: - "@react-native/normalize-color" "*" - invariant "*" - prop-types "*" - deprecated-react-native-prop-types@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/deprecated-react-native-prop-types/-/deprecated-react-native-prop-types-3.0.1.tgz#a275f84cd8519cd1665e8df3c99e9067d57a23ec" @@ -3346,11 +3337,6 @@ elliptic@^6.5.3, elliptic@^6.5.4: minimalistic-assert "^1.0.1" minimalistic-crypto-utils "^1.0.1" -eme-encryption-scheme-polyfill@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/eme-encryption-scheme-polyfill/-/eme-encryption-scheme-polyfill-2.1.1.tgz#91c823ed584e8ec5a9f03a6a676def8f80c57a4c" - integrity sha512-njD17wcUrbqCj0ArpLu5zWXtaiupHb/2fIUQGdInf83GlI+Q6mmqaPGLdrke4savKAu15J/z1Tg/ivDgl14g0g== - emitter-component@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/emitter-component/-/emitter-component-1.1.1.tgz#065e2dbed6959bf470679edabeaf7981d1003ab6" @@ -3518,11 +3504,16 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== -eslint-config-prettier@^8.5.0, eslint-config-prettier@^8.6.0: +eslint-config-prettier@^8.5.0: version "8.7.0" resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.7.0.tgz#f1cc58a8afebc50980bd53475451df146c13182d" integrity sha512-HHVXLSlVUhMSmyW4ZzEuvjpwqamgmlfkutD53cYXLikh4pt/modINRcCIApJ84czDxM4GZInwUrromsDdTImTA== +eslint-config-prettier@^8.8.0: + version "8.8.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" + integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== + eslint-config-standard-with-typescript@^34.0.1: version "34.0.1" resolved "https://registry.yarnpkg.com/eslint-config-standard-with-typescript/-/eslint-config-standard-with-typescript-34.0.1.tgz#4cf797c7f54b2eb1683c7e990b45a257ed4a9992" @@ -3589,10 +3580,10 @@ eslint-plugin-ft-flow@^2.0.1: lodash "^4.17.21" string-natural-compare "^3.0.1" -eslint-plugin-i18next@^6.0.0-6: - version "6.0.0-6" - resolved "https://registry.yarnpkg.com/eslint-plugin-i18next/-/eslint-plugin-i18next-6.0.0-6.tgz#8fef8740ac14d52ad3eb41fdc6b475c634de4141" - integrity sha512-Wl9Ko3AUORoOXm8Gve8BlfasT2dyIcDu1WgPUpLK3G6D/CDDOH33mF5Nd+TThkRVFKIoFY8QObZtnmn9jf9qxA== +eslint-plugin-i18next@^6.0.0-8: + version "6.0.0-8" + resolved "https://registry.yarnpkg.com/eslint-plugin-i18next/-/eslint-plugin-i18next-6.0.0-8.tgz#3dbe9191d6a1746dabc4540d4f1d67301d40d379" + integrity sha512-TMOeq/tcovFnDCxObJsEWm2/pnVAaOPkvvFKfjHrmGQ5oPGa+OmnBGDbTIU2GjVmejlUSBA4R897Y+jQJPmrWQ== dependencies: lodash "^4.17.21" requireindex "~1.1.0" @@ -4470,10 +4461,10 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== -i18next@^22.4.10: - version "22.4.11" - resolved "https://registry.yarnpkg.com/i18next/-/i18next-22.4.11.tgz#8b6c9be95176de90d3f10a78af125d95d3a3258d" - integrity sha512-ShfTzXVMjXdF2iPiT/wbizOrssLh9Ab6VpuVROihLCAu+u25KbZiEYVgsA0W6g0SgjPa/JmGWcUEV/g6cKzEjQ== +i18next@^22.4.13: + version "22.4.13" + resolved "https://registry.yarnpkg.com/i18next/-/i18next-22.4.13.tgz#02e291ab0056eab13b7d356fb454ff991923eaa0" + integrity sha512-GX7flMHRRqQA0I1yGLmaZ4Hwt1JfLqagk8QPDPZsqekbKtXsuIngSVWM/s3SLgNkrEXjA+0sMGNuOEkkmyqmWg== dependencies: "@babel/runtime" "^7.20.6" @@ -5460,11 +5451,6 @@ jsonfile@^4.0.0: array-includes "^3.1.5" object.assign "^4.1.3" -keymirror@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/keymirror/-/keymirror-0.1.1.tgz#918889ea13f8d0a42e7c557250eee713adc95c35" - integrity sha512-vIkZAFWoDijgQT/Nvl2AHCMmnegN2ehgTPYuyy2hWQkQSntI0S7ESYqdLkoSe1HyEBFHHkCgSIvVdSEiWwKvCg== - kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: version "3.2.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" @@ -5575,7 +5561,7 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ== -lodash@^4.16.4, lodash@^4.17.11, lodash@^4.17.21: +lodash@^4.17.11, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -6876,10 +6862,10 @@ react-native-pager-view@^6.1.4: resolved "https://registry.yarnpkg.com/react-native-pager-view/-/react-native-pager-view-6.1.4.tgz#3a63ebd1b72f81991157ea552bb9c887e529bc8c" integrity sha512-fmTwgGwPxGCBusKAq7gHzm+s1Yp0qh5rKPoQszaCuxrb+76KgK4Qe82jJNPUp2xTZOKSw+FbJU2QahF8ncTl+w== -react-native-paper@^5.4.0: - version "5.4.1" - resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-5.4.1.tgz#6731ef573464c4ef00b0a046db5771720a34d73a" - integrity sha512-eh2fh/dr+j/8V9FDHGhc0/tyXjyYSJLBrSGx/4lr2qPK+92QvH2mTNwFc280NiehCkfRSW2u3LMgUuyrkkQjjw== +react-native-paper@^5.5.1: + version "5.5.2" + resolved "https://registry.yarnpkg.com/react-native-paper/-/react-native-paper-5.5.2.tgz#c28058ad0e4252b3b6061b9ddc39ed11543706d5" + integrity sha512-cgkx67++r1oDoZRhzTohb0//qkD1Z20C/OcLfrE0HzyAkG+bYm0fA6gWqvHpdC7icQmuDS8iOOLu2288IYWiOA== dependencies: "@callstack/react-theme-provider" "^3.0.8" color "^3.1.2" @@ -6974,23 +6960,6 @@ react-native-version-number@^0.3.6: resolved "https://registry.yarnpkg.com/react-native-version-number/-/react-native-version-number-0.3.6.tgz#dd8b1435fc217df0a166d7e4a61fdc993f3e7437" integrity sha512-TdyXiK90NiwmSbmAUlUBOV6WI1QGoqtvZZzI5zQY4fKl67B3ZrZn/h+Wy/OYIKKFMfePSiyfeIs8LtHGOZ/NgA== -react-native-video-controls@^2.8.1: - version "2.8.1" - resolved "https://registry.yarnpkg.com/react-native-video-controls/-/react-native-video-controls-2.8.1.tgz#30ae707d8d218fed34bba3fc027b3943c5f438d9" - integrity sha512-dBmrE3TAKaR1gYMfbukjAM6Xo8OMZyRrxPzZtnaUgWcvGo11PQwzaI/j8HPD5fLgO+rlweP2pDpEJyIBsJvJkw== - dependencies: - lodash "^4.16.4" - -react-native-video@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/react-native-video/-/react-native-video-5.2.1.tgz#a17e856759d7e17eee9cbd9df0d05ba22e88d457" - integrity sha512-aJlr9MeTuQ0LpZ4n+EC9RvhoKeiPbLtI2Rxy8u7zo/wzGevbRpWHSBj9xZ5YDBXnAVXzuqyNIkGhdw7bfdIBZw== - dependencies: - deprecated-react-native-prop-types "^2.2.0" - keymirror "^0.1.1" - prop-types "^15.7.2" - shaka-player "^2.5.9" - react-native-webp-format@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/react-native-webp-format/-/react-native-webp-format-1.1.2.tgz#22b14f544191e9a5411c920b9874e532a6ea6c89" @@ -7437,13 +7406,6 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" -shaka-player@^2.5.9: - version "2.5.23" - resolved "https://registry.yarnpkg.com/shaka-player/-/shaka-player-2.5.23.tgz#db92d1c6cf2314f0180a2cec11b0e2f2560336f5" - integrity sha512-3MC9k0OXJGw8AZ4n/ZNCZS2yDxx+3as5KgH6Tx4Q5TRboTBBCu6dYPI5vp1DxKeyU12MBN1Zcbs7AKzXv2EnCg== - dependencies: - eme-encryption-scheme-polyfill "^2.0.1" - shallow-clone@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/shallow-clone/-/shallow-clone-3.0.1.tgz#8f2981ad92531f55035b01fb230769a40e02efa3"