|
| 1 | +import { useEffect, useState } from 'react' |
1 | 2 | import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' |
2 | 3 | import { Button } from '@/components/ui/button' |
3 | 4 | import { HelpCircle, ExternalLink, FileText, Github, BookOpen, MessageCircle, Download } from 'lucide-react' |
4 | 5 |
|
5 | 6 | export function HelpPage() { |
| 7 | + const [canCheckForUpdates, setCanCheckForUpdates] = useState(false) |
| 8 | + |
| 9 | + useEffect(() => { |
| 10 | + let active = true |
| 11 | + |
| 12 | + const loadUpdateCapabilities = async () => { |
| 13 | + try { |
| 14 | + const capabilities = await window.electron?.update?.getCapabilities?.() |
| 15 | + if (active) { |
| 16 | + setCanCheckForUpdates(capabilities?.canCheckForUpdates ?? false) |
| 17 | + } |
| 18 | + } catch { |
| 19 | + if (active) { |
| 20 | + setCanCheckForUpdates(false) |
| 21 | + } |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + void loadUpdateCapabilities() |
| 26 | + |
| 27 | + return () => { |
| 28 | + active = false |
| 29 | + } |
| 30 | + }, []) |
| 31 | + |
6 | 32 | const openExternal = (url: string) => { |
7 | 33 | window.electron?.shell?.openExternal?.(url) |
8 | 34 | } |
@@ -44,28 +70,29 @@ export function HelpPage() { |
44 | 70 | </CardContent> |
45 | 71 | </Card> |
46 | 72 |
|
47 | | - {/* Updates */} |
48 | | - <Card> |
49 | | - <CardHeader> |
50 | | - <CardTitle className="flex items-center gap-2"> |
51 | | - <Download className="size-5" /> |
52 | | - Updates |
53 | | - </CardTitle> |
54 | | - <CardDescription> |
55 | | - Keep your app up to date with the latest features and fixes |
56 | | - </CardDescription> |
57 | | - </CardHeader> |
58 | | - <CardContent className="space-y-2"> |
59 | | - <Button |
60 | | - variant="outline" |
61 | | - className="w-full justify-start" |
62 | | - onClick={checkForUpdates} |
63 | | - > |
64 | | - <Download className="size-4 mr-2" /> |
65 | | - Check for Updates |
66 | | - </Button> |
67 | | - </CardContent> |
68 | | - </Card> |
| 73 | + {canCheckForUpdates && ( |
| 74 | + <Card> |
| 75 | + <CardHeader> |
| 76 | + <CardTitle className="flex items-center gap-2"> |
| 77 | + <Download className="size-5" /> |
| 78 | + Updates |
| 79 | + </CardTitle> |
| 80 | + <CardDescription> |
| 81 | + Keep your app up to date with the latest features and fixes |
| 82 | + </CardDescription> |
| 83 | + </CardHeader> |
| 84 | + <CardContent className="space-y-2"> |
| 85 | + <Button |
| 86 | + variant="outline" |
| 87 | + className="w-full justify-start" |
| 88 | + onClick={checkForUpdates} |
| 89 | + > |
| 90 | + <Download className="size-4 mr-2" /> |
| 91 | + Check for Updates |
| 92 | + </Button> |
| 93 | + </CardContent> |
| 94 | + </Card> |
| 95 | + )} |
69 | 96 |
|
70 | 97 | {/* Get Help */} |
71 | 98 | <Card> |
|
0 commit comments