mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-04 13:08:33 +01:00
fix(settings): lazy-load clipboard so the Account screen opens without a native rebuild
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import * as Application from "expo-application";
|
||||
import { setStringAsync } from "expo-clipboard";
|
||||
import { t } from "i18next";
|
||||
import { useAtom } from "jotai";
|
||||
import { useState } from "react";
|
||||
@@ -18,6 +17,21 @@ export default function AccountPage() {
|
||||
const token = api?.accessToken ?? "";
|
||||
const masked = token ? `•••• •••• •••• ${token.slice(-4)}` : "";
|
||||
|
||||
const copyToken = async () => {
|
||||
if (!token) return;
|
||||
try {
|
||||
// Lazy import: expo-clipboard is a native module. Importing it at module
|
||||
// top crashes the screen on a dev client built before it was added; the
|
||||
// dynamic import defers loading until the user taps copy.
|
||||
const Clipboard = await import("expo-clipboard");
|
||||
await Clipboard.setStringAsync(token);
|
||||
success();
|
||||
Alert.alert(t("home.settings.account.copied"));
|
||||
} catch {
|
||||
Alert.alert(t("home.settings.account.copy_unavailable"));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<ScrollView contentContainerStyle={{ padding: 16 }}>
|
||||
<ListGroup title={t("home.settings.user_info.user_info_title")}>
|
||||
@@ -37,12 +51,7 @@ export default function AccountPage() {
|
||||
<ListItem
|
||||
title={t("home.settings.account.copy_token")}
|
||||
textColor='blue'
|
||||
onPress={async () => {
|
||||
if (!token) return;
|
||||
await setStringAsync(token);
|
||||
success();
|
||||
Alert.alert(t("home.settings.account.copied"));
|
||||
}}
|
||||
onPress={copyToken}
|
||||
/>
|
||||
<ListItem
|
||||
title={t("home.settings.user_info.app_version")}
|
||||
|
||||
Reference in New Issue
Block a user