Skip to content

Commit 7065d56

Browse files
committed
fix redeem link
1 parent b62cf77 commit 7065d56

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 0.1.29
4+
5+
### Fixed
6+
7+
- actually working redeem link for wishlist items (#52)
8+
39
## Version 0.1.28
410

511
### Added

components/WishlistManager.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import WishlistItem from './WishlistItem'
99
import AddEditWishlistItemModal from './AddEditWishlistItemModal'
1010
import ConfirmDialog from './ConfirmDialog'
1111
import { WishlistItemType } from '@/lib/types'
12+
import { openWindow } from '@/lib/utils'
13+
import { toast } from '@/hooks/use-toast'
1214

1315
export default function WishlistManager() {
1416
const {
@@ -62,6 +64,19 @@ export default function WishlistManager() {
6264
setTimeout(() => {
6365
setRecentlyRedeemedId(null)
6466
}, 3000)
67+
68+
if (item.link) {
69+
setTimeout(() => {
70+
const opened = openWindow(item.link!)
71+
if (!opened) {
72+
toast({
73+
title: "Popup Blocked",
74+
description: "Please allow popups to open the link",
75+
variant: "destructive"
76+
})
77+
}
78+
}, 300)
79+
}
6580
}
6681
}
6782

lib/utils.ts

+10
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,14 @@ export const playSound = (soundPath: string = '/sounds/timer-end.wav') => {
286286
audio.play().catch(error => {
287287
console.error('Error playing sound:', error)
288288
})
289+
}
290+
291+
// open a new window (client side only, must be run in browser)
292+
export const openWindow = (url: string): boolean => {
293+
const newWindow = window.open(url, '_blank')
294+
if (newWindow === null) {
295+
// Popup was blocked
296+
return false
297+
}
298+
return true
289299
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "habittrove",
3-
"version": "0.1.28",
3+
"version": "0.1.29",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbopack",

0 commit comments

Comments
 (0)