Skip to content

Commit

Permalink
fix bug with sharing state of newly created annotation with "spaces" …
Browse files Browse the repository at this point in the history
…hotkey
  • Loading branch information
blackforestboi committed May 11, 2024
1 parent 301068a commit 4043c80
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
12 changes: 5 additions & 7 deletions src/content-scripts/content_script/global.ts
Expand Up @@ -376,7 +376,7 @@ export async function main(
'shouldAutoAddSpaces',
)

let shouldShareAnnotation
let shouldShareAnnotation = false

if (data.shouldShare && shouldShareSettings) {
// this setting is here to inverse the "shift" action of the highlight and annotation buttons
Expand All @@ -386,7 +386,9 @@ export async function main(
} else if (shouldShareSettings) {
shouldShareAnnotation = true
}

if (data.shouldShare != null && !data.shouldShare) {
shouldShareAnnotation = false
}
const localListIds: number[] = []
const remoteListIds: string[] = []
const unifiedListIds: UnifiedList['unifiedId'][] = []
Expand Down Expand Up @@ -443,8 +445,7 @@ export async function main(
remoteAnnotationId,
} = await createAnnotation({
shareOpts: {
shouldShare:
shouldShareAnnotation || remoteListIds.length > 0,
shouldShare: shouldShareAnnotation,
shouldCopyShareLink: data.shouldCopyShareLink,
},
annotationsBG,
Expand Down Expand Up @@ -605,7 +606,6 @@ export async function main(
false,
))
) {
console.log('limit reached')
sidebarEvents.emit('showPowerUpModal', {
limitReachedNotif: 'Bookmarks',
})
Expand Down Expand Up @@ -734,7 +734,6 @@ export async function main(
commentText?: string,
highlightColorSetting?: HighlightColor,
) => {
console.log('exectuted again and again')
const selectionEmpty = !selection?.toString().length
if (selectionEmpty) {
return
Expand All @@ -759,7 +758,6 @@ export async function main(
false,
))
) {
console.log('öootad')
sidebarEvents.emit('showPowerUpModal', {
limitReachedNotif: 'Bookmarks',
})
Expand Down
4 changes: 0 additions & 4 deletions src/popup/container.tsx
Expand Up @@ -47,7 +47,6 @@ import { AnnotationsSidebarInPageEventEmitter } from 'src/sidebar/annotations-si
export interface OwnProps {
analyticsBG: AnalyticsCoreInterface
getRootElement: () => HTMLElement
sidebarEvents: AnnotationsSidebarInPageEventEmitter
}

interface StateProps {
Expand Down Expand Up @@ -86,7 +85,6 @@ class PopupContainer extends StatefulUIElement<Props, State, Event> {
syncSettings: createSyncSettingsStore({
syncSettingsBG: runInBackground(),
}),
sidebarEvents: runInBackground(),
}),
)
}
Expand Down Expand Up @@ -398,8 +396,6 @@ class PopupContainer extends StatefulUIElement<Props, State, Event> {
false,
)

console.log('isAllowed', isAllowed)

if (!isAllowed) {
this.processEvent('showUpgradeNotif', true)
return false
Expand Down
4 changes: 0 additions & 4 deletions src/popup/index.tsx
Expand Up @@ -27,29 +27,25 @@ interface RootState {

class Root extends React.Component<RootProps, RootState> {
state: RootState = {}
sidebarEvents: AnnotationsSidebarInPageEventEmitter

async componentDidMount() {
this.setState({
themeVariant: await loadThemeVariant(),
})
this.sidebarEvents = new EventEmitter() as AnnotationsSidebarInPageEventEmitter
}

render() {
const { themeVariant } = this.state
if (!themeVariant) {
return null
}
console.log('this sidebarEvents', this.sidebarEvents)
return (
<Provider store={this.props.store}>
<ThemeProvider theme={theme({ variant: themeVariant })}>
<ErrorBoundary component={RuntimeError}>
<Popup
getRootElement={this.props.getRootElement}
analyticsBG={null}
sidebarEvents={this.sidebarEvents}
/>
</ErrorBoundary>
</ThemeProvider>
Expand Down
1 change: 0 additions & 1 deletion src/popup/logic.ts
Expand Up @@ -28,7 +28,6 @@ export interface Dependencies {
analyticsBG: AnalyticsCoreInterface
annotationsBG: AnnotationInterface<'provider'>
authBG: AuthRemoteFunctionsInterface
sidebarEvents: AnnotationsSidebarInPageEventEmitter
}

export interface Event {
Expand Down

0 comments on commit 4043c80

Please sign in to comment.