mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-29 06:30:47 +00:00
Version name an d nip21 test
This commit is contained in:
parent
9dcf75ba12
commit
89301e97f0
@ -17,6 +17,12 @@
|
|||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:windowSoftInputMode="adjustResize"
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
<intent-filter android:label="filter_react_native">
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="nostr" />
|
||||||
|
</intent-filter>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
|
@ -29,8 +29,10 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
|||||||
setDatabase(db)
|
setDatabase(db)
|
||||||
SInfo.getItem('publicKey', {}).then((value) => {
|
SInfo.getItem('publicKey', {}).then((value) => {
|
||||||
setLoadingDb(false)
|
setLoadingDb(false)
|
||||||
// Linking.addEventListener('url', this.handleOpenURL);
|
|
||||||
})
|
})
|
||||||
|
Linking.addEventListener('url', (event) => {
|
||||||
|
console.log(event.url)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(init, [])
|
useEffect(init, [])
|
||||||
|
@ -13,6 +13,8 @@ import { dropTables } from '../Functions/DatabaseFunctions'
|
|||||||
import { navigate } from '../lib/Navigation'
|
import { navigate } from '../lib/Navigation'
|
||||||
import { nsecEncode } from 'nostr-tools/nip19'
|
import { nsecEncode } from 'nostr-tools/nip19'
|
||||||
import { getNpub } from '../lib/nostr/Nip19'
|
import { getNpub } from '../lib/nostr/Nip19'
|
||||||
|
import Clipboard from '@react-native-clipboard/clipboard'
|
||||||
|
import { validNip21 } from '../Functions/NativeFunctions'
|
||||||
|
|
||||||
export interface UserContextProps {
|
export interface UserContextProps {
|
||||||
userState: 'loading' | 'access' | 'ready'
|
userState: 'loading' | 'access' | 'ready'
|
||||||
@ -60,6 +62,7 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
|
|||||||
const [nSec, setNsec] = useState<string>()
|
const [nSec, setNsec] = useState<string>()
|
||||||
const [privateKey, setPrivateKey] = useState<string>()
|
const [privateKey, setPrivateKey] = useState<string>()
|
||||||
const [user, setUser] = React.useState<User>()
|
const [user, setUser] = React.useState<User>()
|
||||||
|
const [clipboardLoads, setClipboardLoads] = React.useState<string[]>([])
|
||||||
const [contactsCount, setContantsCount] = React.useState<number>(0)
|
const [contactsCount, setContantsCount] = React.useState<number>(0)
|
||||||
const [followersCount, setFollowersCount] = React.useState<number>(0)
|
const [followersCount, setFollowersCount] = React.useState<number>(0)
|
||||||
|
|
||||||
@ -73,12 +76,24 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
|
|||||||
id: publicKey,
|
id: publicKey,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
checkClipboard()
|
||||||
})
|
})
|
||||||
getContactsCount(database).then(setContantsCount)
|
getContactsCount(database).then(setContantsCount)
|
||||||
getFollowersCount(database).then(setFollowersCount)
|
getFollowersCount(database).then(setFollowersCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const checkClipboard: () => void = () => {
|
||||||
|
Clipboard.getString().then((clipboardContent) => {
|
||||||
|
if (validNip21(clipboardContent) && !clipboardLoads.includes(clipboardContent)) {
|
||||||
|
setClipboardLoads((prev) => [...prev, clipboardContent])
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const logout: () => void = () => {
|
const logout: () => void = () => {
|
||||||
if (database) {
|
if (database) {
|
||||||
relayPool?.unsubscribeAll()
|
relayPool?.unsubscribeAll()
|
||||||
|
@ -33,3 +33,12 @@ export const validImageUrl: (url: string | undefined) => boolean = (url) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const validNip21: (string: string | undefined) => boolean = (string) => {
|
||||||
|
if (string) {
|
||||||
|
const regexp = /^nostr:(npub1|nprofile1|note1|nevent1)S*$/
|
||||||
|
return regexp.test(string)
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -122,7 +122,8 @@
|
|||||||
"aboutPage": {
|
"aboutPage": {
|
||||||
"gitHub": "GitHub",
|
"gitHub": "GitHub",
|
||||||
"nostr": "nostr",
|
"nostr": "nostr",
|
||||||
"nips": "NIPs"
|
"nips": "NIPs",
|
||||||
|
"version": "Version"
|
||||||
},
|
},
|
||||||
"homeFeed": {
|
"homeFeed": {
|
||||||
"emptyTitle": "You are not following anyone.",
|
"emptyTitle": "You are not following anyone.",
|
||||||
|
@ -123,7 +123,8 @@
|
|||||||
"aboutPage": {
|
"aboutPage": {
|
||||||
"gitHub": "GitHub",
|
"gitHub": "GitHub",
|
||||||
"nostr": "nostr",
|
"nostr": "nostr",
|
||||||
"nips": "NIPs"
|
"nips": "NIPs",
|
||||||
|
"version": "Version"
|
||||||
},
|
},
|
||||||
"homeFeed": {
|
"homeFeed": {
|
||||||
"emptyTitle": "No sigues a nadie",
|
"emptyTitle": "No sigues a nadie",
|
||||||
|
@ -122,7 +122,8 @@
|
|||||||
"aboutPage": {
|
"aboutPage": {
|
||||||
"gitHub": "GitHub",
|
"gitHub": "GitHub",
|
||||||
"nostr": "nostr",
|
"nostr": "nostr",
|
||||||
"nips": "NIPs"
|
"nips": "NIPs",
|
||||||
|
"version": "Version"
|
||||||
},
|
},
|
||||||
"homeFeed": {
|
"homeFeed": {
|
||||||
"emptyTitle": "You are not following anyone.",
|
"emptyTitle": "You are not following anyone.",
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { FlatList, Linking, ListRenderItem, StyleSheet } from 'react-native'
|
import { FlatList, Linking, ListRenderItem, StyleSheet } from 'react-native'
|
||||||
import { Divider, List, useTheme } from 'react-native-paper'
|
import { Divider, List, Text, useTheme } from 'react-native-paper'
|
||||||
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons'
|
||||||
|
import DeviceInfo from 'react-native-device-info'
|
||||||
|
|
||||||
interface ItemList {
|
interface ItemList {
|
||||||
key: number
|
key: number
|
||||||
title: string
|
title: string
|
||||||
left?: () => JSX.Element
|
left?: JSX.Element
|
||||||
|
right?: JSX.Element
|
||||||
onPress: () => void
|
onPress: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ export const AboutPage: React.FC = () => {
|
|||||||
{
|
{
|
||||||
key: 1,
|
key: 1,
|
||||||
title: t('aboutPage.gitHub'),
|
title: t('aboutPage.gitHub'),
|
||||||
left: () => (
|
left: (
|
||||||
<List.Icon
|
<List.Icon
|
||||||
icon={() => (
|
icon={() => (
|
||||||
<MaterialCommunityIcons
|
<MaterialCommunityIcons
|
||||||
@ -36,7 +38,7 @@ export const AboutPage: React.FC = () => {
|
|||||||
{
|
{
|
||||||
key: 2,
|
key: 2,
|
||||||
title: t('aboutPage.nostr'),
|
title: t('aboutPage.nostr'),
|
||||||
left: () => (
|
left: (
|
||||||
<List.Icon
|
<List.Icon
|
||||||
icon={() => (
|
icon={() => (
|
||||||
<MaterialCommunityIcons
|
<MaterialCommunityIcons
|
||||||
@ -52,7 +54,7 @@ export const AboutPage: React.FC = () => {
|
|||||||
{
|
{
|
||||||
key: 3,
|
key: 3,
|
||||||
title: t('aboutPage.nips'),
|
title: t('aboutPage.nips'),
|
||||||
left: () => (
|
left: (
|
||||||
<List.Icon
|
<List.Icon
|
||||||
icon={() => (
|
icon={() => (
|
||||||
<MaterialCommunityIcons
|
<MaterialCommunityIcons
|
||||||
@ -63,17 +65,44 @@ export const AboutPage: React.FC = () => {
|
|||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
|
right: <></>,
|
||||||
onPress: async () => await Linking.openURL('https://github.com/nostr-protocol/nips'),
|
onPress: async () => await Linking.openURL('https://github.com/nostr-protocol/nips'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 4,
|
||||||
|
title: t('aboutPage.version'),
|
||||||
|
left: (
|
||||||
|
<List.Icon
|
||||||
|
icon={() => (
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name='android'
|
||||||
|
size={25}
|
||||||
|
color={theme.colors.onPrimaryContainer}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
right: <Text>{DeviceInfo.getVersion()}</Text>,
|
||||||
|
onPress: () => {},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
const renderItem: ListRenderItem<ItemList> = ({ item }) => {
|
const renderItem: ListRenderItem<ItemList> = ({ item }) => {
|
||||||
return <List.Item key={item.key} title={item.title} onPress={item.onPress} left={item.left} />
|
return (
|
||||||
|
<List.Item
|
||||||
|
key={item.key}
|
||||||
|
title={item.title}
|
||||||
|
onPress={item.onPress}
|
||||||
|
left={() => item.left}
|
||||||
|
right={() => item.right}
|
||||||
|
/>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<FlatList
|
<FlatList
|
||||||
style={styles.container}
|
style={styles.container}
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
@ -81,7 +110,7 @@ export const AboutPage: React.FC = () => {
|
|||||||
data={items}
|
data={items}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
/>
|
/>
|
||||||
// DeviceInfo.getVersion()
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,10 +23,8 @@ export const ProfileLoadPage: React.FC = () => {
|
|||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
if (publicKey && relayPoolReady) {
|
|
||||||
loadMeta()
|
loadMeta()
|
||||||
loadPets()
|
loadPets()
|
||||||
}
|
|
||||||
|
|
||||||
return () => relayPool?.unsubscribe(['profile-load-notes', 'profile-load-meta-pets'])
|
return () => relayPool?.unsubscribe(['profile-load-notes', 'profile-load-meta-pets'])
|
||||||
}, []),
|
}, []),
|
||||||
@ -49,7 +47,7 @@ export const ProfileLoadPage: React.FC = () => {
|
|||||||
}, [user])
|
}, [user])
|
||||||
|
|
||||||
const loadMeta: () => void = () => {
|
const loadMeta: () => void = () => {
|
||||||
if (publicKey) {
|
if (publicKey && relayPoolReady) {
|
||||||
relayPool?.subscribe('profile-load-meta-pets', [
|
relayPool?.subscribe('profile-load-meta-pets', [
|
||||||
{
|
{
|
||||||
kinds: [Kind.Contacts],
|
kinds: [Kind.Contacts],
|
||||||
@ -64,7 +62,7 @@ export const ProfileLoadPage: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const loadPets: () => void = () => {
|
const loadPets: () => void = () => {
|
||||||
if (database && publicKey) {
|
if (database && publicKey && relayPoolReady) {
|
||||||
getUsers(database, {}).then((results) => {
|
getUsers(database, {}).then((results) => {
|
||||||
if (results && results.length > 0) {
|
if (results && results.length > 0) {
|
||||||
setContactsCount(results.filter((user) => user.contact).length)
|
setContactsCount(results.filter((user) => user.contact).length)
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
"react-native": "0.70.6",
|
"react-native": "0.70.6",
|
||||||
"react-native-action-button": "^2.8.5",
|
"react-native-action-button": "^2.8.5",
|
||||||
"react-native-bidirectional-infinite-scroll": "^0.3.3",
|
"react-native-bidirectional-infinite-scroll": "^0.3.3",
|
||||||
|
"react-native-device-info": "^10.3.0",
|
||||||
"react-native-gesture-handler": "^2.8.0",
|
"react-native-gesture-handler": "^2.8.0",
|
||||||
"react-native-multithreading": "^1.1.1",
|
"react-native-multithreading": "^1.1.1",
|
||||||
"react-native-pager-view": "^6.1.2",
|
"react-native-pager-view": "^6.1.2",
|
||||||
|
@ -7225,6 +7225,11 @@ react-native-codegen@^0.70.6:
|
|||||||
jscodeshift "^0.13.1"
|
jscodeshift "^0.13.1"
|
||||||
nullthrows "^1.1.1"
|
nullthrows "^1.1.1"
|
||||||
|
|
||||||
|
react-native-device-info@^10.3.0:
|
||||||
|
version "10.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-native-device-info/-/react-native-device-info-10.3.0.tgz#6bab64d84d3415dd00cc446c73ec5e2e61fddbe7"
|
||||||
|
integrity sha512-/ziZN1sA1REbJTv5mQZ4tXggcTvSbct+u5kCaze8BmN//lbxcTvWsU6NQd4IihLt89VkbX+14IGc9sVApSxd/w==
|
||||||
|
|
||||||
react-native-gesture-handler@^2.8.0:
|
react-native-gesture-handler@^2.8.0:
|
||||||
version "2.8.0"
|
version "2.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz#ef9857871c10663c95a51546225b6e00cd4740cf"
|
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.8.0.tgz#ef9857871c10663c95a51546225b6e00cd4740cf"
|
||||||
|
Loading…
Reference in New Issue
Block a user