1111
1212import * as Clipboard from 'expo-clipboard' ;
1313import { AppState , Platform } from 'react-native' ;
14- import { useSettingsStore } from '@/stores/settingsStore ' ;
14+ import { configService } from '@/services/ConfigService ' ;
1515import { setTimer , clearTimer } from 'native-timer' ;
1616import { nativeSaveClipboardImageToFile } from 'native-util' ;
1717
@@ -104,7 +104,7 @@ export async function dismissOverlay(): Promise<void> {
104104async function shouldUseOverlay ( ) : Promise < boolean > {
105105 if ( Platform . OS !== 'android' || ! overlayModule ) return false ;
106106 if ( AppState . currentState !== 'background' ) return false ;
107- const config = useSettingsStore . getState ( ) . config ;
107+ const config = await configService . getConfig ( ) ;
108108 if ( ! ( config ?. enableClipboardOverlay ?? false ) ) return false ;
109109 // Sync overlay visibility and retry count to native module
110110 const isDebug = config ?. debugMode ?? false ;
@@ -124,10 +124,10 @@ async function shouldUseOverlay(): Promise<boolean> {
124124 * 条件:Android + 后台 + 设置启用 + Shizuku 可用且有权限
125125 * Shizuku 优先级高于悬浮窗
126126 */
127- function shouldUseShizuku ( ) : boolean {
127+ async function shouldUseShizuku ( ) : Promise < boolean > {
128128 if ( Platform . OS !== 'android' || ! shizukuModule ) return false ;
129129 if ( AppState . currentState !== 'background' ) return false ;
130- const config = useSettingsStore . getState ( ) . config ;
130+ const config = await configService . getConfig ( ) ;
131131 if ( ! ( config ?. enableShizukuClipboard ?? false ) ) return false ;
132132 if ( ! shizukuModule . isShizukuAvailable ( ) ) return false ;
133133 if ( ! shizukuModule . hasShizukuPermission ( ) ) return false ;
@@ -138,7 +138,7 @@ function shouldUseShizuku(): boolean {
138138 * 获取剪贴板文本
139139 */
140140export async function getStringAsync ( options ?: Clipboard . GetStringOptions ) : Promise < string > {
141- if ( shouldUseShizuku ( ) ) {
141+ if ( await shouldUseShizuku ( ) ) {
142142 try {
143143 const result = await shizukuModule ! . getStringViaShizuku ( ) ;
144144 return result ;
@@ -170,7 +170,7 @@ export async function setStringAsync(
170170 * 检查剪贴板是否有文本
171171 */
172172export async function hasStringAsync ( ) : Promise < boolean > {
173- if ( shouldUseShizuku ( ) ) {
173+ if ( await shouldUseShizuku ( ) ) {
174174 try {
175175 return await shizukuModule ! . hasStringViaShizuku ( ) ;
176176 } catch ( e ) {
@@ -191,7 +191,7 @@ export async function hasStringAsync(): Promise<boolean> {
191191 * 检查剪贴板是否有图片
192192 */
193193export async function hasImageAsync ( ) : Promise < boolean > {
194- if ( shouldUseShizuku ( ) ) {
194+ if ( await shouldUseShizuku ( ) ) {
195195 try {
196196 return await shizukuModule ! . hasImageViaShizuku ( ) ;
197197 } catch ( e ) {
0 commit comments