Skip to content

Commit

Permalink
massively improve UX of clicking around annotations on a page
Browse files Browse the repository at this point in the history
- insta close the annotation editor and open for the next note
  • Loading branch information
blackforestboi committed Jul 26, 2024
1 parent f3ed1f8 commit f7bbfe8
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
1 change: 1 addition & 0 deletions src/content-scripts/content_script/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ export async function main(
getState: tooltipUtils.getTooltipState,
setState: tooltipUtils.setTooltipState,
},
shouldInitTooltip: areHighlightsEnabled,
})

// 9. Check for page activity status
Expand Down
19 changes: 17 additions & 2 deletions src/in-page-ui/tooltip/content_script/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,23 @@ class TooltipRoot extends React.Component<TooltipRootProps, TooltipRootState> {
saveAnnotation = async (
commentState: string,
color?: HighlightColor['id'],
unifiedId?: string,
dontUpdateState?: boolean,
) => {
const currentAnnotation = this.state.currentAnnotation
let currentAnnotation = undefined
let comment = commentState

if (unifiedId) {
currentAnnotation = this.props.annotationsCache.annotations.byId[
unifiedId
]
} else {
currentAnnotation = this.state.currentAnnotation
}

const existingHighlight = this.props.annotationsCache.annotations.byId[
currentAnnotation.unifiedId
]
const comment = commentState

this.props.annotationsCache.updateAnnotation(
{
Expand Down Expand Up @@ -413,6 +424,10 @@ class TooltipRoot extends React.Component<TooltipRootProps, TooltipRootState> {
} catch (err) {
console.log(err)
}

if (dontUpdateState) {
return
}
this.setState({
currentAnnotation: {
...currentAnnotation,
Expand Down

0 comments on commit f7bbfe8

Please sign in to comment.