mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-29 06:30:47 +00:00
Version name an d nip21 test (#189)
This commit is contained in:
commit
048a2d87d7
@ -17,6 +17,12 @@
|
||||
android:launchMode="singleTask"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
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>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
@ -29,8 +29,10 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
||||
setDatabase(db)
|
||||
SInfo.getItem('publicKey', {}).then((value) => {
|
||||
setLoadingDb(false)
|
||||
// Linking.addEventListener('url', this.handleOpenURL);
|
||||
})
|
||||
Linking.addEventListener('url', (event) => {
|
||||
console.log(event.url)
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(init, [])
|
||||
|
@ -13,6 +13,8 @@ import { dropTables } from '../Functions/DatabaseFunctions'
|
||||
import { navigate } from '../lib/Navigation'
|
||||
import { nsecEncode } from 'nostr-tools/nip19'
|
||||
import { getNpub } from '../lib/nostr/Nip19'
|
||||
import Clipboard from '@react-native-clipboard/clipboard'
|
||||
import { validNip21 } from '../Functions/NativeFunctions'
|
||||
|
||||
export interface UserContextProps {
|
||||
userState: 'loading' | 'access' | 'ready'
|
||||
@ -60,6 +62,7 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
|
||||
const [nSec, setNsec] = useState<string>()
|
||||
const [privateKey, setPrivateKey] = useState<string>()
|
||||
const [user, setUser] = React.useState<User>()
|
||||
const [clipboardLoads, setClipboardLoads] = React.useState<string[]>([])
|
||||
const [contactsCount, setContantsCount] = React.useState<number>(0)
|
||||
const [followersCount, setFollowersCount] = React.useState<number>(0)
|
||||
|
||||
@ -73,12 +76,24 @@ export const UserContextProvider = ({ children }: UserContextProviderProps): JSX
|
||||
id: publicKey,
|
||||
})
|
||||
}
|
||||
checkClipboard()
|
||||
})
|
||||
getContactsCount(database).then(setContantsCount)
|
||||
getFollowersCount(database).then(setFollowersCount)
|
||||
}
|
||||
}
|
||||
|
||||
const checkClipboard: () => void = () => {
|
||||
Clipboard.getString().then((clipboardContent) => {
|
||||
if (validNip21(clipboardContent) && !clipboardLoads.includes(clipboardContent)) {
|
||||
setClipboardLoads((prev) => [...prev, clipboardContent])
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
const logout: () => void = () => {
|
||||
if (database) {
|
||||
relayPool?.unsubscribeAll()
|
||||
|
@ -33,3 +33,12 @@ export const validImageUrl: (url: string | undefined) => boolean = (url) => {
|
||||
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": {
|
||||
"gitHub": "GitHub",
|
||||
"nostr": "nostr",
|
||||
"nips": "NIPs"
|
||||
"nips": "NIPs",
|
||||
"version": "Version"
|
||||
},
|
||||
"homeFeed": {
|
||||
"emptyTitle": "You are not following anyone.",
|
||||
|
@ -123,7 +123,8 @@
|
||||
"aboutPage": {
|
||||
"gitHub": "GitHub",
|
||||
"nostr": "nostr",
|
||||
"nips": "NIPs"
|
||||
"nips": "NIPs",
|
||||
"version": "Version"
|
||||
},
|
||||
"homeFeed": {
|
||||
"emptyTitle": "No sigues a nadie",
|
||||
|
@ -122,7 +122,8 @@
|
||||
"aboutPage": {
|
||||
"gitHub": "GitHub",
|
||||
"nostr": "nostr",
|
||||
"nips": "NIPs"
|
||||
"nips": "NIPs",
|
||||
"version": "Version"
|
||||
},
|
||||
"homeFeed": {
|
||||
"emptyTitle": "You are not following anyone.",
|
||||
|
@ -1,13 +1,15 @@
|
||||
import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
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 DeviceInfo from 'react-native-device-info'
|
||||
|
||||
interface ItemList {
|
||||
key: number
|
||||
title: string
|
||||
left?: () => JSX.Element
|
||||
left?: JSX.Element
|
||||
right?: JSX.Element
|
||||
onPress: () => void
|
||||
}
|
||||
|
||||
@ -20,7 +22,7 @@ export const AboutPage: React.FC = () => {
|
||||
{
|
||||
key: 1,
|
||||
title: t('aboutPage.gitHub'),
|
||||
left: () => (
|
||||
left: (
|
||||
<List.Icon
|
||||
icon={() => (
|
||||
<MaterialCommunityIcons
|
||||
@ -36,7 +38,7 @@ export const AboutPage: React.FC = () => {
|
||||
{
|
||||
key: 2,
|
||||
title: t('aboutPage.nostr'),
|
||||
left: () => (
|
||||
left: (
|
||||
<List.Icon
|
||||
icon={() => (
|
||||
<MaterialCommunityIcons
|
||||
@ -52,7 +54,7 @@ export const AboutPage: React.FC = () => {
|
||||
{
|
||||
key: 3,
|
||||
title: t('aboutPage.nips'),
|
||||
left: () => (
|
||||
left: (
|
||||
<List.Icon
|
||||
icon={() => (
|
||||
<MaterialCommunityIcons
|
||||
@ -63,25 +65,52 @@ export const AboutPage: React.FC = () => {
|
||||
)}
|
||||
/>
|
||||
),
|
||||
right: <></>,
|
||||
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 }) => {
|
||||
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 (
|
||||
<FlatList
|
||||
style={styles.container}
|
||||
showsVerticalScrollIndicator={false}
|
||||
ItemSeparatorComponent={Divider}
|
||||
data={items}
|
||||
renderItem={renderItem}
|
||||
/>
|
||||
// DeviceInfo.getVersion()
|
||||
<>
|
||||
<FlatList
|
||||
style={styles.container}
|
||||
showsVerticalScrollIndicator={false}
|
||||
ItemSeparatorComponent={Divider}
|
||||
data={items}
|
||||
renderItem={renderItem}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,8 @@ export const ProfileLoadPage: React.FC = () => {
|
||||
|
||||
useFocusEffect(
|
||||
React.useCallback(() => {
|
||||
if (publicKey && relayPoolReady) {
|
||||
loadMeta()
|
||||
loadPets()
|
||||
}
|
||||
loadMeta()
|
||||
loadPets()
|
||||
|
||||
return () => relayPool?.unsubscribe(['profile-load-notes', 'profile-load-meta-pets'])
|
||||
}, []),
|
||||
@ -49,7 +47,7 @@ export const ProfileLoadPage: React.FC = () => {
|
||||
}, [user])
|
||||
|
||||
const loadMeta: () => void = () => {
|
||||
if (publicKey) {
|
||||
if (publicKey && relayPoolReady) {
|
||||
relayPool?.subscribe('profile-load-meta-pets', [
|
||||
{
|
||||
kinds: [Kind.Contacts],
|
||||
@ -64,7 +62,7 @@ export const ProfileLoadPage: React.FC = () => {
|
||||
}
|
||||
|
||||
const loadPets: () => void = () => {
|
||||
if (database && publicKey) {
|
||||
if (database && publicKey && relayPoolReady) {
|
||||
getUsers(database, {}).then((results) => {
|
||||
if (results && results.length > 0) {
|
||||
setContactsCount(results.filter((user) => user.contact).length)
|
||||
|
@ -37,6 +37,7 @@
|
||||
"react-native": "0.70.6",
|
||||
"react-native-action-button": "^2.8.5",
|
||||
"react-native-bidirectional-infinite-scroll": "^0.3.3",
|
||||
"react-native-device-info": "^10.3.0",
|
||||
"react-native-gesture-handler": "^2.8.0",
|
||||
"react-native-multithreading": "^1.1.1",
|
||||
"react-native-pager-view": "^6.1.2",
|
||||
|
@ -7225,6 +7225,11 @@ react-native-codegen@^0.70.6:
|
||||
jscodeshift "^0.13.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:
|
||||
version "2.8.0"
|
||||
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