Skip to content

Commit

Permalink
rename props to fix already declared names
Browse files Browse the repository at this point in the history
  • Loading branch information
drewvolz committed Sep 7, 2024
1 parent ffbddf5 commit a8c4c92
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 42 deletions.
22 changes: 6 additions & 16 deletions source/views/directory/detail.android.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import {callPhone} from '../../components/call-phone'
import {sendEmail} from '../../components/send-email'
import {buildEmailAction, buildPhoneActions} from './helpers'
import * as c from '@frogpond/colors'
import type {CampusLocation, Department} from './types'
import type {
CampusLocation,
Department,
DirectoryIconName,
DirectoryIconProps,
} from './types'
import {
Avatar,
Title,
Expand All @@ -21,26 +26,11 @@ import {
NativeStackNavigationProp,
} from '@react-navigation/native-stack'
import {RootStackParamList} from '../../../source/navigation/types'
import {StyleProp, ViewStyle} from 'react-native'

export const DetailNavigationOptions: NativeStackNavigationOptions = {
title: 'Contact',
}

type DirectoryIconName =
| 'calendar-clock-outline'
| 'email-outline'
| 'handshake-outline'
| 'link'
| 'map-marker-outline'
| 'open-in-new'
| 'phone'

interface DirectoryIconProps {
color: string
style?: StyleProp<ViewStyle>
}

const createDirectoryIcon =
(iconName: DirectoryIconName) => (props: DirectoryIconProps) => (
<List.Icon {...props} icon={iconName} />
Expand Down
22 changes: 13 additions & 9 deletions source/views/directory/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {LoadingView, NoticeView} from '@frogpond/notice'
import {formatResults} from './helpers'
import {useDirectoryEntries} from './query'
import {Avatar, List} from 'react-native-paper'
import type {DirectoryItem, DirectorySearchTypeEnum} from './types'
import type {DirectoryIconProps, DirectoryItem, DirectorySearchTypeEnum} from './types'

Check failure on line 19 in source/views/directory/list.tsx

View workflow job for this annotation

GitHub Actions / ESLint

Replace `DirectoryIconProps,·DirectoryItem,·DirectorySearchTypeEnum` with `⏎↹DirectoryIconProps,⏎↹DirectoryItem,⏎↹DirectorySearchTypeEnum,⏎`
import Icon from 'react-native-vector-icons/Ionicons'
import {RouteProp, useNavigation, useRoute} from '@react-navigation/native'
import {
Expand Down Expand Up @@ -154,17 +154,21 @@ function IosDirectoryItemRow({item, onPress}: DirectoryItemRowProps) {
}

function AndroidDirectoryItemRow({item, onPress}: DirectoryItemRowProps) {
const renderAvatar = (props: DirectoryIconProps) => {
return (
<Avatar.Image
{...props}
size={42}
source={{uri: item.thumbnail}}
style={[props.style, styles.image]}
/>
)
}

return (
<List.Item
description={item.description}
left={(props) => (
<Avatar.Image
{...props}
size={42}
source={{uri: item.thumbnail}}
style={[props.style, styles.image]}
/>
)}
left={renderAvatar}
onPress={onPress}
title={item.displayName}
/>
Expand Down
4 changes: 2 additions & 2 deletions source/views/directory/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export function useDirectoryEntries(
): UseQueryResult<SearchResults, unknown> {
return useQuery({
queryKey: keys.all(getDirectoryQuery({query, type})),
queryFn: async ({queryKey: [_, query], signal}) => {
queryFn: async ({queryKey: [_, searchQuery], signal}) => {
let response = await directory
.get('search', {searchParams: query, signal})
.get('search', {searchParams: searchQuery, signal})
.json()
return response as SearchResults
},
Expand Down
16 changes: 16 additions & 0 deletions source/views/directory/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleProp, ViewStyle } from "react-native"

Check failure on line 1 in source/views/directory/types.ts

View workflow job for this annotation

GitHub Actions / ESLint

Replace `·StyleProp,·ViewStyle·}·from·"react-native"` with `StyleProp,·ViewStyle}·from·'react-native'`

Check warning on line 1 in source/views/directory/types.ts

View workflow job for this annotation

GitHub Actions / ESLint

Strings must use singlequote

export type CampusLocation = {
display: string
buildingabbr: string
Expand Down Expand Up @@ -77,3 +79,17 @@ export type DirectorySearchTypeEnum =
| 'query'
| 'title'
| 'username'

export type DirectoryIconName =
| 'calendar-clock-outline'
| 'email-outline'
| 'handshake-outline'
| 'link'
| 'map-marker-outline'
| 'open-in-new'
| 'phone'

export interface DirectoryIconProps {
color: string
style?: StyleProp<ViewStyle>
}
6 changes: 3 additions & 3 deletions source/views/menus/dev-bonapp-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const styles = StyleSheet.create({
export const BonAppPickerView = (): JSX.Element => {
let [cafeId, setCafeId] = React.useState('')

let chooseCafe = (cafeId: string) => {
if (!/^\d*$/u.test(cafeId)) {
let chooseCafe = (selectedCafeId: string) => {
if (!/^\d*$/u.test(selectedCafeId)) {
return
}
setCafeId(cafeId)
setCafeId(selectedCafeId)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion source/views/more/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function MoreView(): JSX.Element {
let filteredData = []
for (let {title, data: items} of data) {
let filteredItems = items.filter((value) =>
linkToArray(value).some((value) => value.includes(searchQuery)),
linkToArray(value).some((item) => item.includes(searchQuery)),
)
if (filteredItems.length) {
filteredData.push({title, data: items})
Expand Down
12 changes: 6 additions & 6 deletions source/views/news/news-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const styles = StyleSheet.create({
})

let getStoryCategories = (story: StoryType) => {
return story.categories.map((c) => trimStoryCateogry(c))
return story.categories.map((category) => trimStoryCateogry(category))
}

let filterStories = (entries: StoryType[], filters: ListType<StoryType>[]) => {
Expand All @@ -44,6 +44,10 @@ let filterStories = (entries: StoryType[], filters: ListType<StoryType>[]) => {
})
}

const NewsItemSeparator = (thumbnail: Props['thumbnail']) => (
<ListSeparator spacing={{left: thumbnail === false ? undefined : 101}} />
)

export const NewsList = (props: Props): JSX.Element => {
let {
data = [],
Expand Down Expand Up @@ -112,11 +116,7 @@ export const NewsList = (props: Props): JSX.Element => {

return (
<FlatList
ItemSeparatorComponent={() => (
<ListSeparator
spacing={{left: props.thumbnail === false ? undefined : 101}}
/>
)}
ItemSeparatorComponent={NewsItemSeparator}
ListEmptyComponent={
isLoading ? (
<LoadingView />
Expand Down
3 changes: 2 additions & 1 deletion source/views/settings/screens/api-test/detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export const APITestDetailView = (): JSX.Element => {
})

React.useLayoutEffect(() => {
const rightButton = () => <NetworkLoggerButton />
navigation.setOptions({
title: cleanedName,
headerRight: () => <NetworkLoggerButton />,
headerRight: rightButton,
})
}, [cleanedName, navigation])

Expand Down
3 changes: 2 additions & 1 deletion source/views/settings/screens/api-test/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const APITestView = (): JSX.Element => {
} = useServerRoutes()

React.useLayoutEffect(() => {
const rightButton = () => <NetworkLoggerButton />
navigation.setOptions({
headerSearchBarOptions: {
autoCapitalize: 'none',
Expand All @@ -39,7 +40,7 @@ export const APITestView = (): JSX.Element => {
setFilterPath(event.nativeEvent.text),
placeholder: '/path/to/uri',
},
headerRight: () => <NetworkLoggerButton />,
headerRight: rightButton,
})
}, [navigation])

Expand Down
6 changes: 3 additions & 3 deletions source/views/settings/screens/change-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ export let IconSettingsView = (): JSX.Element => {
getIcon()
}, [])

let setIcon = async (iconType: string) => {
if (iconType === 'default') {
let setIcon = async (iconName: string) => {
if (iconName === 'default') {
await Icons.reset()
} else {
await Icons.setIconName(iconType)
await Icons.setIconName(iconName)
}

getIcon()
Expand Down

0 comments on commit a8c4c92

Please sign in to comment.