mirror of
https://github.com/KoalaSat/nostros.git
synced 2024-09-29 06:30:47 +00:00
Push to top and decimal numbers
This commit is contained in:
parent
f213bf95d2
commit
755bc51ca9
@ -102,6 +102,7 @@ export const LnPayment: React.FC<LnPaymentProps> = ({ open, setOpen, event, user
|
||||
label={t('lnPayment.monto') ?? ''}
|
||||
onChangeText={setMonto}
|
||||
value={monto}
|
||||
keyboardType='decimal-pad'
|
||||
/>
|
||||
<TextInput
|
||||
style={styles.spacer}
|
||||
|
@ -39,6 +39,8 @@ export interface AppContextProps {
|
||||
setDisplayUserShareDrawer: (displayUserShareDrawer: string | undefined) => void
|
||||
refreshBottomBarAt?: number
|
||||
setRefreshBottomBarAt: (refreshBottomBarAt: number) => void
|
||||
pushedTab?: string
|
||||
setPushedTab: (pushedTab: string) => void
|
||||
}
|
||||
|
||||
export interface AppContextProviderProps {
|
||||
@ -70,6 +72,8 @@ export const initialAppContext: AppContextProps = {
|
||||
checkClipboard: () => {},
|
||||
imageHostingService: 'random',
|
||||
setImageHostingService: () => {},
|
||||
pushedTab: 'random',
|
||||
setPushedTab: () => {},
|
||||
getImageHostingService: () => '',
|
||||
getSatoshiSymbol: () => <></>,
|
||||
setClipboardNip21: () => {},
|
||||
@ -100,6 +104,13 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
||||
const [clipboardNip21, setClipboardNip21] = React.useState<string>()
|
||||
const [displayUserDrawer, setDisplayUserDrawer] = React.useState<string>()
|
||||
const [displayUserShareDrawer, setDisplayUserShareDrawer] = React.useState<string>()
|
||||
const [pushedTab, setPushedTab] = useState<string>()
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
setPushedTab(undefined)
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
useEffect(() => {
|
||||
const handleChange = AppState.addEventListener('change', (changedState) => {
|
||||
@ -222,6 +233,8 @@ export const AppContextProvider = ({ children }: AppContextProviderProps): JSX.E
|
||||
displayUserShareDrawer,
|
||||
refreshBottomBarAt,
|
||||
setRefreshBottomBarAt,
|
||||
pushedTab,
|
||||
setPushedTab,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
|
@ -28,7 +28,7 @@ interface GlobalFeedProps {
|
||||
|
||||
export const GlobalFeed: React.FC<GlobalFeedProps> = ({ navigation }) => {
|
||||
const theme = useTheme()
|
||||
const { database, showPublicImages } = useContext(AppContext)
|
||||
const { database, showPublicImages, pushedTab } = useContext(AppContext)
|
||||
const { publicKey } = useContext(UserContext)
|
||||
const { lastEventId, relayPool, lastConfirmationtId } = useContext(RelayPoolContext)
|
||||
const initialPageSize = 10
|
||||
@ -37,11 +37,18 @@ export const GlobalFeed: React.FC<GlobalFeedProps> = ({ navigation }) => {
|
||||
const [newNotesCount, setNewNotesCount] = useState<number>(0)
|
||||
const [pageSize, setPageSize] = useState<number>(initialPageSize)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const flashListRef = React.useRef<FlashList<Note>>(null)
|
||||
|
||||
useEffect(() => {
|
||||
subscribeNotes()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
flashListRef.current?.scrollToIndex({ animated: true, index: 0 })
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
useEffect(() => {
|
||||
if (relayPool && publicKey) {
|
||||
loadNotes()
|
||||
@ -183,6 +190,7 @@ export const GlobalFeed: React.FC<GlobalFeedProps> = ({ navigation }) => {
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
horizontal={false}
|
||||
ListFooterComponent={<ActivityIndicator animating={true} />}
|
||||
ref={flashListRef}
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
|
@ -24,7 +24,7 @@ import {
|
||||
export const HomePage: React.FC = () => {
|
||||
const theme = useTheme()
|
||||
const { t } = useTranslation('common')
|
||||
const { language } = React.useContext(AppContext)
|
||||
const { language, setPushedTab } = React.useContext(AppContext)
|
||||
const { privateKey, publicKey } = React.useContext(UserContext)
|
||||
const { database, notificationSeenAt, clipboardNip21, setClipboardNip21, refreshBottomBarAt } =
|
||||
useContext(AppContext)
|
||||
@ -138,6 +138,9 @@ export const HomePage: React.FC = () => {
|
||||
/>
|
||||
),
|
||||
}}
|
||||
listeners={{
|
||||
tabPress: () => setPushedTab('Home'),
|
||||
}}
|
||||
/>
|
||||
{privateKey && (
|
||||
<Tab.Screen
|
||||
@ -189,6 +192,9 @@ export const HomePage: React.FC = () => {
|
||||
</>
|
||||
),
|
||||
}}
|
||||
listeners={{
|
||||
tabPress: () => setPushedTab('Notifications'),
|
||||
}}
|
||||
/>
|
||||
</Tab.Navigator>
|
||||
|
||||
|
@ -29,13 +29,20 @@ interface MyFeedProps {
|
||||
export const MyFeed: React.FC<MyFeedProps> = ({ navigation }) => {
|
||||
const theme = useTheme()
|
||||
const { t } = useTranslation('common')
|
||||
const { database } = useContext(AppContext)
|
||||
const { database, pushedTab } = useContext(AppContext)
|
||||
const { publicKey } = useContext(UserContext)
|
||||
const { lastEventId, relayPool, lastConfirmationtId } = useContext(RelayPoolContext)
|
||||
const initialPageSize = 10
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [pageSize, setPageSize] = useState<number>(initialPageSize)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const flashListRef = React.useRef<FlashList<Note>>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
flashListRef.current?.scrollToIndex({ animated: true, index: 0 })
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
useEffect(() => {
|
||||
subscribeNotes()
|
||||
@ -169,6 +176,7 @@ export const MyFeed: React.FC<MyFeedProps> = ({ navigation }) => {
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
horizontal={false}
|
||||
ListFooterComponent={<ActivityIndicator animating={true} />}
|
||||
ref={flashListRef}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
@ -27,13 +27,14 @@ import { FlashList, ListRenderItem } from '@shopify/flash-list'
|
||||
export const NotificationsFeed: React.FC = () => {
|
||||
const theme = useTheme()
|
||||
const { t } = useTranslation('common')
|
||||
const { database, setNotificationSeenAt } = useContext(AppContext)
|
||||
const { database, setNotificationSeenAt, pushedTab } = useContext(AppContext)
|
||||
const { publicKey } = useContext(UserContext)
|
||||
const initialPageSize = 10
|
||||
const { lastEventId, relayPool } = useContext(RelayPoolContext)
|
||||
const [pageSize, setPageSize] = useState<number>(initialPageSize)
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [refreshing, setRefreshing] = useState(true)
|
||||
const flashListRef = React.useRef<FlashList<Note>>(null)
|
||||
|
||||
useFocusEffect(
|
||||
React.useCallback(() => {
|
||||
@ -64,6 +65,12 @@ export const NotificationsFeed: React.FC = () => {
|
||||
}
|
||||
}, [pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
flashListRef.current?.scrollToIndex({ animated: true, index: 0 })
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
const updateLastSeen: () => void = () => {
|
||||
const unixtime = getUnixTime(new Date())
|
||||
setNotificationSeenAt(unixtime)
|
||||
@ -180,6 +187,7 @@ export const NotificationsFeed: React.FC = () => {
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
horizontal={false}
|
||||
ListFooterComponent={<ActivityIndicator animating={true} />}
|
||||
ref={flashListRef}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
@ -27,13 +27,14 @@ interface ReactionsFeedProps {
|
||||
|
||||
export const ReactionsFeed: React.FC<ReactionsFeedProps> = ({ navigation }) => {
|
||||
const theme = useTheme()
|
||||
const { database } = useContext(AppContext)
|
||||
const { database, pushedTab } = useContext(AppContext)
|
||||
const { publicKey } = useContext(UserContext)
|
||||
const { lastEventId, relayPool, lastConfirmationtId } = useContext(RelayPoolContext)
|
||||
const initialPageSize = 10
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [pageSize, setPageSize] = useState<number>(initialPageSize)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const flashListRef = React.useRef<FlashList<Note>>(null)
|
||||
|
||||
useEffect(() => {
|
||||
subscribeNotes()
|
||||
@ -52,6 +53,12 @@ export const ReactionsFeed: React.FC<ReactionsFeedProps> = ({ navigation }) => {
|
||||
}
|
||||
}, [pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
flashListRef.current?.scrollToIndex({ animated: true, index: 0 })
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
const onRefresh = useCallback(() => {
|
||||
setRefreshing(true)
|
||||
subscribeNotes()
|
||||
@ -169,6 +176,7 @@ export const ReactionsFeed: React.FC<ReactionsFeedProps> = ({ navigation }) => {
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
horizontal={false}
|
||||
ListFooterComponent={<ActivityIndicator animating={true} />}
|
||||
ref={flashListRef}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
@ -27,13 +27,14 @@ interface RepostsFeedProps {
|
||||
|
||||
export const RepostsFeed: React.FC<RepostsFeedProps> = ({ navigation }) => {
|
||||
const theme = useTheme()
|
||||
const { database } = useContext(AppContext)
|
||||
const { database, pushedTab } = useContext(AppContext)
|
||||
const { publicKey } = useContext(UserContext)
|
||||
const { lastEventId, relayPool, lastConfirmationtId } = useContext(RelayPoolContext)
|
||||
const initialPageSize = 10
|
||||
const [notes, setNotes] = useState<Note[]>([])
|
||||
const [pageSize, setPageSize] = useState<number>(initialPageSize)
|
||||
const [refreshing, setRefreshing] = useState(false)
|
||||
const flashListRef = React.useRef<FlashList<Note>>(null)
|
||||
|
||||
useEffect(() => {
|
||||
subscribeNotes()
|
||||
@ -52,6 +53,12 @@ export const RepostsFeed: React.FC<RepostsFeedProps> = ({ navigation }) => {
|
||||
}
|
||||
}, [pageSize])
|
||||
|
||||
useEffect(() => {
|
||||
if (pushedTab) {
|
||||
flashListRef.current?.scrollToIndex({ animated: true, index: 0 })
|
||||
}
|
||||
}, [pushedTab])
|
||||
|
||||
const onRefresh = useCallback(() => {
|
||||
setRefreshing(true)
|
||||
subscribeNotes()
|
||||
@ -161,6 +168,7 @@ export const RepostsFeed: React.FC<RepostsFeedProps> = ({ navigation }) => {
|
||||
ListEmptyComponent={ListEmptyComponent}
|
||||
horizontal={false}
|
||||
ListFooterComponent={<ActivityIndicator animating={true} />}
|
||||
ref={flashListRef}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user