Skip to content

Commit 4ff27e4

Browse files
committed
Restore highlightRemoved
1 parent c2f73b7 commit 4ff27e4

File tree

1 file changed

+10
-2
lines changed
  • src/app/content/highlights/components

1 file changed

+10
-2
lines changed

src/app/content/highlights/components/Card.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,25 @@ function useLocationFilterId(page: CardProps['page']): string | undefined {
145145

146146
function Card(props: CardProps) {
147147
const locationFilterId = useLocationFilterId(props.page);
148+
const [highlightRemoved, setHighlightRemoved] = React.useState<boolean>(
149+
false
150+
);
148151
const computedProps = useComputedProps(props);
149152

150153
if (
151154
!props.highlight.range ||
152155
!props.page ||
153156
!props.book ||
154-
!locationFilterId
157+
!locationFilterId ||
158+
highlightRemoved
155159
) {
156160
return null;
157161
}
158162

159163
return (
160164
<NoteOrCard
161165
props={props as CardPropsWithBookAndPage}
166+
setHighlightRemoved={setHighlightRemoved}
162167
locationFilterId={locationFilterId}
163168
computedProps={computedProps}
164169
/>
@@ -167,10 +172,12 @@ function Card(props: CardProps) {
167172

168173
function NoteOrCard({
169174
props,
175+
setHighlightRemoved,
170176
locationFilterId,
171177
computedProps,
172178
}: {
173179
props: CardPropsWithBookAndPage;
180+
setHighlightRemoved: React.Dispatch<React.SetStateAction<boolean>>;
174181
locationFilterId: string;
175182
computedProps: ReturnType<typeof useComputedProps>;
176183
}) {
@@ -185,6 +192,7 @@ function NoteOrCard({
185192
const showToast = useConfirmationToastContext();
186193
const onRemove = React.useCallback(() => {
187194
if (props.data) {
195+
setHighlightRemoved(true);
188196
props.remove(props.data, {
189197
locationFilterId,
190198
pageId: props.page.id,
@@ -193,7 +201,7 @@ function NoteOrCard({
193201
message: 'Highlight removed',
194202
});
195203
}
196-
}, [locationFilterId, props, showToast]);
204+
}, [locationFilterId, props, showToast, setHighlightRemoved]);
197205
const style = highlightStyles.find(
198206
search => props.data && search.label === props.data.color
199207
);

0 commit comments

Comments
 (0)