Commit cf421a9f authored by Robert Knight's avatar Robert Knight

Fix typing errors with AnnotationQuote

These errors were revealed by improving the types for `withServices`.
Where this component is used in `AnnotationQuote` the code has been
refactored to avoid calling the `quote` function twice and more
obviously handle the case where `quote` returns null.
parent 78f6617f
......@@ -76,7 +76,7 @@ function Annotation({
const draft = annotation && store.getDraft(annotation);
const hasQuote = annotation && !!quote(annotation);
const annotationQuote = annotation ? quote(annotation) : null;
const isFocused = annotation && store.isAnnotationFocused(annotation.$tag);
const isSaving = annotation && store.isSavingAnnotation(annotation);
const isEditing = annotation && !!draft && !isSaving;
......@@ -104,9 +104,9 @@ function Annotation({
threadIsCollapsed={threadIsCollapsed}
/>
{hasQuote && (
{annotationQuote && (
<AnnotationQuote
quote={quote(annotation)}
quote={annotationQuote}
isFocused={isFocused}
isOrphan={isOrphan(annotation)}
/>
......
......@@ -15,15 +15,15 @@ import StyledText from '../StyledText';
* @prop {string} quote
* @prop {boolean} [isFocused]
* @prop {boolean} [isOrphan]
* @prop {SidebarSettings} [settings] - Used for theming.
* @prop {SidebarSettings} settings
*/
/**
* Display the selected text from the document associated with an annotation.
*
* @parm {AnnotationQuoteProps} props
* @param {AnnotationQuoteProps} props
*/
function AnnotationQuote({ quote, isFocused, isOrphan, settings = {} }) {
function AnnotationQuote({ quote, isFocused, isOrphan, settings }) {
return (
<Excerpt collapsedHeight={35} inlineControls={true} overflowThreshold={20}>
<StyledText classes={classnames({ 'p-redacted-text': isOrphan })}>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment