summaryrefslogtreecommitdiff
path: root/src/components/SmartClipboardButton.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/SmartClipboardButton.tsx')
-rw-r--r--src/components/SmartClipboardButton.tsx44
1 files changed, 33 insertions, 11 deletions
diff --git a/src/components/SmartClipboardButton.tsx b/src/components/SmartClipboardButton.tsx
index 098b53d..7be3b2f 100644
--- a/src/components/SmartClipboardButton.tsx
+++ b/src/components/SmartClipboardButton.tsx
@@ -1,12 +1,24 @@
-import { useState } from "react";
+import { useState, useEffect } from "react";
import { PanelSectionRow, ButtonItem } from "@decky/ui";
-import { FaClipboard } from "react-icons/fa";
+import { FaClipboard, FaCheck } from "react-icons/fa";
import { getLaunchOption } from "../api/lsfgApi";
-import { showClipboardSuccessToast, showClipboardErrorToast, showSuccessToast } from "../utils/toastUtils";
+import { showClipboardErrorToast } from "../utils/toastUtils";
import { copyWithVerification } from "../utils/clipboardUtils";
export function SmartClipboardButton() {
const [isLoading, setIsLoading] = useState(false);
+ const [showSuccess, setShowSuccess] = useState(false);
+
+ // Reset success state after 3 seconds
+ useEffect(() => {
+ if (showSuccess) {
+ const timer = setTimeout(() => {
+ setShowSuccess(false);
+ }, 3000);
+ return () => clearTimeout(timer);
+ }
+ return undefined;
+ }, [showSuccess]);
const getLaunchOptionText = async (): Promise<string> => {
try {
@@ -18,7 +30,7 @@ export function SmartClipboardButton() {
};
const copyToClipboard = async () => {
- if (isLoading) return;
+ if (isLoading || showSuccess) return;
setIsLoading(true);
try {
@@ -26,10 +38,11 @@ export function SmartClipboardButton() {
const { success, verified } = await copyWithVerification(text);
if (success) {
- if (verified) {
- showClipboardSuccessToast();
- } else {
- showSuccessToast("Copied to Clipboard!", "Launch option copied (verification unavailable)");
+ // Show success feedback in the button instead of toast
+ setShowSuccess(true);
+ if (!verified) {
+ // Copy worked but verification failed - still show success
+ console.log('Copy verification failed but copy likely worked');
}
} else {
showClipboardErrorToast();
@@ -47,10 +60,14 @@ export function SmartClipboardButton() {
<ButtonItem
layout="below"
onClick={copyToClipboard}
- disabled={isLoading}
+ disabled={isLoading || showSuccess}
>
<div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
- {isLoading ? (
+ {showSuccess ? (
+ <FaCheck style={{
+ color: "#4CAF50" // Green color for success
+ }} />
+ ) : isLoading ? (
<FaClipboard style={{
animation: "pulse 1s ease-in-out infinite",
opacity: 0.7
@@ -58,7 +75,12 @@ export function SmartClipboardButton() {
) : (
<FaClipboard />
)}
- <div>{isLoading ? "Copying..." : "Copy Launch Option"}</div>
+ <div style={{
+ color: showSuccess ? "#4CAF50" : "inherit",
+ fontWeight: showSuccess ? "bold" : "normal"
+ }}>
+ {showSuccess ? "Copied to clipboard" : isLoading ? "Copying..." : "Copy Launch Option"}
+ </div>
</div>
</ButtonItem>
<style>{`