diff --git a/src/def.d.ts b/src/def.d.ts index 3b068b9..d8b22b3 100644 --- a/src/def.d.ts +++ b/src/def.d.ts @@ -369,7 +369,6 @@ interface VendettaObject { HTTP_REGEX: RegExp; }; utils: { - copyText: (content: string) => void; findInReactTree: (tree: SearchTree, filter: SearchFilter) => any; findInTree: (tree: SearchTree, filter: SearchFilter, options: FindInTreeOptions) => any; safeFetch: (input: RequestInfo, options: RequestInit) => Promise; diff --git a/src/lib/utils/copyText.ts b/src/lib/utils/copyText.ts deleted file mode 100644 index 7454477..0000000 --- a/src/lib/utils/copyText.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { clipboard } from "@metro/common"; - -// TODO: Remove/deprecate this, the clipboard module works the same way. - -export default function copyText(content: string) { - try { - clipboard.setString(content); - } catch (e) { - throw new Error("Failed to set clipboard content."); - } -} \ No newline at end of file diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index abb4ad9..6584f68 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -1,5 +1,4 @@ // Makes mass-importing utils cleaner, chosen over moving utils to one file -export { default as copyText } from "@utils/copyText"; export { default as findInReactTree } from "@utils/findInReactTree"; export { default as findInTree } from "@utils/findInTree"; export { default as safeFetch } from "@utils/safeFetch"; diff --git a/src/ui/settings/components/AssetDisplay.tsx b/src/ui/settings/components/AssetDisplay.tsx index d2c0291..31f058e 100644 --- a/src/ui/settings/components/AssetDisplay.tsx +++ b/src/ui/settings/components/AssetDisplay.tsx @@ -1,9 +1,8 @@ import { Asset } from "@types"; -import { ReactNative as RN, stylesheet } from "@metro/common"; +import { ReactNative as RN, stylesheet, clipboard } from "@metro/common"; import { showToast } from "@ui/toasts"; import { getAssetIDByName } from "@ui/assets"; import { Forms } from "@ui/components"; -import copyText from "@lib/utils/copyText"; interface AssetDisplayProps { asset: Asset; @@ -24,7 +23,7 @@ export default function AssetDisplay({ asset }: AssetDisplayProps) { label={`${asset.name} - ${asset.id}`} trailing={} onPress={() => { - copyText(asset.name); + clipboard.setString(asset.name); showToast("Copied asset name to clipboard.", getAssetIDByName("toast_copy_link")); }} /> diff --git a/src/ui/settings/components/InstallButton.tsx b/src/ui/settings/components/InstallButton.tsx index 62d2ce4..3cadc73 100644 --- a/src/ui/settings/components/InstallButton.tsx +++ b/src/ui/settings/components/InstallButton.tsx @@ -1,4 +1,4 @@ -import { ReactNative as RN, clipboard, stylesheet } from "@metro/common"; +import { ReactNative as RN, stylesheet, clipboard } from "@metro/common"; import { HTTP_REGEX } from "@lib/constants"; import { showInputAlert } from "@ui/alerts"; import { getAssetIDByName } from "@ui/assets"; diff --git a/src/ui/settings/components/Version.tsx b/src/ui/settings/components/Version.tsx index 363c9b1..033accf 100644 --- a/src/ui/settings/components/Version.tsx +++ b/src/ui/settings/components/Version.tsx @@ -1,7 +1,7 @@ +import { clipboard } from "@metro/common"; import { getAssetIDByName } from "@ui/assets"; import { showToast } from "@ui/toasts"; import { Forms } from "@ui/components"; -import copyText from "@utils/copyText"; interface VersionProps { label: string; @@ -18,7 +18,7 @@ export default function Version({ label, version, icon }: VersionProps) { leading={} trailing={{version}} onPress={() => { - copyText(`${label} - ${version}`); + clipboard.setString(`${label} - ${version}`); showToast("Copied version to clipboard.", getAssetIDByName("toast_copy_link")); }} />