Skip to content

Commit

Permalink
Merge branch 'main' into @kwasow/androidDebugging
Browse files Browse the repository at this point in the history
  • Loading branch information
dansup authored Feb 20, 2025
2 parents 932a578 + 94333d8 commit a7dfc9e
Show file tree
Hide file tree
Showing 13 changed files with 546 additions and 237 deletions.
33 changes: 33 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,37 @@ Build it with xcode. It shows the full error.

### Android: "Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain"


Try removing the folder containing this repository and clone it again.

Build it with xcode. It shows the full error.


### Android: BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67

This might mean that your java version is too new for the project. It is recommended to use Java 17.

### On macOS you can try this

`export JAVA_HOME=$(/usr/libexec/java_home -v 17)` after installing with homebrew and running

```
brew install openjdk@17
sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk
```

### Android: File google-services.json is missing

```
> Task :app:processDebugGoogleServices FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> File google-services.json is missing. The Google Services Plugin cannot function without it.
Searched Location:
```

This means firebase config is missing. you need to create a firebase project and put the google-services.json into the Repository’s root directory. Then run `npx expo prebuild --platform android`

16 changes: 2 additions & 14 deletions src/app/(auth)/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
deleteStatusV1,
fetchHomeFeed,
getSelfAccount,
postBookmark,
reblogStatus,
unreblogStatus,
} from 'src/lib/api'
Expand Down Expand Up @@ -90,6 +89,7 @@ export default function HomeScreen() {
useCallback(() => {
const unsubscribe = navigation.addListener('tabPress', () => {
flatListRef.current?.scrollToOffset({ animated: true, offset: 0 })
refetch()
})

return unsubscribe
Expand Down Expand Up @@ -162,16 +162,6 @@ export default function HomeScreen() {
},
})

const bookmarkMutation = useMutation({
mutationFn: async (id: string) => {
return await postBookmark(id)
},
})

const onBookmark = (id: string) => {
bookmarkMutation.mutate(id)
}

const onShare = (id: string, state) => {
try {
shareMutation.mutate({ type: state == true ? 'unreblog' : 'reblog', id: id })
Expand Down Expand Up @@ -228,11 +218,10 @@ export default function HomeScreen() {
user={user}
onOpenComments={() => onOpenComments(item.id)}
onDeletePost={() => onDeletePost(item.id)}
onBookmark={() => onBookmark(item.id)}
onShare={() => onShare(item.id, item.reblogged)}
/>
),
[user, onOpenComments, onDeletePost, onBookmark, onShare]
[user, onOpenComments, onDeletePost, onShare]
)

const { data: userSelf } = useQuery({
Expand Down Expand Up @@ -263,7 +252,6 @@ export default function HomeScreen() {
getNextPageParam: (lastPage) => lastPage.nextPage,
getPreviousPageParam: (lastPage) => lastPage.prevPage,
})

if (isFetching && !isFetchingNextPage && !isRefetching) {
return (
<View flexGrow={1} mt="$5" py="$5" justifyContent="center" alignItems="center">
Expand Down
15 changes: 2 additions & 13 deletions src/app/(auth)/(tabs)/network.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
deleteStatusV1,
fetchNetworkFeed,
getSelfAccount,
postBookmark,
reblogStatus,
unreblogStatus,
} from 'src/lib/api'
Expand Down Expand Up @@ -64,6 +63,7 @@ export default function HomeScreen() {
useCallback(() => {
const unsubscribe = navigation.addListener('tabPress', () => {
flatListRef.current?.scrollToOffset({ animated: true, offset: 0 })
refetch()
})

return unsubscribe
Expand Down Expand Up @@ -139,16 +139,6 @@ export default function HomeScreen() {
},
})

const bookmarkMutation = useMutation({
mutationFn: async (id: string) => {
return await postBookmark(id)
},
})

const onBookmark = (id: string) => {
bookmarkMutation.mutate(id)
}

const onShare = (id: string, state) => {
try {
shareMutation.mutate({ type: state == true ? 'unreblog' : 'reblog', id: id })
Expand Down Expand Up @@ -205,11 +195,10 @@ export default function HomeScreen() {
user={user}
onOpenComments={() => onOpenComments(item.id)}
onDeletePost={() => onDeletePost(item.id)}
onBookmark={() => onBookmark(item.id)}
onShare={() => onShare(item.id, item.reblogged)}
/>
),
[user, onOpenComments, onDeletePost, onBookmark, onShare]
[user, onOpenComments, onDeletePost, onShare]
)

const { data: userSelf } = useQuery({
Expand Down
84 changes: 46 additions & 38 deletions src/app/(auth)/notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,17 @@ export default function NotificationsScreen() {
const {
data,
fetchNextPage,
fetchPreviousPage,
hasNextPage,
hasPreviousPage,
isFetchingNextPage,
isFetching,
isError,
isRefetching,
error,
refetch,
} = useInfiniteQuery({
queryKey: ['notifications', activeTab],
queryFn: fetchNotifications,
getNextPageParam: (lastPage) => lastPage.nextPage,
getPreviousPageParam: (lastPage) => lastPage.prevPage,
getPreviousPageParam: (firstPage) => firstPage.prevPage,
})

useEffect(() => {
Expand All @@ -47,7 +45,19 @@ export default function NotificationsScreen() {
setActiveTab(value)
}

if (isFetching && !isFetchingNextPage) {
const handleInfiniteScroll = (_: { distanceFromEnd: number }) => {
if (isFetchingNextPage) {
return
}

if (hasNextPage) {
fetchNextPage()
}
}

// Since refetching cause the refetch of all the pages sequentially (longer waits), !isRefetching avoid unmonting of the FlatList and
// allow the user to see the past notifications in the meantime
if (isFetching && !isFetchingNextPage && !isRefetching) {
return (
<View flexGrow={1} mt="$5" p="$3">
<ActivityIndicator color={'#000'} />
Expand All @@ -64,7 +74,7 @@ export default function NotificationsScreen() {
}

return (
<SafeAreaView edges={['left']}>
<SafeAreaView edges={['left', 'bottom']}>
<Stack.Screen
options={{
title: 'Notifications',
Expand All @@ -81,57 +91,55 @@ export default function NotificationsScreen() {
width={SCREEN_WIDTH}
bg="$gray5"
>
<Tabs.List flex={1} separator={<Separator vertical borderColor="$gray5" />}>
<Tabs.List flex={1}>
<Tabs.Tab value="all" px="$0" flexGrow={1}>
<Tabs.Trigger value="all">
<Text fontSize="$2" fontWeight="bold" allowFontScaling={false}>
All
</Text>
</Tabs.Trigger>
<Text fontSize="$2" fontWeight="bold" allowFontScaling={false}>
All
</Text>
</Tabs.Tab>
<Separator vertical borderColor="$gray5" />
<Tabs.Tab value="mentions" px="$0" flexGrow={1}>
<Tabs.Trigger value="mentions">
<Feather name="at-sign" size={20} />
</Tabs.Trigger>
<Feather name="at-sign" size={20} />
</Tabs.Tab>
<Separator vertical borderColor="$gray5" />
<Tabs.Tab value="likes" px="$0" flexGrow={1}>
<Tabs.Trigger value="likes">
<Feather name="heart" size={20} />
</Tabs.Trigger>
<Feather name="heart" size={20} />
</Tabs.Tab>
<Separator vertical borderColor="$gray5" />
<Tabs.Tab value="follows" px="$0" flexGrow={1}>
<Tabs.Trigger value="follows">
<Feather name="user-plus" size={20} />
</Tabs.Trigger>
<Feather name="user-plus" size={20} />
</Tabs.Tab>
<Separator vertical borderColor="$gray5" />
<Tabs.Tab value="reblogs" px="$0" flexGrow={1}>
<Tabs.Trigger value="reblogs">
<Feather name="refresh-cw" size={20} />
</Tabs.Trigger>
<Feather name="refresh-cw" size={20} />
</Tabs.Tab>
</Tabs.List>
</Tabs>

<FlatList
style={{ height: '100%' }}
data={data?.pages.flatMap((page) => page.data)}
ItemSeparatorComponent={() => <Separator borderColor="$gray5" />}
renderItem={({ item }) => <RenderNotificationItem item={item} />}
onEndReached={() => {
if (hasNextPage) fetchNextPage()
}}
refreshing={isFetching}
onRefresh={() => queryClient.invalidateQueries({ queryKey: ['notifications'] })}
// In case of duplicates, discriminate the item with id_index avoid printing errors in console
keyExtractor={(item, index) => `${item.id}_${index.toString()}`}
onEndReached={handleInfiniteScroll}
refreshing={isRefetching}
onRefresh={() =>
queryClient.invalidateQueries({
queryKey: ['notifications'],
})
}
onEndReachedThreshold={0.5}
contentContainerStyle={{ flexGrow: 1 }}
ListFooterComponent={() =>
isFetchingNextPage ? (
<View py="$10">
<ActivityIndicator />
</View>
) : (
<View h={200}></View>
)
}
ListFooterComponent={() => (
<View py="$6">
{isFetchingNextPage ? <ActivityIndicator /> : null}
{!hasNextPage ? (
<Text ta="center">No more notifications for now!</Text>
) : null}
</View>
)}
/>
</SafeAreaView>
)
Expand Down
Loading

0 comments on commit a7dfc9e

Please sign in to comment.