Skip to content

Commit

Permalink
fix up type errors and bugs found in last testing
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Mar 11, 2024
1 parent 18cb8d4 commit 98b9f77
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 17 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
23 changes: 20 additions & 3 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2437,7 +2437,18 @@ export class DashboardLogic extends UILogic<State, Events> {
})
}

setPageNewNoteLists: EventHandler<'setPageNewNoteLists'> = ({ event }) => {
setPageNewNoteLists: EventHandler<'setPageNewNoteLists'> = ({
event,
previousState,
}) => {
const existingLists =
previousState.searchResults.results[event.day].pages.byId[
event.pageId
].newNoteForm.lists
const uniqueLists = event.lists.filter(
(list) => !existingLists.includes(list),
)

this.emitMutation({
searchResults: {
results: {
Expand All @@ -2446,7 +2457,7 @@ export class DashboardLogic extends UILogic<State, Events> {
byId: {
[event.pageId]: {
newNoteForm: {
lists: { $set: event.lists },
lists: { $set: uniqueLists },
},
},
},
Expand Down Expand Up @@ -3049,6 +3060,13 @@ export class DashboardLogic extends UILogic<State, Events> {
}) => {
const { contentShareBG } = this.options
const noteData = previousState.searchResults.noteData.byId[event.noteId]

const noteListIds = new Set(noteData.lists)

if (noteListIds.has(event.added)) {
return
}

const pageData =
previousState.searchResults.pageData.byId[noteData.pageUrl]
const listData = getListData(
Expand All @@ -3059,7 +3077,6 @@ export class DashboardLogic extends UILogic<State, Events> {

let remoteFn: () => Promise<any>

const noteListIds = new Set(noteData.lists)
const pageListIds = new Set(pageData.lists)

if (event.added != null) {
Expand Down
8 changes: 8 additions & 0 deletions src/in-page-ui/tooltip/content_script/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ class TooltipRoot extends React.Component<TooltipRootProps, TooltipRootState> {
if (!currentAnnotation) {
return
}

const isListAlreadySelected = this.state.currentAnnotationLists.some(
(currentList) => currentList.localId === listId,
)
if (isListAlreadySelected) {
return
}

const newList = this.props.annotationsCache.getListByLocalId(listId)
const listsForState = [...this.state.currentAnnotationLists]
listsForState.push(newList)
Expand Down
11 changes: 11 additions & 0 deletions src/in-page-ui/tooltip/content_script/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,17 @@ export const insertTooltip = async (params: TooltipInsertDependencies) => {
removeSpaceForAnnotation: (listId: number) => {
return // Placeholder function, replace with actual implementation
},
selectSpaceForAnnotation: (listId: number) => {
// Placeholder function, replace with actual implementation
},
updateSpacesSearchSuggestions: async (query: string) => {
// Placeholder function, replace with actual implementation
return [] // Assuming this function returns an array of suggestions
},
spaceSearchResults: [], // Assuming this is an array, adjust according to your needs
addNewSpaceViaWikiLinks: async (spaceName: string) => {
// Placeholder function, replace with actual implementation
},
},
{
annotationsBG: params.annotationsBG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1182,17 +1182,13 @@ export class AnnotationsSidebarContainer<
spaceName,
unifiedAnnotationId,
) => {
const {
localListId,
} = await this.props.customListsBG.createCustomList(
{ name: spaceName },
this.processEvent(
'addNewSpaceViaWikiLinksEditNote',
{
spaceName: spaceName,
unifiedAnnotationId: unifiedAnnotationId,
},
)

this.processEvent('updateListsForAnnotation', {
added: localListId,
deleted: null,
unifiedAnnotationId: unifiedAnnotationId,
})
}}
spaceSearchSuggestions={
this.state.spaceSearchSuggestions
Expand Down
19 changes: 16 additions & 3 deletions src/sidebar/annotations-sidebar/containers/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2700,6 +2700,7 @@ export class SidebarContainerLogic extends UILogic<
'updateListsForAnnotation'
> = async ({ event }) => {
const { annotationsCache, contentSharingBG } = this.options
console.log('arrives here', event.added)

// this.emitMutation({ confirmSelectNoteSpaceArgs: { $set: null } })

Expand Down Expand Up @@ -2732,6 +2733,11 @@ export class SidebarContainerLogic extends UILogic<
)
}

console.log('cacheList', cacheList, unifiedListIds)
if (unifiedListIds.has(cacheList.unifiedId)) {
return
}

unifiedListIds.add(cacheList.unifiedId)
bgPromise = contentSharingBG.shareAnnotationToSomeLists({
annotationUrl: existing.localId,
Expand Down Expand Up @@ -2821,6 +2827,8 @@ export class SidebarContainerLogic extends UILogic<
isPrivate: true,
})

console.log('goes through here', event)

this.processUIEvent('updateListsForAnnotation', {
event: {
added: localListId,
Expand Down Expand Up @@ -2866,9 +2874,14 @@ export class SidebarContainerLogic extends UILogic<
event,
previousState,
}) => {
this.emitMutation({
commentBox: { lists: { $set: event.lists } },
})
const existingLists = new Set(previousState.commentBox.lists)
const newLists = event.lists.filter((list) => !existingLists.has(list))

if (newLists.length > 0) {
this.emitMutation({
commentBox: { lists: { $set: newLists } },
})
}
}

goToAnnotationInNewTab: EventHandler<'goToAnnotationInNewTab'> = async ({
Expand Down

0 comments on commit 98b9f77

Please sign in to comment.