forked from akai/readest
fix: conditional Back key interception on Android (#1942)
This commit is contained in:
@@ -51,12 +51,6 @@ const Reader: React.FC<{ ids?: string }> = ({ ids }) => {
|
||||
setTimeout(getSysFontsList, 3000);
|
||||
}
|
||||
initDayjs(getLocale());
|
||||
|
||||
acquireBackKeyInterception();
|
||||
return () => {
|
||||
releaseBackKeyInterception();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const handleKeyDown = (event: CustomEvent) => {
|
||||
@@ -74,6 +68,15 @@ const Reader: React.FC<{ ids?: string }> = ({ ids }) => {
|
||||
return false;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!appService?.isAndroidApp) return;
|
||||
acquireBackKeyInterception();
|
||||
return () => {
|
||||
releaseBackKeyInterception();
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [appService?.isAndroidApp]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!appService?.isAndroidApp) return;
|
||||
eventDispatcher.onSync('native-key-down', handleKeyDown);
|
||||
|
||||
Reference in New Issue
Block a user