mirror of
https://github.com/aliasvault/aliasvault.git
synced 2026-04-04 14:54:11 -04:00
Update ClipboardUtility.ts (#1157)
This commit is contained in:
committed by
Leendert de Borst
parent
fe7da551a4
commit
2c98b81111
@@ -2,13 +2,12 @@ import NativeVaultManager from '@/specs/NativeVaultManager';
|
||||
|
||||
/**
|
||||
* Copy text to clipboard with automatic expiration based on platform capabilities.
|
||||
*
|
||||
*
|
||||
* On iOS: Uses native clipboard expiration via UIPasteboard.setItems with expirationDate.
|
||||
* On Android: Uses native method that combines clipboard copy with automatic clearing:
|
||||
* - For delays ≤10 seconds: Uses Handler (reliable for short delays)
|
||||
* - For delays >10 seconds: Uses AlarmManager (works even when app is backgrounded)
|
||||
* - Uses AlarmManager (works even when app is backgrounded)
|
||||
* - Android 13+: Also marks clipboard content as sensitive
|
||||
*
|
||||
*
|
||||
* @param text - The text to copy to clipboard
|
||||
* @param expirationSeconds - Number of seconds after which clipboard should be cleared (0 = no expiration)
|
||||
*/
|
||||
@@ -22,9 +21,9 @@ export async function copyToClipboardWithExpiration(
|
||||
|
||||
/**
|
||||
* Copy text to clipboard without expiration.
|
||||
*
|
||||
*
|
||||
* @param text - The text to copy to clipboard
|
||||
*/
|
||||
export async function copyToClipboard(text: string): Promise<void> {
|
||||
await copyToClipboardWithExpiration(text, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user