Skip to content

Commit

Permalink
fix list (#414)
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat authored Mar 10, 2023
2 parents ec0d83f + ed5c5b9 commit ce599b5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 33 deletions.
4 changes: 1 addition & 3 deletions frontend/Pages/ProfileLoadPage/FirstStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export const FirstStep: React.FC<FirstStepProps> = ({ nextStep }) => {
relays.forEach((relay) => {
removeRelayItem(relay)
})
metadata.tags.forEach(
async (tag) => await addRelayItem({ url: tag[1], paid: tag[3] === 'paid' ? 1 : 0 }),
)
metadata.tags.forEach(async (tag) => await addRelayItem({ url: tag[1] }))
nextStep()
}
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/Pages/ProfileLoadPage/SecondStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const SecondStep: React.FC<SecondStepProps> = ({ nextStep }) => {
if (results.length > 0) {
setContactsCount(results.filter((user) => user.contact).length)
const authors = [...results.map((user: User) => user.id)]
relayPool?.subscribe('profile-load-notes', [
relayPool?.subscribe('profile-load-contacts', [
{
kinds: [Kind.Metadata, 10002],
authors,
Expand Down Expand Up @@ -156,7 +156,7 @@ export const SecondStep: React.FC<SecondStepProps> = ({ nextStep }) => {
</View>
</View>
<View style={styles.buttons}>
<Button mode='contained' onPress={nextStep} disabled={contactsCount === undefined}>
<Button mode='contained' onPress={nextStep} disabled={!contactsCount}>
{t('profileLoadPage.nextStep')}
</Button>
<Button mode='outlined' onPress={() => setUserState('ready')}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/Pages/ProfileLoadPage/ThirdStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const ThirdStep: React.FC<ThirdStepProps> = ({ nextStep }) => {
getUsers(database, {}).then((results) => {
if (results.length > 0) {
const authors = [...results.map((user: User) => user.id), publicKey]
relayPool?.subscribe('profile-load-relays', [
relayPool?.subscribe('profile-load-contacts', [
{
kinds: [10002],
authors,
Expand Down
8 changes: 1 addition & 7 deletions frontend/Pages/ProfileLoadPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ export const ProfileLoadPage: React.FC = () => {

useFocusEffect(
React.useCallback(() => {
return () =>
relayPool?.unsubscribe([
'profile-load-meta',
'profile-load-contacts',
'profile-load-notes',
'profile-load-relays',
])
return () => relayPool?.unsubscribe(['profile-load-meta', 'profile-load-contacts'])
}, []),
)

Expand Down
39 changes: 19 additions & 20 deletions frontend/Pages/RelaysPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,7 @@ export const RelaysPage: React.FC = () => {
const activeRelays = relays.filter(
(relay) => relay?.active && (!relay.resilient || relay.resilient < 0),
)
const tags: string[][] = activeRelays.map((relay) => [
'r',
relay.url ?? '',
relay.mode ?? '',
relay.paid ? 'paid' : '',
])
const tags: string[][] = activeRelays.map((relay) => ['r', relay.url ?? '', relay.mode ?? ''])
const event: Event = {
content: '',
created_at: getUnixTime(new Date()),
Expand Down Expand Up @@ -267,14 +262,14 @@ export const RelaysPage: React.FC = () => {
</View>
<FlatList
showsVerticalScrollIndicator={false}
data={relays.filter((relay) => {
return (
(!relay.resilient &&
(relay.paid === undefined || relay.paid < 1) &&
showFreeRelays) ||
(!relay.resilient && relay.paid !== undefined && relay.paid > 0 && showPaidRelays)
)
})}
data={relays
.filter((relay) => !relay.resilient || relay.resilient < 1)
.filter((relay) => {
return (
((relay.paid === undefined || relay.paid < 1) && showFreeRelays) ||
(relay.paid !== undefined && relay.paid > 0 && showPaidRelays)
)
})}
renderItem={renderItem}
ItemSeparatorComponent={Divider}
/>
Expand All @@ -287,12 +282,16 @@ export const RelaysPage: React.FC = () => {
<FlatList
showsVerticalScrollIndicator={false}
style={styles.relayList}
data={relays.filter((relay) => {
return (
(relay.resilient && (relay.paid === undefined || relay.paid < 1) && showFreeRelays) ??
(relay.resilient && relay.paid !== undefined && relay.paid > 0 && showPaidRelays)
)
})}
data={relays
.filter((relay) => relay.resilient && relay.resilient > 0)
.filter((relay) => {
return (
(relay.resilient &&
(relay.paid === undefined || relay.paid < 1) &&
showFreeRelays) ??
(relay.resilient && relay.paid !== undefined && relay.paid > 0 && showPaidRelays)
)
})}
renderItem={renderItem}
ItemSeparatorComponent={Divider}
/>
Expand Down

0 comments on commit ce599b5

Please sign in to comment.