Skip to content

Commit

Permalink
fix banner as well
Browse files Browse the repository at this point in the history
  • Loading branch information
docimin committed May 22, 2024
1 parent 0888e79 commit 65627c0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/app/(account)/account/profile/frontpage/uploadAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'
import { useToast } from '@/components/ui/use-toast'
import { UserAvatarsDocumentType, UserDataDocumentsType } from '@/utils/types'
import { UserDataDocumentsType } from '@/utils/types'
import { databases, ID, storage } from '@/app/appwrite-client'

Check warning on line 4 in src/app/(account)/account/profile/frontpage/uploadAvatar.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier ID
import * as Sentry from '@sentry/nextjs'
import { Input } from '@/components/ui/input'
Expand Down Expand Up @@ -61,7 +61,7 @@ export default function UploadAvatar({
// If the user already has an avatar, delete it
if (avatarDocument.avatarId) {
// Delete the old avatar
const data = await storage.deleteFile('avatars', avatarDocument.avatarId).catch((error) => {
await storage.deleteFile('avatars', avatarDocument.avatarId).catch((error) => {
//console.error(error)
Sentry.captureException('Failed to delete old avatar.', error)
})
Expand Down
12 changes: 7 additions & 5 deletions src/app/(account)/account/profile/frontpage/uploadBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'
import { useToast } from '@/components/ui/use-toast'
import { UserAvatarsDocumentType } from '@/utils/types'
import { UserAvatarsDocumentType, UserDataDocumentsType } from '@/utils/types'

Check warning on line 3 in src/app/(account)/account/profile/frontpage/uploadBanner.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier UserAvatarsDocumentType
import { databases, ID, storage } from '@/app/appwrite-client'

Check warning on line 4 in src/app/(account)/account/profile/frontpage/uploadBanner.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused import specifier ID
import * as Sentry from '@sentry/nextjs'
import { Input } from '@/components/ui/input'
Expand Down Expand Up @@ -56,19 +56,21 @@ export default function UploadBanner({
setIsUploading(true) // Set isUploading to true before making the API call

// Get the user's banner document
const bannerDocument: UserAvatarsDocumentType =
const bannerDocument: UserDataDocumentsType =
await databases.getDocument('hp_db', 'userdata', userMe.$id)
// If the user already has an banner, delete it
if (bannerDocument.profileBannerId) {
// Delete the old banner
console.log('deleting')
await storage.deleteFile('banners', bannerDocument.profileBannerId)
await storage.deleteFile('banners', bannerDocument.profileBannerId).catch((error) => {
//console.error(error)
Sentry.captureException('Failed to delete old banner.', error)
})
}

// Upload the new banner
const fileData = storage.createFile(
'banners',
ID.unique(),
bannerDocument.$id,
(document.getElementById('banner-upload') as HTMLInputElement).files[0]
)

Expand Down

0 comments on commit 65627c0

Please sign in to comment.