|
1 | 1 | import { ArrowLeft, DotsThree, Plus } from "@phosphor-icons/react"; |
2 | | -import { useEffect, useState } from "react"; |
| 2 | +import { type MouseEvent, useEffect, useState } from "react"; |
3 | 3 | import { Controller, useForm } from "react-hook-form"; |
4 | 4 | import { useNavigate } from "react-router-dom"; |
5 | 5 | import { z } from "zod/v4"; |
6 | 6 | import { |
7 | 7 | type CompletionCheck, |
8 | 8 | getTelegramChats, |
| 9 | + openExternalUrl, |
9 | 10 | revealHooksFile, |
10 | 11 | type LoopNotification, |
11 | 12 | type TelegramChatOption, |
@@ -194,6 +195,15 @@ function inferTelegramChatKind(chatId: string): TelegramChatOption["kind"] { |
194 | 195 | return chatId.trim().startsWith("-") ? "group" : "dm"; |
195 | 196 | } |
196 | 197 |
|
| 198 | +async function handleExternalLinkClick(event: MouseEvent<HTMLAnchorElement>, url: string) { |
| 199 | + event.preventDefault(); |
| 200 | + |
| 201 | + const opened = await openExternalUrl(url); |
| 202 | + if (!opened) { |
| 203 | + window.open(url, "_blank", "noopener,noreferrer"); |
| 204 | + } |
| 205 | +} |
| 206 | + |
197 | 207 | function parseCommandsText(commandsText: string) { |
198 | 208 | return commandsText |
199 | 209 | .split(/\r?\n/) |
@@ -662,7 +672,13 @@ export function SettingsRoute() { |
662 | 672 | <FieldDescription> |
663 | 673 | <a |
664 | 674 | className="text-blue-400 transition-colors hover:text-blue-300" |
665 | | - href="https://t.me/BotFather" |
| 675 | + href="https://github.com/lnikell/loopndroll?tab=readme-ov-file#telegram-setup" |
| 676 | + onClick={(event) => { |
| 677 | + void handleExternalLinkClick( |
| 678 | + event, |
| 679 | + "https://github.com/lnikell/loopndroll?tab=readme-ov-file#telegram-setup", |
| 680 | + ); |
| 681 | + }} |
666 | 682 | rel="noreferrer" |
667 | 683 | target="_blank" |
668 | 684 | > |
@@ -963,6 +979,12 @@ export function SettingsRoute() { |
963 | 979 | <a |
964 | 980 | className="text-blue-400 transition-colors hover:text-blue-300" |
965 | 981 | href="https://github.com/lnikell/loopndroll?tab=readme-ov-file#telegram-commands" |
| 982 | + onClick={(event) => { |
| 983 | + void handleExternalLinkClick( |
| 984 | + event, |
| 985 | + "https://github.com/lnikell/loopndroll?tab=readme-ov-file#telegram-commands", |
| 986 | + ); |
| 987 | + }} |
966 | 988 | rel="noreferrer" |
967 | 989 | target="_blank" |
968 | 990 | > |
@@ -1061,6 +1083,12 @@ export function SettingsRoute() { |
1061 | 1083 | <a |
1062 | 1084 | className="text-blue-400 transition-colors hover:text-blue-300" |
1063 | 1085 | href="https://github.com/lnikell/loopndroll?tab=readme-ov-file#4-completion-checks" |
| 1086 | + onClick={(event) => { |
| 1087 | + void handleExternalLinkClick( |
| 1088 | + event, |
| 1089 | + "https://github.com/lnikell/loopndroll?tab=readme-ov-file#4-completion-checks", |
| 1090 | + ); |
| 1091 | + }} |
1064 | 1092 | rel="noreferrer" |
1065 | 1093 | target="_blank" |
1066 | 1094 | > |
|
0 commit comments