Spaces:
Running
Running
test sharing function
Browse files- components/form.tsx +8 -2
components/form.tsx
CHANGED
@@ -40,6 +40,7 @@ export const Form = ({ children }: { children: React.ReactNode }) => {
|
|
40 |
const [track, setTrack] = useState("");
|
41 |
const [shareLoading, setShareLoading] = useState(false);
|
42 |
const [blob, setBlob] = useState<Blob | null>(null);
|
|
|
43 |
|
44 |
const {
|
45 |
form,
|
@@ -226,7 +227,7 @@ export const Form = ({ children }: { children: React.ReactNode }) => {
|
|
226 |
}
|
227 |
)}
|
228 |
onClick={async () => {
|
229 |
-
if (shareLoading) return;
|
230 |
setShareLoading(true);
|
231 |
await share(
|
232 |
blob,
|
@@ -240,9 +241,14 @@ export const Form = ({ children }: { children: React.ReactNode }) => {
|
|
240 |
results
|
241 |
);
|
242 |
setShareLoading(false);
|
|
|
243 |
}}
|
244 |
>
|
245 |
-
{shareLoading
|
|
|
|
|
|
|
|
|
246 |
</button>
|
247 |
)}
|
248 |
</div>
|
|
|
40 |
const [track, setTrack] = useState("");
|
41 |
const [shareLoading, setShareLoading] = useState(false);
|
42 |
const [blob, setBlob] = useState<Blob | null>(null);
|
43 |
+
const [hasBeenShared, setHasBeenShared] = useState(false);
|
44 |
|
45 |
const {
|
46 |
form,
|
|
|
227 |
}
|
228 |
)}
|
229 |
onClick={async () => {
|
230 |
+
if (shareLoading || hasBeenShared) return;
|
231 |
setShareLoading(true);
|
232 |
await share(
|
233 |
blob,
|
|
|
241 |
results
|
242 |
);
|
243 |
setShareLoading(false);
|
244 |
+
setHasBeenShared(true);
|
245 |
}}
|
246 |
>
|
247 |
+
{shareLoading
|
248 |
+
? "Sharing..."
|
249 |
+
: hasBeenShared
|
250 |
+
? "Shared"
|
251 |
+
: "Share my song"}
|
252 |
</button>
|
253 |
)}
|
254 |
</div>
|