mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-28 22:30:41 +00:00
Some Improvements
This commit is contained in:
parent
e9eaa6eec2
commit
e856e4e6de
@ -88,7 +88,7 @@ export const ConfigPage: React.FC = () => {
|
||||
<Layout style={styles.action}>
|
||||
<Button
|
||||
onPress={() => goToPage('relays')}
|
||||
status='info'
|
||||
status='warning'
|
||||
accessoryLeft={
|
||||
<Icon name='server' size={16} color={theme['text-basic-color']} solid />
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ export const ContactsPage: React.FC = () => {
|
||||
|
||||
const loadUsers: () => void = () => {
|
||||
if (database && publicKey) {
|
||||
setTimeout(() => setRefreshing(false), 5000)
|
||||
getUsers(database, { contacts: true }).then((results) => {
|
||||
if (users) setRefreshing(false)
|
||||
if (results) setUsers(results)
|
||||
})
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ export const HomePage: React.FC = () => {
|
||||
|
||||
const calculateInitialNotes: () => Promise<void> = async () => {
|
||||
if (database && publicKey) {
|
||||
setTimeout(() => setRefreshing(false), 5000)
|
||||
const users = await getUsers(database, { contacts: true, includeIds: [publicKey] })
|
||||
setAuthors(users)
|
||||
subscribeNotes(users)
|
||||
@ -64,9 +65,6 @@ export const HomePage: React.FC = () => {
|
||||
getNotes(database, { contacts: true, includeIds: [publicKey], limit: pageSize }).then(
|
||||
(notes) => {
|
||||
setNotes(notes)
|
||||
if (notes.length > 0 || authors.length === 0) {
|
||||
setRefreshing(false)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import { getReplyEventId } from '../../Functions/RelayFunctions/Events'
|
||||
import moment from 'moment'
|
||||
import { populateRelay } from '../../Functions/RelayFunctions'
|
||||
import Avatar from '../Avatar'
|
||||
import { markdownStyle } from '../../Constants/AppConstants'
|
||||
import { markdownIt, markdownStyle } from '../../Constants/AppConstants'
|
||||
|
||||
interface NoteCardProps {
|
||||
note: Note
|
||||
@ -56,7 +56,9 @@ export const NoteCard: React.FC<NoteCardProps> = ({ note }) => {
|
||||
</Layout>
|
||||
</Layout>
|
||||
<Layout style={styles.text}>
|
||||
<Markdown style={markdownStyle(theme)}>{note.content}</Markdown>
|
||||
<Markdown style={markdownStyle(theme)} markdownit={markdownIt}>
|
||||
{note.content}
|
||||
</Markdown>
|
||||
</Layout>
|
||||
<Layout style={styles.footer}>
|
||||
<Text appearance='hint'>{moment.unix(note.created_at).format('DD-MM-YY HH:mm')}</Text>
|
||||
|
@ -37,8 +37,9 @@ export const NotePage: React.FC = () => {
|
||||
|
||||
const onRefresh = useCallback(() => {
|
||||
setRefreshing(true)
|
||||
setTimeout(() => setRefreshing(false), 5000)
|
||||
relayPool?.unsubscribeAll()
|
||||
subscribeNotes().finally(() => setRefreshing(false))
|
||||
subscribeNotes()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -76,7 +76,6 @@ export const ProfilePage: React.FC = () => {
|
||||
if (database) {
|
||||
getNotes(database, { filters: { pubkey: userId }, limit: pageSize }).then((results) => {
|
||||
setNotes(results)
|
||||
setRefreshing(false)
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -112,7 +111,8 @@ export const ProfilePage: React.FC = () => {
|
||||
const ids = event.tags.map((tag) => tagToUser(tag).id)
|
||||
setContactsIds(ids)
|
||||
} else if (event.kind === EventKind.meta) {
|
||||
storeEvent(event, database).then(() => setRefreshing(false))
|
||||
setTimeout(() => setRefreshing(false), 5000)
|
||||
storeEvent(event, database)
|
||||
subscribeNotes()
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { StyleSheet } from 'react-native'
|
||||
import { MarkdownIt } from 'react-native-markdown-display'
|
||||
|
||||
export const markdownStyle: (theme: Record<string, string>) => StyleSheet.NamedStyles<any> = (
|
||||
theme,
|
||||
@ -41,3 +42,7 @@ export const markdownStyle: (theme: Record<string, string>) => StyleSheet.NamedS
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export const markdownIt = new MarkdownIt({
|
||||
linkify: true,
|
||||
})
|
||||
|
@ -4,6 +4,8 @@ import { initDatabase } from '../Functions/DatabaseFunctions'
|
||||
import { createInitDatabase } from '../Functions/DatabaseFunctions/Migrations'
|
||||
import FlashMessage from 'react-native-flash-message'
|
||||
import SInfo from 'react-native-sensitive-info'
|
||||
import { BackHandler } from 'react-native'
|
||||
import { markdownIt } from '../Constants/AppConstants'
|
||||
|
||||
export interface AppContextProps {
|
||||
page: string
|
||||
@ -35,6 +37,15 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
||||
const [loadingDb, setLoadingDb] = useState<boolean>(initialAppContext.loadingDb)
|
||||
|
||||
const init: () => void = () => {
|
||||
BackHandler.addEventListener('hardwareBackPress', () => {
|
||||
goBack()
|
||||
return true
|
||||
})
|
||||
markdownIt.linkify
|
||||
.tlds('onion', true)
|
||||
.add('git:', 'http:')
|
||||
.add('ftp:', null)
|
||||
.set({ fuzzyIP: true })
|
||||
const db = initDatabase()
|
||||
setDatabase(db)
|
||||
SInfo.getItem('privateKey', {}).then((result) => {
|
||||
@ -60,7 +71,9 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
||||
|
||||
const goBack: () => void = () => {
|
||||
const breadcrump = page.split('%')
|
||||
setPage(breadcrump.slice(0, -1).join('%') || 'home')
|
||||
if (breadcrump.length > 1) {
|
||||
setPage(breadcrump.slice(0, -1).join('%'))
|
||||
}
|
||||
}
|
||||
|
||||
const getActualPage: () => string = () => {
|
||||
|
@ -21,6 +21,7 @@
|
||||
"create-hash": "^1.2.0",
|
||||
"events": "^3.3.0",
|
||||
"i18next": "^22.0.2",
|
||||
"markdown-it": "^13.0.1",
|
||||
"moment": "^2.29.4",
|
||||
"react": "18.1.0",
|
||||
"react-i18next": "^11.18.6",
|
||||
|
23
yarn.lock
23
yarn.lock
@ -2882,6 +2882,11 @@ entities@~2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.3.tgz#5c487e5742ab93c15abb5da22759b8590ec03b7f"
|
||||
integrity sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==
|
||||
|
||||
entities@~3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4"
|
||||
integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q==
|
||||
|
||||
envinfo@^7.7.2:
|
||||
version "7.8.1"
|
||||
resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475"
|
||||
@ -4910,6 +4915,13 @@ linkify-it@^2.0.0:
|
||||
dependencies:
|
||||
uc.micro "^1.0.1"
|
||||
|
||||
linkify-it@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-4.0.1.tgz#01f1d5e508190d06669982ba31a7d9f56a5751ec"
|
||||
integrity sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw==
|
||||
dependencies:
|
||||
uc.micro "^1.0.1"
|
||||
|
||||
locate-path@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e"
|
||||
@ -5033,6 +5045,17 @@ markdown-it@^10.0.0:
|
||||
mdurl "^1.0.1"
|
||||
uc.micro "^1.0.5"
|
||||
|
||||
markdown-it@^13.0.1:
|
||||
version "13.0.1"
|
||||
resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.1.tgz#c6ecc431cacf1a5da531423fc6a42807814af430"
|
||||
integrity sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q==
|
||||
dependencies:
|
||||
argparse "^2.0.1"
|
||||
entities "~3.0.1"
|
||||
linkify-it "^4.0.1"
|
||||
mdurl "^1.0.1"
|
||||
uc.micro "^1.0.5"
|
||||
|
||||
md5.js@^1.3.4:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
|
||||
|
Loading…
Reference in New Issue
Block a user