mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-21 06:34:30 +01:00
fix redeem link
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
## Version 0.1.29
|
||||
|
||||
### Fixed
|
||||
|
||||
- actually working redeem link for wishlist items (#52)
|
||||
|
||||
## Version 0.1.28
|
||||
|
||||
### Added
|
||||
|
||||
@@ -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 {
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
10
lib/utils.ts
10
lib/utils.ts
@@ -287,3 +287,13 @@ export const playSound = (soundPath: string = '/sounds/timer-end.wav') => {
|
||||
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
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "habittrove",
|
||||
"version": "0.1.28",
|
||||
"version": "0.1.29",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev --turbopack",
|
||||
|
||||
Reference in New Issue
Block a user