Skip to content

Commit

Permalink
.. i forgot what i all changed. Some stuff probably.
Browse files Browse the repository at this point in the history
  • Loading branch information
docimin committed Sep 17, 2024
1 parent b732805 commit 74f67c3
Show file tree
Hide file tree
Showing 16 changed files with 252 additions and 137 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"applinks:headpat.place",
"applinks:api.headpat.place"
],
"buildNumber": "91"
"buildNumber": "93"
},
"android": {
"permissions": [
Expand All @@ -73,7 +73,7 @@
}
},
"package": "com.headpat.app",
"versionCode": 64
"versionCode": 66
},
"extra": {
"router": {
Expand Down
68 changes: 43 additions & 25 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import DiscordIcon from '~/components/icons/DiscordIcon'
import EulaModal from '~/components/EulaModal'
import { Muted } from '~/components/ui/typography'
import * as Updates from 'expo-updates'
import { LocationObject } from 'expo-location'

async function bootstrap() {
const initialNotification = await messaging().getInitialNotification()
Expand All @@ -75,37 +76,54 @@ async function bootstrap() {
}
}

TaskManager.defineTask('background-location-task', async ({ data, error }) => {
if (error) {
console.error(error)
Sentry.captureException(error)
return BackgroundFetch.BackgroundFetchResult.Failed
}

// Use the user data from the task
const userId = await AsyncStorage.getItem('userId')
TaskManager.defineTask(
'background-location-task',
async ({
data,

Check warning on line 82 in app/_layout.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused parameter data
error,
}: {
data: { locations: LocationObject[] }
error: any
}) => {
if (error) {
console.error(error)
Sentry.captureException(error)
return BackgroundFetch.BackgroundFetchResult.Failed
}

if (!userId) {
return BackgroundFetch.BackgroundFetchResult.Failed
}
// Use the user data from the task
const userId = await AsyncStorage.getItem('userId')
const preciseLocation = await AsyncStorage.getItem('preciseLocation')

// Get current location
const location = await Location.getCurrentPositionAsync()
if (!userId) {
return Location.stopLocationUpdatesAsync('background-location-task')
}

// Make API calls to update or create location document
await database
.updateDocument('hp_db', 'locations', userId, {
long: location.coords.longitude,
lat: location.coords.latitude,
// Get current location
const location = await Location.getCurrentPositionAsync({
accuracy:
preciseLocation === 'true'
? Location.Accuracy.High
: Location.Accuracy.Low,
})
.catch(async () => {
await database.createDocument('hp_db', 'locations', userId, {

// Make API calls to update or create location document
await database
.updateDocument('hp_db', 'locations', userId, {
long: location.coords.longitude,
lat: location.coords.latitude,
timeUntilEnd: new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
})
})
})
.catch(async () => {
await database.createDocument('hp_db', 'locations', userId, {
long: location.coords.longitude,
lat: location.coords.latitude,
timeUntilEnd: new Date(
Date.now() + 24 * 60 * 60 * 1000
).toISOString(),
})
})
}
)

const LIGHT_THEME: Theme = {
dark: false,
Expand Down Expand Up @@ -323,7 +341,7 @@ function CustomDrawerContent() {
</View>
)
}}
onPress={() => router.navigate('/community/list')}
onPress={() => router.navigate('/community')}
/>

<View style={{ flex: 1, flexGrow: 1 }}></View>
Expand Down
15 changes: 4 additions & 11 deletions app/account/(stacks)/userprofile/(tabs)/avatarAdd/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function AvatarAdd() {
const [image, setImage] = useState<ImagePicker.ImageOrVideo>(null)
const { showLoadingModal, hideLoadingModal, showAlertModal } = useAlertModal()
const maxFileSize = 1.5 * 1024 * 1024 // 1.5 MB in bytes
const maxResolution = 8 * 1024 * 1024

const pickImage = async () => {
try {
Expand All @@ -29,16 +28,10 @@ export default function AvatarAdd() {
return
}

if (result.width + result.height > maxResolution) {
showAlertModal('FAILED', 'Image resolution is too large.')
return
}

if (result.width + result.height <= maxResolution) {
setImage(result)
}
setImage(result)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.log(error)
//console.log(error)
//showAlertModal('FAILED', 'Error picking image.')
//Sentry.captureException(error)
}
Expand Down Expand Up @@ -114,7 +107,7 @@ export default function AvatarAdd() {
} catch (error) {
console.log('error', error)
showAlertModal('FAILED', 'Error uploading image.')
Sentry.captureException(error)
Sentry.captureMessage(error, 'log')
}
}

Expand Down
17 changes: 5 additions & 12 deletions app/account/(stacks)/userprofile/(tabs)/bannerAdd/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default function BannerAdd() {
const [image, setImage] = useState<ImagePicker.ImageOrVideo>(null)
const { showLoadingModal, hideLoadingModal, showAlertModal } = useAlertModal()
const maxFileSize = 5 * 1024 * 1024 // 1.5 MB in bytes
const maxResolution = 8 * 1024 * 1024

const pickImage = async () => {
try {
Expand All @@ -28,16 +27,10 @@ export default function BannerAdd() {
return
}

if (result.width + result.height > maxResolution) {
showAlertModal('FAILED', 'Image resolution is too large.')
return
}

if (result.width + result.height <= maxResolution) {
setImage(result)
}
setImage(result)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.log(error)
//console.log(error)
//showAlertModal('FAILED', 'Error picking image.')
//Sentry.captureException(error)
}
Expand Down Expand Up @@ -115,9 +108,9 @@ export default function BannerAdd() {
hideLoadingModal()
handleFinish()
} catch (error) {
console.log(error)
//console.log(error)
showAlertModal('FAILED', 'Error picking image.')
Sentry.captureException(error)
Sentry.captureMessage(error, 'log')
}
}

Expand Down
12 changes: 10 additions & 2 deletions app/announcements/(stacks)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
View,
} from 'react-native'
import { H1, H3, Muted } from '~/components/ui/typography'
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { Announcements } from '~/lib/types/collections'
import { database } from '~/lib/appwrite-client'
import { Query } from 'react-native-appwrite'
Expand All @@ -22,6 +22,7 @@ import { formatDate } from '~/components/calculateTimeLeft'
import { useColorScheme } from '~/lib/useColorScheme'
import { useAlertModal } from '~/components/contexts/AlertModalProvider'
import * as Sentry from '@sentry/react-native'
import { useFocusEffect } from '@react-navigation/core'

export default function AnnouncementsPage() {
const { isDarkColorScheme } = useColorScheme()
Expand Down Expand Up @@ -59,8 +60,15 @@ export default function AnnouncementsPage() {
setRefreshing(false)
}

useFocusEffect(
useCallback(() => {
onRefresh()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
)

useEffect(() => {
fetchAnnouncements().then()
showLoadingModal()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

Expand Down
2 changes: 1 addition & 1 deletion app/community/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react'
function _layout() {
return (
<Stack screenOptions={{ headerShown: false }}>
<Stack.Screen name="list/index" />
<Stack.Screen name="index" />
<Stack.Screen name="[communityId]" />
</Stack>
)
Expand Down
File renamed without changes.
14 changes: 10 additions & 4 deletions app/events/(tabs)/archived.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '~/components/ui/card'
import { ClockIcon, MapPinIcon } from 'lucide-react-native'
import { useColorScheme } from '~/lib/useColorScheme'
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { functions } from '~/lib/appwrite-client'
import { Events } from '~/lib/types/collections'
import { H1, H3, Muted } from '~/components/ui/typography'
Expand All @@ -24,6 +24,7 @@ import {
} from '~/components/calculateTimeLeft'
import { Link } from 'expo-router'
import { useAlertModal } from '~/components/contexts/AlertModalProvider'
import { useFocusEffect } from '@react-navigation/core'

export default function ArchivedEventsPage() {
const { isDarkColorScheme } = useColorScheme()
Expand Down Expand Up @@ -59,13 +60,18 @@ export default function ArchivedEventsPage() {

const onRefresh = () => {
setRefreshing(true)
showLoadingModal()
fetchEvents().then()
}

useFocusEffect(
useCallback(() => {
onRefresh()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
)

useEffect(() => {
showLoadingModal()
fetchEvents().then()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

Expand All @@ -79,7 +85,7 @@ export default function ArchivedEventsPage() {
<View className={'flex-1 justify-center items-center'}>
<View className={'p-4 native:pb-24 max-w-md gap-6'}>
<View className={'gap-1'}>
<H1 className={'text-foreground text-center'}>Events</H1>
<H1 className={'text-foreground text-center'}>Archived</H1>
<Muted className={'text-base text-center'}>
No events available
</Muted>
Expand Down
14 changes: 10 additions & 4 deletions app/events/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '~/components/ui/card'
import { ClockIcon, MapPinIcon } from 'lucide-react-native'
import { useColorScheme } from '~/lib/useColorScheme'
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { functions } from '~/lib/appwrite-client'
import { Events } from '~/lib/types/collections'
import { H1, H3, Muted } from '~/components/ui/typography'
Expand All @@ -24,6 +24,7 @@ import {
} from '~/components/calculateTimeLeft'
import { Link } from 'expo-router'
import { useAlertModal } from '~/components/contexts/AlertModalProvider'
import { useFocusEffect } from '@react-navigation/core'

export default function EventsPage() {
const { isDarkColorScheme } = useColorScheme()
Expand Down Expand Up @@ -59,13 +60,18 @@ export default function EventsPage() {

const onRefresh = () => {
setRefreshing(true)
showLoadingModal()
fetchEvents().then()
}

useFocusEffect(
useCallback(() => {
onRefresh()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
)

useEffect(() => {
showLoadingModal()
fetchEvents().then()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

Expand All @@ -79,7 +85,7 @@ export default function EventsPage() {
<View className={'flex-1 justify-center items-center'}>
<View className={'p-4 native:pb-24 max-w-md gap-6'}>
<View className={'gap-1'}>
<H1 className={'text-foreground text-center'}>Events</H1>
<H1 className={'text-foreground text-center'}>Active</H1>
<Muted className={'text-base text-center'}>
No events available
</Muted>
Expand Down
15 changes: 11 additions & 4 deletions app/events/(tabs)/upcoming.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '~/components/ui/card'
import { ClockIcon, MapPinIcon } from 'lucide-react-native'
import { useColorScheme } from '~/lib/useColorScheme'
import { useEffect, useState } from 'react'
import { useCallback, useEffect, useState } from 'react'
import { functions } from '~/lib/appwrite-client'
import { Events } from '~/lib/types/collections'
import { H1, H3, Muted } from '~/components/ui/typography'
Expand All @@ -24,6 +24,7 @@ import {
} from '~/components/calculateTimeLeft'
import { Link } from 'expo-router'
import { useAlertModal } from '~/components/contexts/AlertModalProvider'
import { useFocusEffect } from '@react-navigation/core'

export default function EventsPage() {
const { isDarkColorScheme } = useColorScheme()
Expand All @@ -33,7 +34,6 @@ export default function EventsPage() {
const { showLoadingModal, hideLoadingModal, showAlertModal } = useAlertModal()

const fetchEvents = async () => {
showLoadingModal()
try {
const data = await functions.createExecution(
'event-endpoints',
Expand Down Expand Up @@ -63,8 +63,15 @@ export default function EventsPage() {
fetchEvents().then()
}

useFocusEffect(
useCallback(() => {
onRefresh()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
)

useEffect(() => {
fetchEvents().then()
showLoadingModal()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

Expand All @@ -78,7 +85,7 @@ export default function EventsPage() {
<View className={'flex-1 justify-center items-center'}>
<View className={'p-4 native:pb-24 max-w-md gap-6'}>
<View className={'gap-1'}>
<H1 className={'text-foreground text-center'}>Events</H1>
<H1 className={'text-foreground text-center'}>Upcoming</H1>
<Muted className={'text-base text-center'}>
No upcoming events
</Muted>
Expand Down
5 changes: 3 additions & 2 deletions app/gallery/(stacks)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export default function GalleryPage() {
refreshing={refreshing}
numColumns={maxColumns}
contentContainerStyle={{ flexGrow: 1 }}
onEndReached={loadMore}
onEndReachedThreshold={0.5}
// TODO: Implement this in the future
//onEndReached={loadMore}
//onEndReachedThreshold={0.5}
ListFooterComponent={
loadingMore && (
<View
Expand Down
Loading

0 comments on commit 74f67c3

Please sign in to comment.