Skip to content

Commit

Permalink
fix redeem link
Browse files Browse the repository at this point in the history
  • Loading branch information
dohsimpson committed Jan 27, 2025
1 parent b62cf77 commit 7065d56
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Version 0.1.29

### Fixed

- actually working redeem link for wishlist items (#52)

## Version 0.1.28

### Added
Expand Down
15 changes: 15 additions & 0 deletions components/WishlistManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import WishlistItem from './WishlistItem'
import AddEditWishlistItemModal from './AddEditWishlistItemModal'
import ConfirmDialog from './ConfirmDialog'
import { WishlistItemType } from '@/lib/types'
import { openWindow } from '@/lib/utils'
import { toast } from '@/hooks/use-toast'

export default function WishlistManager() {
const {
Expand Down Expand Up @@ -62,6 +64,19 @@ export default function WishlistManager() {
setTimeout(() => {
setRecentlyRedeemedId(null)
}, 3000)

if (item.link) {
setTimeout(() => {
const opened = openWindow(item.link!)
if (!opened) {
toast({
title: "Popup Blocked",
description: "Please allow popups to open the link",
variant: "destructive"
})
}
}, 300)
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,4 +286,14 @@ export const playSound = (soundPath: string = '/sounds/timer-end.wav') => {
audio.play().catch(error => {
console.error('Error playing sound:', error)
})
}

// open a new window (client side only, must be run in browser)
export const openWindow = (url: string): boolean => {
const newWindow = window.open(url, '_blank')
if (newWindow === null) {
// Popup was blocked
return false
}
return true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "habittrove",
"version": "0.1.28",
"version": "0.1.29",
"private": true,
"scripts": {
"dev": "next dev --turbopack",
Expand Down

0 comments on commit 7065d56

Please sign in to comment.