forked from akai/readest
fix(annotator): fix instant action on Android (#3042)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
||||
import React, { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
||||
import { RiDeleteBinLine } from 'react-icons/ri';
|
||||
|
||||
import * as CFI from 'foliate-js/epubcfi.js';
|
||||
@@ -89,6 +89,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
|
||||
const [selectedColor, setSelectedColor] = useState<HighlightColor>(
|
||||
settings.globalReadSettings.highlightStyles[selectedStyle],
|
||||
);
|
||||
const androidTouchEndRef = useRef(false);
|
||||
|
||||
const showingPopup =
|
||||
showAnnotPopup ||
|
||||
@@ -239,8 +240,10 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
|
||||
const handleNativeTouch = (event: CustomEvent) => {
|
||||
const ev = event.detail as NativeTouchEventType;
|
||||
if (ev.type === 'touchstart') {
|
||||
androidTouchEndRef.current = false;
|
||||
handleTouchStart();
|
||||
} else if (ev.type === 'touchend') {
|
||||
androidTouchEndRef.current = true;
|
||||
handleTouchEnd();
|
||||
handlePointerUp(doc, index);
|
||||
}
|
||||
@@ -414,6 +417,7 @@ const Annotator: React.FC<{ bookKey: string }> = ({ bookKey }) => {
|
||||
|
||||
const handleQuickAction = () => {
|
||||
const action = viewSettings.annotationQuickAction;
|
||||
if (appService?.isAndroidApp && !androidTouchEndRef.current) return;
|
||||
switch (action) {
|
||||
case 'copy':
|
||||
handleCopy(false);
|
||||
|
||||
@@ -27,7 +27,11 @@ const QuickActionMenu: React.FC<QuickActionMenuProps> = ({
|
||||
eventDispatcher.dispatch('toast', {
|
||||
type: 'info',
|
||||
timeout: 2000,
|
||||
message: _('Quick action disabled'),
|
||||
message: _('Instant {{action}} Disabled', {
|
||||
action: _(
|
||||
annotationToolQuickActions.find((btn) => btn.type === action)?.label || _('Annotation'),
|
||||
),
|
||||
}),
|
||||
});
|
||||
} else {
|
||||
eventDispatcher.dispatch('toast', {
|
||||
@@ -53,7 +57,7 @@ const QuickActionMenu: React.FC<QuickActionMenuProps> = ({
|
||||
{annotationToolQuickActions.map((button) => (
|
||||
<MenuItem
|
||||
key={button.type}
|
||||
label={_(button.label)}
|
||||
label={_('Instant {{action}}', { action: _(button.label) })}
|
||||
tooltip={_(button.tooltip)}
|
||||
buttonClass={selectedAction === button.type ? 'bg-base-300/85' : ''}
|
||||
Icon={button.Icon}
|
||||
|
||||
Reference in New Issue
Block a user