From 85b4e634824db679a297e01432fb3920985c557b Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Wed, 1 May 2024 15:06:59 +0700 Subject: [PATCH 01/12] Index page results by compound ID of page ID + pagination skip - Prev was only page ID which meant there was no support for the same page appearing twice, which is now possible in blank search - Pagination skip is an arbitrary choice as part of the new compound ID. It could be anything else which is unique to that "page" of search results --- src/dashboard-refactor/logic.ts | 23 +++++++++-------- .../search-results/index.tsx | 15 +++++------ .../search-results/types.ts | 7 ++++-- src/dashboard-refactor/search-results/util.ts | 25 ++++++++++--------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index 1611657045..db818ecabc 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -940,13 +940,14 @@ export class DashboardLogic extends UILogic { const { results } = utils.pageSearchResultToState( result, + params, this.options.annotationsCache, ) - let resultsList = results[-1].pages.byId + const resultsList = results[-1].pages.byId - for (let page of Object.values(resultsList)) { - const annotations = page.noteIds?.user ?? [] + for (const page of Object.values(resultsList)) { + const annotations = page.noteIds.user ?? [] if (selectedUrls[page.id]) { if (annotations.length > 0) { for (let note of annotations) { @@ -1239,6 +1240,7 @@ export class DashboardLogic extends UILogic { results, } = utils.pageSearchResultToState( result, + params, this.options.annotationsCache, ) @@ -1323,21 +1325,20 @@ export class DashboardLogic extends UILogic { compiledSelectableBlocks = previousState.selectableBlocks } - let resultsList = results[-1].pages.byId + const resultsList = results[-1].pages.byId - for (let page of Object.values(resultsList)) { - let block: SelectableBlock = { + for (const page of Object.values(resultsList)) { + const block: SelectableBlock = { id: page.id, type: 'page', } compiledSelectableBlocks.push(block) - - let pageNotes = page?.noteIds?.user ?? null + const pageNotes = page.noteIds.user ?? null if (pageNotes.length > 0) { - for (let note of pageNotes) { - let noteBlock: SelectableBlock = { + for (const note of pageNotes) { + const noteBlock: SelectableBlock = { id: note, type: 'note', } @@ -1548,9 +1549,11 @@ export class DashboardLogic extends UILogic { /* END - modal event handlers */ /* START - search result event handlers */ + // TODO: Remove this event setPageSearchResult: EventHandler<'setPageSearchResult'> = ({ event }) => { const state = utils.pageSearchResultToState( event.result, + { skip: 0, limit: 10 }, this.options.annotationsCache, ) this.emitMutation({ diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index 6d57e5faa3..7f43ef4f9c 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -708,25 +708,26 @@ export default class SearchResultsContainer extends React.Component< } private renderPageResult = ( - pageId: string, + pageResultId: string, day: number, index: number, order: number, ) => { + const pageResult = this.props.results[day].pages.byId[pageResultId] const page = { - ...this.props.pageData.byId[pageId], - ...this.props.results[day].pages.byId[pageId], + ...this.props.pageData.byId[pageResult.id], + ...pageResult, } const interactionProps = bindFunctionalProps< PageInteractionAugdProps, PageInteractionProps - >(this.props.pageInteractionProps, day, pageId) + >(this.props.pageInteractionProps, day, pageResultId) const pickerProps = bindFunctionalProps< PagePickerAugdProps, PagePickerProps - >(this.props.pagePickerProps, pageId) + >(this.props.pagePickerProps, pageResult.id) return ( 0} + hasNotes={page.totalAnnotationCount > 0} filterbyList={this.props.filterByList} searchType={this.props.searchType} isInFocus={page.isInFocus} diff --git a/src/dashboard-refactor/search-results/types.ts b/src/dashboard-refactor/search-results/types.ts index 2b85a9079e..c98e33f40d 100644 --- a/src/dashboard-refactor/search-results/types.ts +++ b/src/dashboard-refactor/search-results/types.ts @@ -2,7 +2,10 @@ import type { TaskState } from 'ui-logic-core/lib/types' import type { UIEvent } from 'ui-logic-core' import type { AnnotationsSorter } from 'src/sidebar/annotations-sidebar/sorting' -import type { StandardSearchResponse } from 'src/search/background/types' +import type { + StandardSearchResponse, + UnifiedSearchPaginationParams, +} from 'src/search/background/types' import type { PipelineRes } from 'src/search' import type { PickerUpdateHandler } from 'src/common-ui/GenericPicker/types' import type { Anchor } from 'src/highlighting/types' @@ -110,8 +113,8 @@ export type PagePickerAugdProps = { export type SearchResultToState = ( result: T, + params: UnifiedSearchPaginationParams, annotationsCache: PageAnnotationsCacheInterface, - extraPageResultState?: Pick, ) => Pick export type SearchType = diff --git a/src/dashboard-refactor/search-results/util.ts b/src/dashboard-refactor/search-results/util.ts index 98de26d9d4..77cd4cd22b 100644 --- a/src/dashboard-refactor/search-results/util.ts +++ b/src/dashboard-refactor/search-results/util.ts @@ -105,7 +105,6 @@ export const bindFunctionalProps = < export const getInitialPageResultState = ( id: string, noteIds: string[] = [], - extra: Partial = {}, ): PageResult => ({ id, notesType: 'user', @@ -121,7 +120,6 @@ export const getInitialPageResultState = ( hoverState: null, copyLoadingState: 'pristine', editTitleState: null, - ...extra, }) export const getInitialNoteResultState = ( @@ -202,29 +200,32 @@ const annotationToNoteData = ( } } +export const formPageSearchResultId = ( + pageId: string, + resultsPage: number, +): string => `${resultsPage}-${pageId}` + export const pageSearchResultToState: SearchResultToState = ( result, + params, cache, - extraPageResultState, ) => { const pageData = initNormalizedState() const noteData = initNormalizedState() const pageResults = initNormalizedState() for (const pageResult of result.docs) { - const id = pageResult.url + const pageId = pageResult.url + const resultId = formPageSearchResultId(pageId, params.skip) + const sortedAnnots = pageResult.annotations.sort(sortByPagePosition) const noteIds = sortedAnnots.map((a) => a.url) - pageData.byId[id] = pageResultToPageData(pageResult, cache) - pageResults.byId[id] = getInitialPageResultState( - pageResult.url, - noteIds, - extraPageResultState, - ) + pageData.byId[pageId] = pageResultToPageData(pageResult, cache) + pageResults.byId[resultId] = getInitialPageResultState(pageId, noteIds) - pageData.allIds.push(id) - pageResults.allIds.push(id) + pageData.allIds.push(pageId) + pageResults.allIds.push(resultId) for (const annotation of sortedAnnots) { noteData.allIds.push(annotation.url) From b3e1794aaa81cba5a82d710654e2a88ecfa59bd9 Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Thu, 2 May 2024 14:19:39 +0700 Subject: [PATCH 02/12] Fix page list removal not working with notes - Didn't properly propagate to remove lists from dependent notes --- src/dashboard-refactor/index.tsx | 6 +- src/dashboard-refactor/logic.ts | 59 +++++++++++++------ .../search-results/index.tsx | 6 +- .../search-results/logic.test.ts | 27 +++------ .../search-results/types.ts | 24 ++------ src/dashboard-refactor/search-results/util.ts | 25 ++++---- src/dashboard-refactor/util.ts | 34 ----------- 7 files changed, 77 insertions(+), 104 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index c9d7d16af9..84a28f88fb 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1203,11 +1203,9 @@ export class DashboardContainer extends StatefulUIElement< }, }} pagePickerProps={{ - onListPickerUpdate: (pageId) => (args) => + onListPickerUpdate: (pageResultId) => (args) => this.processEvent('setPageLists', { - id: pageId, - fullPageUrl: - searchResults.pageData.byId[pageId].fullUrl, + pageResultId: pageResultId, ...this.localListPickerArgIdsToCached(args), }), }} diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index db818ecabc..4133f3515a 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -19,12 +19,7 @@ import { MISSING_PDF_QUERY_PARAM, } from 'src/dashboard-refactor/constants' import { STORAGE_KEYS as CLOUD_STORAGE_KEYS } from 'src/personal-cloud/constants' -import { - updatePickerValues, - stateToSearchParams, - flattenNestedResults, - getListData, -} from './util' +import { updatePickerValues, stateToSearchParams, getListData } from './util' import { SPECIAL_LIST_IDS } from '@worldbrain/memex-common/lib/storage/modules/lists/constants' import type { NoResultsType, SelectableBlock } from './search-results/types' import { filterListsByQuery } from './lists-sidebar/util' @@ -256,6 +251,7 @@ export class DashboardLogic extends UILogic { searchResults: { blankSearchOldestResultTimestamp: null, results: {}, + pageIdToResultIds: {}, noResultsType: null, showMobileAppAd: false, shouldShowTagsUIs: false, @@ -948,7 +944,7 @@ export class DashboardLogic extends UILogic { for (const page of Object.values(resultsList)) { const annotations = page.noteIds.user ?? [] - if (selectedUrls[page.id]) { + if (selectedUrls[page.pageId]) { if (annotations.length > 0) { for (let note of annotations) { bulkEditItems[note] = { @@ -958,7 +954,7 @@ export class DashboardLogic extends UILogic { } continue } else { - bulkEditItems[page.id] = { + bulkEditItems[page.pageId] = { type: 'page', } if (annotations.length > 0) { @@ -1238,6 +1234,7 @@ export class DashboardLogic extends UILogic { noteData, pageData, results, + pageIdToResultIds, } = utils.pageSearchResultToState( result, params, @@ -1310,11 +1307,17 @@ export class DashboardLogic extends UILogic { noteData, ), }, + pageIdToResultIds: { + $merge: pageIdToResultIds, + }, } : { results: { $set: results }, pageData: { $set: pageData }, noteData: { $set: noteData }, + pageIdToResultIds: { + $set: pageIdToResultIds, + }, }), }, }) @@ -1329,7 +1332,7 @@ export class DashboardLogic extends UILogic { for (const page of Object.values(resultsList)) { const block: SelectableBlock = { - id: page.id, + id: page.pageId, type: 'page', } @@ -1582,13 +1585,35 @@ export class DashboardLogic extends UILogic { > = {} const calcNextLists = updatePickerValues(event) + const pageResult = + previousState.searchResults.results[-1].pages.byId[ + event.pageResultId + ] + const pageData = + previousState.searchResults.pageData.byId[pageResult.pageId] + // If we're removing a shared list, we also need to make sure it gets removed from children annots if (removingSharedList) { - const childrenNoteIds = flattenNestedResults(previousState).byId[ - event.id - ].noteIds.user + const dependentNoteIds: string[] = [] + const pageResultIds = + previousState.searchResults.pageIdToResultIds[pageResult.pageId] + + for (const pageResultId of pageResultIds) { + const noteIdsForPage = + previousState.searchResults.results[-1].pages.byId[ + pageResultId + ].noteIds.user + + dependentNoteIds.push( + ...noteIdsForPage.filter( + (noteId) => + previousState.searchResults.noteData.byId[noteId] + .isBulkShareProtected, + ), + ) + } - for (const noteId of childrenNoteIds) { + for (const noteId of dependentNoteIds) { noteDataMutation[noteId] = { lists: { $apply: calcNextLists }, } @@ -1596,10 +1621,10 @@ export class DashboardLogic extends UILogic { } const nextPageListIds = calcNextLists( - previousState.searchResults.pageData.byId[event.id].lists, + previousState.searchResults.pageData.byId[pageResult.pageId].lists, ) this.options.annotationsCache.setPageData( - normalizeUrl(event.fullPageUrl), + pageResult.pageId, nextPageListIds, ) this.emitMutation({ @@ -1607,7 +1632,7 @@ export class DashboardLogic extends UILogic { noteData: { byId: noteDataMutation }, pageData: { byId: { - [event.id]: { + [pageResult.pageId]: { lists: { $set: nextPageListIds }, }, }, @@ -1616,7 +1641,7 @@ export class DashboardLogic extends UILogic { }) await this.options.listsBG.updateListForPage({ - url: event.fullPageUrl, + url: pageData.fullUrl, added: event.added && listData.localId, deleted: event.deleted && listData.localId, skipPageIndexing: true, diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index 7f43ef4f9c..de0119fb25 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -715,7 +715,7 @@ export default class SearchResultsContainer extends React.Component< ) => { const pageResult = this.props.results[day].pages.byId[pageResultId] const page = { - ...this.props.pageData.byId[pageResult.id], + ...this.props.pageData.byId[pageResult.pageId], ...pageResult, } @@ -727,7 +727,7 @@ export default class SearchResultsContainer extends React.Component< const pickerProps = bindFunctionalProps< PagePickerAugdProps, PagePickerProps - >(this.props.pagePickerProps, pageResult.id) + >(this.props.pagePickerProps, pageResultId) return ( this.shiftSelectItems(page.id)} + shiftSelectItem={() => this.shiftSelectItems(page.pageId)} isBulkSelected={this.props.selectedItems?.includes( page.normalizedUrl, )} diff --git a/src/dashboard-refactor/search-results/logic.test.ts b/src/dashboard-refactor/search-results/logic.test.ts index f396026d0e..77727acd92 100644 --- a/src/dashboard-refactor/search-results/logic.test.ts +++ b/src/dashboard-refactor/search-results/logic.test.ts @@ -177,14 +177,12 @@ describe('Dashboard search results logic', () => { expect(annotationsCache.pageListIds.get(pageId)).toEqual(undefined) await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, added: listAData.unifiedId, skipPageIndexing: true, }) await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, added: listBData.unifiedId, skipPageIndexing: true, }) @@ -197,8 +195,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, deleted: listAData.unifiedId, skipPageIndexing: true, }) @@ -211,8 +208,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, added: listCData.unifiedId, skipPageIndexing: true, }) @@ -393,8 +389,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, added: listData.unifiedId, skipPageIndexing: true, }) @@ -1342,8 +1337,7 @@ describe('Dashboard search results logic', () => { const pageId = DATA.PAGE_1.normalizedUrl await searchResults.processEvent('setPageLists', { - id: pageId, - fullPageUrl: 'https://' + pageId, + pageResultId: pageId, added: listDataA.unifiedId, skipPageIndexing: true, }) @@ -2656,8 +2650,7 @@ describe('Dashboard search results logic', () => { added: listDataC.unifiedId, }) await searchResults.processEvent('setPageLists', { - id: pageIdA, - fullPageUrl: DATA.PAGE_1.fullUrl, + pageResultId: pageIdA, added: listDataC.unifiedId, // This list is private, so manually adding it to the page here }) @@ -2700,8 +2693,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setPageLists', { - id: pageIdA, - fullPageUrl: DATA.PAGE_1.fullUrl, + pageResultId: pageIdA, deleted: listDataC.unifiedId, }) @@ -2742,8 +2734,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setPageLists', { - id: pageIdA, - fullPageUrl: DATA.PAGE_1.fullUrl, + pageResultId: pageIdA, deleted: listDataA.unifiedId, }) diff --git a/src/dashboard-refactor/search-results/types.ts b/src/dashboard-refactor/search-results/types.ts index c98e33f40d..320ce838eb 100644 --- a/src/dashboard-refactor/search-results/types.ts +++ b/src/dashboard-refactor/search-results/types.ts @@ -1,11 +1,7 @@ import type { TaskState } from 'ui-logic-core/lib/types' import type { UIEvent } from 'ui-logic-core' - import type { AnnotationsSorter } from 'src/sidebar/annotations-sidebar/sorting' -import type { - StandardSearchResponse, - UnifiedSearchPaginationParams, -} from 'src/search/background/types' +import type { StandardSearchResponse } from 'src/search/background/types' import type { PipelineRes } from 'src/search' import type { PickerUpdateHandler } from 'src/common-ui/GenericPicker/types' import type { Anchor } from 'src/highlighting/types' @@ -16,10 +12,7 @@ import type { AnnotationSharingStates, } from 'src/content-sharing/background/types' import type { AnnotationPrivacyLevels } from '@worldbrain/memex-common/lib/annotations/types' -import type { - PageAnnotationsCacheInterface, - RGBAColor, -} from 'src/annotations/cache/types' +import type { RGBAColor } from 'src/annotations/cache/types' export interface CommonInteractionProps { onCopyPasterBtnClick: React.MouseEventHandler @@ -111,12 +104,6 @@ export type PagePickerAugdProps = { [Key in keyof PagePickerProps]: (pageId: string) => PagePickerProps[Key] } -export type SearchResultToState = ( - result: T, - params: UnifiedSearchPaginationParams, - annotationsCache: PageAnnotationsCacheInterface, -) => Pick - export type SearchType = | 'pages' | 'notes' @@ -210,7 +197,7 @@ export interface NoteResult { } export interface PageResult { - id: string + pageId: string notesType: NotesType areNotesShown: boolean activePage: boolean @@ -254,6 +241,8 @@ export interface RootState { results: NestedResults areResultsExhausted: boolean + pageIdToResultIds: { [pageId: string]: string[] } + // Display data lookups /** Holds page data shared with all page occurrences on any day. */ pageData: NormalizedState @@ -310,8 +299,7 @@ export type Events = UIEvent<{ // Page data state mutations (*shared with all* occurences of the page in different days) setPageLists: { - id: string - fullPageUrl: string + pageResultId: string added?: string deleted?: string skipPageIndexing?: boolean diff --git a/src/dashboard-refactor/search-results/util.ts b/src/dashboard-refactor/search-results/util.ts index 77cd4cd22b..93ca88f10e 100644 --- a/src/dashboard-refactor/search-results/util.ts +++ b/src/dashboard-refactor/search-results/util.ts @@ -1,14 +1,12 @@ import type { StandardSearchResponse, - AnnotsByPageUrl, AnnotPage, + UnifiedSearchPaginationParams, } from 'src/search/background/types' import type { PageData, PageResult, - PageResultsByDay, NoteData, - SearchResultToState, NoteResult, NoteFormState, RootState, @@ -103,10 +101,10 @@ export const bindFunctionalProps = < } export const getInitialPageResultState = ( - id: string, + pageId: string, noteIds: string[] = [], ): PageResult => ({ - id, + pageId, notesType: 'user', activePage: undefined, areNotesShown: false, @@ -205,18 +203,24 @@ export const formPageSearchResultId = ( resultsPage: number, ): string => `${resultsPage}-${pageId}` -export const pageSearchResultToState: SearchResultToState = ( - result, - params, - cache, -) => { +export const pageSearchResultToState = ( + result: StandardSearchResponse, + params: UnifiedSearchPaginationParams, + cache: PageAnnotationsCacheInterface, +): Pick< + RootState, + 'results' | 'noteData' | 'pageData' | 'pageIdToResultIds' +> => { const pageData = initNormalizedState() const noteData = initNormalizedState() const pageResults = initNormalizedState() + const pageIdToResultIds: RootState['pageIdToResultIds'] = {} for (const pageResult of result.docs) { const pageId = pageResult.url const resultId = formPageSearchResultId(pageId, params.skip) + const existingResultIds = pageIdToResultIds[pageId] ?? [] + pageIdToResultIds[pageId] = [...existingResultIds, resultId] const sortedAnnots = pageResult.annotations.sort(sortByPagePosition) const noteIds = sortedAnnots.map((a) => a.url) @@ -239,6 +243,7 @@ export const pageSearchResultToState: SearchResultToState): NormalizedState => { - const allPageResults = Object.values(searchResults.results).map( - (a) => a.pages, - ) - const result = initNormalizedState() - - for (const pages of allPageResults) { - result.allIds = [...new Set([...result.allIds, ...pages.allIds])] - for (const pageId in pages.byId) { - const existing = result.byId[pageId] ?? ({} as PageResult) - result.byId[pageId] = { - ...pages.byId[pageId], - noteIds: { - followed: [], - search: [], - user: [ - ...new Set([ - ...(existing?.noteIds?.user ?? []), - ...pages.byId[pageId].noteIds.user, - ]), - ], - }, - } - } - } - - return result -} From e0960302df98ca257bc151d391bc9c17b7cd17cd Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Thu, 2 May 2024 15:28:46 +0700 Subject: [PATCH 03/12] Get page result sidebar btn partially working - This code is really hard to understand. It's gotten extremely complicated for such simple behavior :( - I got it to a state where it seems to work, but lots of errors throw in the console. Ran out of patience to figure that part out further --- src/dashboard-refactor/index.tsx | 16 +++++++++----- src/dashboard-refactor/logic.ts | 22 ++++--------------- .../search-results/components/page-result.tsx | 2 -- src/dashboard-refactor/types.ts | 6 ++--- .../AnnotationsSidebarContainer.tsx | 1 + 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index 84a28f88fb..0a4ffccf20 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1019,25 +1019,31 @@ export class DashboardContainer extends StatefulUIElement< day, pageId, }), - onNotesBtnClick: (day, pageId) => (e) => { + onNotesBtnClick: (day, pageResultId) => (e) => { + // TODO: Multiple processEvent calls should never happen from a single user action. Needs to be unified + // These are also running concurrently, potentially introducing race conditions this.processEvent('toggleNoteSidebarOn', null) - const pageData = searchResults.pageData.byId[pageId] + const pageResult = + searchResults.results[-1].pages.byId[pageResultId] + const pageData = + searchResults.pageData.byId[pageResult.pageId] this.processEvent('setActivePage', { activeDay: day, - activePageID: pageId, + activePageID: pageResult.pageId, activePage: true, }) if (e.shiftKey) { this.processEvent('setPageNotesShown', { day, - pageId, + pageId: pageResultId, areShown: !searchResults.results[day].pages - .byId[pageId].areNotesShown, + .byId[pageResultId].areNotesShown, }) return } + // TODO: Explain why a setTimeout is needed here setTimeout( () => { this.notesSidebarRef.current.toggleSidebarShowForPageId( diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index 4133f3515a..9c7e368840 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -2341,30 +2341,17 @@ export class DashboardLogic extends UILogic { event, previousState, }) => { - if (event.activePageID == null && event.activeDay == null) { + if (event.activePageID == null || event.activeDay == null) { this.emitMutation({ activeDay: { $set: undefined }, activePageID: { $set: undefined }, - searchResults: { - results: { - [previousState.activeDay]: { - pages: { - byId: { - [previousState.activePageID]: { - activePage: { - $set: false, - }, - }, - }, - }, - }, - }, - }, }) return } this.emitMutation({ + activeDay: { $set: event.activeDay }, + activePageID: { $set: event.activePageID }, searchResults: { results: { [event.activeDay]: { @@ -2391,8 +2378,6 @@ export class DashboardLogic extends UILogic { }, }, }, - activeDay: { $set: event.activeDay }, - activePageID: { $set: event.activePageID }, }) } @@ -2885,6 +2870,7 @@ export class DashboardLogic extends UILogic { isNoteSidebarShown: { $set: true }, }) } + onMatchingTextToggleClick: EventHandler< 'onMatchingTextToggleClick' > = async ({ event, previousState }) => { diff --git a/src/dashboard-refactor/search-results/components/page-result.tsx b/src/dashboard-refactor/search-results/components/page-result.tsx index 567673bcfd..bb79096ff9 100644 --- a/src/dashboard-refactor/search-results/components/page-result.tsx +++ b/src/dashboard-refactor/search-results/components/page-result.tsx @@ -912,8 +912,6 @@ export default class PageResultView extends PureComponent { } render() { - const hasTitle = this.props.fullTitle && this.props.fullTitle.length > 0 - return ( Date: Thu, 2 May 2024 15:43:06 +0700 Subject: [PATCH 04/12] Remove tag picker page result interaction props --- src/dashboard-refactor/index.tsx | 14 -------------- src/dashboard-refactor/search-results/index.tsx | 5 ----- src/dashboard-refactor/search-results/types.ts | 1 - 3 files changed, 20 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index 0a4ffccf20..cd4448b92c 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1062,14 +1062,6 @@ export class DashboardContainer extends StatefulUIElement< pageData.fullUrl, ) }, - onTagPickerBtnClick: (day, pageId) => () => - this.processEvent('setPageTagPickerShown', { - day, - pageId, - isShown: !searchResults.results[day].pages.byId[ - pageId - ].isTagPickerShown, - }), onListPickerFooterBtnClick: (day, pageId) => () => this.processEvent('setPageListPickerShown', { day, @@ -1359,12 +1351,6 @@ export class DashboardContainer extends StatefulUIElement< }, onGoToHighlightClick: (noteId) => () => this.processEvent('goToHighlightInNewTab', { noteId }), - onTagPickerBtnClick: (noteId) => () => - this.processEvent('setNoteTagPickerShown', { - noteId, - isShown: !searchResults.noteData.byId[noteId] - .isTagPickerShown, - }), onListPickerBarBtnClick: (noteId) => () => this.processEvent('setNoteListPickerShown', { noteId, diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index de0119fb25..7dd88cd3b7 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -774,11 +774,6 @@ export default class SearchResultsContainer extends React.Component< {...pickerProps} {...page} lists={this.getLocalListIdsForCacheIds(page.lists)} - onTagPickerBtnClick={ - this.props.shouldShowTagsUIs - ? interactionProps.onTagPickerBtnClick - : undefined - } hasNotes={page.totalAnnotationCount > 0} filterbyList={this.props.filterByList} searchType={this.props.searchType} diff --git a/src/dashboard-refactor/search-results/types.ts b/src/dashboard-refactor/search-results/types.ts index 320ce838eb..19745f08aa 100644 --- a/src/dashboard-refactor/search-results/types.ts +++ b/src/dashboard-refactor/search-results/types.ts @@ -16,7 +16,6 @@ import type { RGBAColor } from 'src/annotations/cache/types' export interface CommonInteractionProps { onCopyPasterBtnClick: React.MouseEventHandler - onTagPickerBtnClick?: React.MouseEventHandler onListPickerBarBtnClick: React.MouseEventHandler onListPickerFooterBtnClick: React.MouseEventHandler onShareBtnClick: React.MouseEventHandler From 4ed4d18e6dd2e41cfc0452f586b3ea1db21b5caa Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Thu, 2 May 2024 15:43:19 +0700 Subject: [PATCH 05/12] Get page result AI btn working again --- src/dashboard-refactor/index.tsx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index cd4448b92c..cbb50319ae 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1008,16 +1008,19 @@ export class DashboardContainer extends StatefulUIElement< }} spaceSearchSuggestions={this.state.spaceSearchSuggestions} pageInteractionProps={{ - onClick: (day, pageId) => async (event) => + onClick: (day, pageResultId) => async (event) => this.processEvent('clickPageResult', { day, - pageId, + pageId: pageResultId, synthEvent: event, }), - onMatchingTextToggleClick: (day, pageId) => async () => + onMatchingTextToggleClick: ( + day, + pageResultId, + ) => async () => this.processEvent('onMatchingTextToggleClick', { day, - pageId, + pageId: pageResultId, }), onNotesBtnClick: (day, pageResultId) => (e) => { // TODO: Multiple processEvent calls should never happen from a single user action. Needs to be unified @@ -1054,11 +1057,14 @@ export class DashboardContainer extends StatefulUIElement< this.props.inPageMode ? 200 : 0, ) }, - onAIResultBtnClick: (day, pageId) => () => { + onAIResultBtnClick: (day, pageResultId) => async () => { this.processEvent('toggleNoteSidebarOn', null) - const pageData = searchResults.pageData.byId[pageId] + const pageResult = + searchResults.results[-1].pages.byId[pageResultId] + const pageData = + searchResults.pageData.byId[pageResult.pageId] - this.notesSidebarRef.current.toggleAIShowForPageId( + await this.notesSidebarRef.current.toggleAIShowForPageId( pageData.fullUrl, ) }, From 4c9c0008138c3a920d79fb26a7b0101e71d345e1 Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Thu, 2 May 2024 16:01:12 +0700 Subject: [PATCH 06/12] Change all pageId refs to pageResultIds --- src/dashboard-refactor/index.tsx | 59 +++++------ src/dashboard-refactor/logic.ts | 98 ++++++++++--------- .../search-results/index.tsx | 3 +- .../search-results/logic.test.ts | 92 ++++++++--------- .../search-results/types.ts | 3 +- src/dashboard-refactor/search-results/util.ts | 8 +- 6 files changed, 139 insertions(+), 124 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index cbb50319ae..a2d311fe1b 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -950,13 +950,13 @@ export class DashboardContainer extends StatefulUIElement< onPageNotesSortSelection={(day, pageId) => (sortingFn) => this.processEvent('setPageNotesSort', { day, - pageId, + pageResultId: pageId, sortingFn, })} onPageNotesTypeSelection={(day, pageId) => (noteType) => this.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType, })} onShowAllNotesClick={() => @@ -1011,7 +1011,7 @@ export class DashboardContainer extends StatefulUIElement< onClick: (day, pageResultId) => async (event) => this.processEvent('clickPageResult', { day, - pageId: pageResultId, + pageResultId: pageResultId, synthEvent: event, }), onMatchingTextToggleClick: ( @@ -1020,7 +1020,7 @@ export class DashboardContainer extends StatefulUIElement< ) => async () => this.processEvent('onMatchingTextToggleClick', { day, - pageId: pageResultId, + pageResultId: pageResultId, }), onNotesBtnClick: (day, pageResultId) => (e) => { // TODO: Multiple processEvent calls should never happen from a single user action. Needs to be unified @@ -1039,7 +1039,7 @@ export class DashboardContainer extends StatefulUIElement< if (e.shiftKey) { this.processEvent('setPageNotesShown', { day, - pageId: pageResultId, + pageResultId: pageResultId, areShown: !searchResults.results[day].pages .byId[pageResultId].areNotesShown, }) @@ -1071,19 +1071,19 @@ export class DashboardContainer extends StatefulUIElement< onListPickerFooterBtnClick: (day, pageId) => () => this.processEvent('setPageListPickerShown', { day, - pageId, + pageResultId: pageId, show: 'footer', }), onListPickerBarBtnClick: (day, pageId) => () => this.processEvent('setPageListPickerShown', { day, - pageId, + pageResultId: pageId, show: 'lists-bar', }), onCopyPasterBtnClick: (day, pageId) => (event) => this.processEvent('setPageCopyPasterShown', { day, - pageId, + pageResultId: pageId, isShown: !searchResults.results[day].pages.byId[ pageId ].isCopyPasterShown, @@ -1092,7 +1092,7 @@ export class DashboardContainer extends StatefulUIElement< onCopyPasterDefaultExecute: (day, pageId) => (event) => this.processEvent('setCopyPasterDefaultExecute', { day, - pageId, + pageResultId: pageId, isShown: !searchResults.results[day].pages.byId[ pageId ].isCopyPasterShown, @@ -1101,13 +1101,13 @@ export class DashboardContainer extends StatefulUIElement< onTrashBtnClick: (day, pageId) => (instaDelete) => this.processEvent('setDeletingPageArgs', { day, - pageId, + pageResultId: pageId, instaDelete, }), onShareBtnClick: (day, pageId) => () => this.processEvent('setPageShareMenuShown', { day, - pageId, + pageResultId: pageId, isShown: !searchResults.results[day].pages.byId[ pageId ].isShareMenuShown, @@ -1118,7 +1118,7 @@ export class DashboardContainer extends StatefulUIElement< } this.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover: 'main-content', }) @@ -1132,25 +1132,25 @@ export class DashboardContainer extends StatefulUIElement< onFooterHover: (day, pageId) => () => this.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover: 'footer', }), onTagsHover: (day, pageId) => () => this.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover: 'tags', }), onListsHover: (day, pageId) => () => this.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover: 'lists', }), onUnhover: (day, pageId) => () => { this.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover: null, }) if (this.state.focusLockUntilMouseStart) { @@ -1166,21 +1166,24 @@ export class DashboardContainer extends StatefulUIElement< onRemoveFromListBtnClick: (day, pageId) => () => { this.processEvent('removePageFromList', { day, - pageId, + pageResultId: pageId, }) }, onPageDrag: (day, pageId) => (e) => this.processEvent('dragPage', { day, - pageId, + pageResultId: pageId, dataTransfer: e.dataTransfer, }), onPageDrop: (day, pageId) => () => - this.processEvent('dropPage', { day, pageId }), + this.processEvent('dropPage', { + day, + pageResultId: pageId, + }), updatePageNotesShareInfo: (day, pageId) => (shareStates) => this.processEvent('updatePageNotesShareInfo', { day, - pageId, + pageResultId: pageId, shareStates, }), onEditTitleSave: (day, pageId) => ( @@ -1219,12 +1222,12 @@ export class DashboardContainer extends StatefulUIElement< onCancel: (day, pageId) => () => this.processEvent('cancelPageNewNote', { day, - pageId, + pageResultId: pageId, }), onCommentChange: (day, pageId) => (value) => this.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value, }), addPageToList: (day, pageId) => (listId) => { @@ -1238,7 +1241,7 @@ export class DashboardContainer extends StatefulUIElement< } return this.processEvent('setPageNewNoteLists', { day, - pageId, + pageResultId: pageId, lists: [ ...this.state.searchResults.results[day].pages .byId[pageId].newNoteForm.lists, @@ -1257,7 +1260,7 @@ export class DashboardContainer extends StatefulUIElement< } return this.processEvent('setPageNewNoteLists', { day, - pageId, + pageResultId: pageId, lists: this.state.searchResults?.results[ day ].pages.byId[pageId].newNoteForm.lists.filter( @@ -1268,7 +1271,7 @@ export class DashboardContainer extends StatefulUIElement< onSave: (day, pageId) => (shouldShare, isProtected) => this.processEvent('savePageNewNote', { day, - pageId, + pageResultId: pageId, isProtected, shouldShare, fullPageUrl: @@ -1297,7 +1300,7 @@ export class DashboardContainer extends StatefulUIElement< } this.processEvent('setPageNewNoteLists', { day, - pageId, + pageResultId: pageId, lists: [ ...this.state.searchResults.results[day].pages .byId[pageId].newNoteForm.lists, @@ -1318,7 +1321,7 @@ export class DashboardContainer extends StatefulUIElement< } this.processEvent('setPageNewNoteLists', { day, - pageId, + pageResultId: pageId, lists: this.state.searchResults.results[ day ].pages.byId[pageId].newNoteForm.lists.filter( @@ -1414,7 +1417,7 @@ export class DashboardContainer extends StatefulUIElement< onTrashBtnClick: (noteId, day, pageId) => (instaDelete) => this.processEvent('setDeletingNoteArgs', { noteId, - pageId, + pageResultId: pageId, day, }), onCommentChange: (noteId) => (event) => { diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index 9c7e368840..38926bd6c3 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -1654,7 +1654,8 @@ export class DashboardLogic extends UILogic { }) => { if (event.instaDelete) { const pageLists = - previousState.searchResults.pageData.byId[event.pageId].lists + previousState.searchResults.pageData.byId[event.pageResultId] + .lists const isPageInInbox = pageLists.some( (listId) => this.options.annotationsCache.lists.byId[listId].localId === @@ -1678,10 +1679,10 @@ export class DashboardLogic extends UILogic { State['searchResults'] > = { pageData: { - byId: { $unset: [event.pageId] }, + byId: { $unset: [event.pageResultId] }, allIds: { $set: previousState.searchResults.pageData.allIds.filter( - (id) => id !== event.pageId, + (id) => id !== event.pageResultId, ), }, }, @@ -1691,12 +1692,12 @@ export class DashboardLogic extends UILogic { resultsMutation.results = { [event.day]: { pages: { - byId: { $unset: [event.pageId] }, + byId: { $unset: [event.pageResultId] }, allIds: { $set: previousState.searchResults.results[ event.day ].pages.allIds.filter( - (id) => id !== event.pageId, + (id) => id !== event.pageResultId, ), }, }, @@ -1705,14 +1706,14 @@ export class DashboardLogic extends UILogic { } else { resultsMutation.results = removeAllResultOccurrencesOfPage( previousState.searchResults.results, - event.pageId, + event.pageResultId, ) } this.emitMutation({ searchResults: resultsMutation, }) - await this.options.searchBG.delPages([event.pageId]) + await this.options.searchBG.delPages([event.pageResultId]) }, ) } else { @@ -1796,7 +1797,7 @@ export class DashboardLogic extends UILogic { previousState, event: { direction: 'down', - item: { id: event.pageId, type: 'page' }, + item: { id: event.pageResultId, type: 'page' }, }, }) @@ -1806,11 +1807,11 @@ export class DashboardLogic extends UILogic { { mustBeLocal: true, source: 'removePageFromList' }, ) const filterOutPage = (ids: string[]) => - ids.filter((id) => id !== event.pageId) + ids.filter((id) => id !== event.pageResultId) const mutation: UIMutation = { pageData: { - byId: { $unset: [event.pageId] }, + byId: { $unset: [event.pageResultId] }, allIds: { $set: filterOutPage( previousState.searchResults.pageData.allIds, @@ -1823,7 +1824,7 @@ export class DashboardLogic extends UILogic { mutation.results = { [PAGE_SEARCH_DUMMY_DAY]: { pages: { - byId: { $unset: [event.pageId] }, + byId: { $unset: [event.pageResultId] }, allIds: { $set: filterOutPage( previousState.searchResults.results[ @@ -1837,7 +1838,7 @@ export class DashboardLogic extends UILogic { } else { mutation.results = removeAllResultOccurrencesOfPage( previousState.searchResults.results, - event.pageId, + event.pageResultId, ) } this.emitMutation({ @@ -1852,7 +1853,7 @@ export class DashboardLogic extends UILogic { await this.options.listsBG.removePageFromList({ id: listData.localId, - url: event.pageId, + url: event.pageResultId, }) } @@ -1906,7 +1907,7 @@ export class DashboardLogic extends UILogic { throw new Error('No page ID is set for deletion') } - const { pageId, day } = modals.deletingPageArgs + const { pageResultId: pageId, day } = modals.deletingPageArgs const pageLists = pageData.byId[pageId].lists const isPageInInbox = pageLists.some( @@ -2179,7 +2180,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { copyLoadingState: { $set: 'running', }, @@ -2194,12 +2195,12 @@ export class DashboardLogic extends UILogic { let templateCopyResult if ( !previousState.searchResults.results[event.day]?.pages.byId[ - event.pageId + event.pageResultId ].isCopyPasterShown ) { templateCopyResult = await this.handleDefaultTemplateCopy( [null], - [event.pageId], + [event.pageResultId], ) } @@ -2210,7 +2211,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { copyLoadingState: { $set: 'success', }, @@ -2229,7 +2230,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { copyLoadingState: { $set: 'pristine', }, @@ -2253,7 +2254,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { isCopyPasterShown: { $set: event.isShown }, }, }, @@ -2273,7 +2274,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { listPickerShowStatus: { $apply: (prev) => prev === event.show @@ -2298,7 +2299,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { isTagPickerShown: { $set: event.isShown }, }, }, @@ -2326,7 +2327,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { isShareMenuShown: { $set: event.isShown }, }, }, @@ -2389,7 +2390,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { areNotesShown: { $set: event.areShown }, }, }, @@ -2405,7 +2406,8 @@ export class DashboardLogic extends UILogic { previousState, }) => { const { searchResults } = previousState - const page = searchResults.results[event.day]?.pages.byId[event.pageId] + const page = + searchResults.results[event.day]?.pages.byId[event.pageResultId] const sortedNoteIds = page.noteIds[page.notesType].sort((a, b) => event.sortingFn( @@ -2420,7 +2422,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { noteIds: { [page.notesType]: { $set: sortedNoteIds, @@ -2442,7 +2444,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { notesType: { $set: event.noteType }, }, }, @@ -2456,10 +2458,10 @@ export class DashboardLogic extends UILogic { setPageHover: EventHandler<'setPageHover'> = ({ event, previousState }) => { if ( previousState.searchResults.results[event.day]?.pages.byId[ - event.pageId + event.pageResultId ].isCopyPasterShown || previousState.searchResults.results[event.day]?.pages.byId[ - event.pageId + event.pageResultId ].listPickerShowStatus !== 'hide' ) { return @@ -2471,7 +2473,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { hoverState: { $set: event.hover }, }, }, @@ -2491,7 +2493,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { newNoteForm: { isTagPickerShown: { $set: event.isShown, @@ -2512,7 +2514,7 @@ export class DashboardLogic extends UILogic { }) => { const existingLists = previousState.searchResults.results[event.day].pages.byId[ - event.pageId + event.pageResultId ].newNoteForm.lists const uniqueLists = event.lists.filter( (list) => !existingLists.includes(list), @@ -2524,7 +2526,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { newNoteForm: { lists: { $set: uniqueLists }, }, @@ -2546,7 +2548,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { newNoteForm: { inputValue: { $set: event.value }, }, @@ -2566,7 +2568,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { newNoteForm: { $set: utils.getInitialFormState(), }, @@ -2619,7 +2621,7 @@ export class DashboardLogic extends UILogic { this.processUIEvent('setPageNewNoteLists', { event: { day: event.day, - pageId: event.pageId, + pageResultId: event.pageId, lists: listsToAdd, }, previousState, @@ -2655,7 +2657,7 @@ export class DashboardLogic extends UILogic { const { annotationsBG, contentShareBG } = this.options const formState = previousState.searchResults.results[event.day].pages.byId[ - event.pageId + event.pageResultId ].newNoteForm const listsToAdd = formState.lists.map((listId) => getListData(listId, previousState, { @@ -2716,7 +2718,7 @@ export class DashboardLogic extends UILogic { comment: formState.inputValue, tags: formState.tags, lists: formState.lists ?? [], - pageUrl: event.pageId, + pageUrl: event.pageResultId, isShared: shouldSetAsAutoAdded || event.shouldShare, @@ -2732,7 +2734,7 @@ export class DashboardLogic extends UILogic { [event.day]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { newNoteForm: { $set: utils.getInitialFormState(), }, @@ -2875,15 +2877,16 @@ export class DashboardLogic extends UILogic { 'onMatchingTextToggleClick' > = async ({ event, previousState }) => { const previousValue = - previousState.searchResults.results[-1].pages.byId[event.pageId] - ?.showAllResults + previousState.searchResults.results[-1].pages.byId[ + event.pageResultId + ]?.showAllResults this.emitMutation({ searchResults: { results: { [-1]: { pages: { byId: { - [event.pageId]: { + [event.pageResultId]: { showAllResults: { $set: !previousValue }, }, }, @@ -2909,7 +2912,7 @@ export class DashboardLogic extends UILogic { throw new Error('No note ID is set for deletion') } - const { noteId, pageId, day } = modals.deletingNoteArgs + const { noteId, pageResultId: pageId, day } = modals.deletingNoteArgs const pageResult = searchResults.results[day].pages.byId[pageId] const pageResultNoteIds = pageResult.noteIds[ pageResult.notesType @@ -4272,13 +4275,14 @@ export class DashboardLogic extends UILogic { listsSidebar: { someListIsDragging: { $set: true }, }, - searchResults: { draggedPageId: { $set: event.pageId } }, + searchResults: { draggedPageId: { $set: event.pageResultId } }, }) const crt = this.options.document.getElementById(DRAG_EL_ID) crt.style.display = 'block' event.dataTransfer.setDragImage(crt, 0, 0) - const page = previousState.searchResults.pageData.byId[event.pageId] + const page = + previousState.searchResults.pageData.byId[event.pageResultId] const action: DragToListAction<'page'> = { type: 'page', fullPageUrl: page.fullUrl, @@ -4702,7 +4706,7 @@ export class DashboardLogic extends UILogic { previousState, }) => { const pageData = - previousState?.searchResults?.pageData?.byId[event.pageId] + previousState?.searchResults?.pageData?.byId[event.pageResultId] if (!pageData) { return @@ -4731,7 +4735,7 @@ export class DashboardLogic extends UILogic { searchResults: { pageData: { byId: { - [event.pageId]: { + [event.pageResultId]: { uploadedPdfLinkLoadState: { $set: taskState, }, diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index 7dd88cd3b7..4ff4705710 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -576,6 +576,7 @@ export default class SearchResultsContainer extends React.Component< notesType, isShared, noteIds, + pageResultId, }: PageResultData & PageData, day: number, { onShareBtnClick }: PageInteractionProps, @@ -589,7 +590,7 @@ export default class SearchResultsContainer extends React.Component< const boundAnnotCreateProps = bindFunctionalProps< typeof newNoteInteractionProps, NewNoteInteractionProps - >(newNoteInteractionProps, day, normalizedUrl) + >(newNoteInteractionProps, day, pageResultId) const lists = this.getLocalListIdsForCacheIds(newNoteForm.lists) return ( diff --git a/src/dashboard-refactor/search-results/logic.test.ts b/src/dashboard-refactor/search-results/logic.test.ts index 77727acd92..7daaad954f 100644 --- a/src/dashboard-refactor/search-results/logic.test.ts +++ b/src/dashboard-refactor/search-results/logic.test.ts @@ -250,7 +250,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('setDeletingPageArgs', { - pageId, + pageResultId: pageId, day: PAGE_SEARCH_DUMMY_DAY, instaDelete: false, }) @@ -322,7 +322,7 @@ describe('Dashboard search results logic', () => { ).toEqual(true) await searchResults.processEvent('setDeletingPageArgs', { - pageId, + pageResultId: pageId, day: PAGE_SEARCH_DUMMY_DAY, instaDelete: true, }) @@ -405,7 +405,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('removePageFromList', { day: PAGE_SEARCH_DUMMY_DAY, - pageId, + pageResultId: pageId, }) expect( @@ -438,7 +438,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('dragPage', { - pageId: page.normalizedUrl, + pageResultId: page.normalizedUrl, day: PAGE_SEARCH_DUMMY_DAY, dataTransfer, }) @@ -453,7 +453,7 @@ describe('Dashboard search results logic', () => { ) await searchResults.processEvent('dropPage', { - pageId: page.normalizedUrl, + pageResultId: page.normalizedUrl, day: PAGE_SEARCH_DUMMY_DAY, }) @@ -487,7 +487,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('updatePageNotesShareInfo', { day, - pageId, + pageResultId: pageId, shareStates: makeNewShareStates(notesById, { isShared: false, }), @@ -505,7 +505,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('updatePageNotesShareInfo', { day, - pageId, + pageResultId: pageId, shareStates: makeNewShareStates(notesById, { isShared: true, }), @@ -524,7 +524,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('updatePageNotesShareInfo', { day, - pageId, + pageResultId: pageId, shareStates: makeNewShareStates(notesById, { isShared: false, isBulkShareProtected: true, @@ -545,7 +545,7 @@ describe('Dashboard search results logic', () => { // NOTE: Now that they're all protected, the next call shouldn't change anything await searchResults.processEvent('updatePageNotesShareInfo', { day, - pageId, + pageResultId: pageId, shareStates: makeNewShareStates(notesById, { isShared: false, isBulkShareProtected: false, @@ -714,7 +714,7 @@ describe('Dashboard search results logic', () => { ).toBe(false) await searchResults.processEvent('setPageTagPickerShown', { day, - pageId, + pageResultId: pageId, isShown: true, }) expect( @@ -724,7 +724,7 @@ describe('Dashboard search results logic', () => { ).toBe(true) await searchResults.processEvent('setPageTagPickerShown', { day, - pageId, + pageResultId: pageId, isShown: false, }) expect( @@ -750,7 +750,7 @@ describe('Dashboard search results logic', () => { ).toBe('hide') await searchResults.processEvent('setPageListPickerShown', { day, - pageId, + pageResultId: pageId, show: 'footer', }) expect( @@ -760,7 +760,7 @@ describe('Dashboard search results logic', () => { ).toBe('footer') await searchResults.processEvent('setPageListPickerShown', { day, - pageId, + pageResultId: pageId, show: 'lists-bar', }) expect( @@ -770,7 +770,7 @@ describe('Dashboard search results logic', () => { ).toBe('lists-bar') await searchResults.processEvent('setPageListPickerShown', { day, - pageId, + pageResultId: pageId, show: 'lists-bar', }) expect( @@ -797,7 +797,7 @@ describe('Dashboard search results logic', () => { ).toBe(false) await searchResults.processEvent('setPageShareMenuShown', { day, - pageId, + pageResultId: pageId, isShown: true, }) expect( @@ -807,7 +807,7 @@ describe('Dashboard search results logic', () => { ).toBe(true) await searchResults.processEvent('setPageShareMenuShown', { day, - pageId, + pageResultId: pageId, isShown: false, }) expect( @@ -834,7 +834,7 @@ describe('Dashboard search results logic', () => { ).toEqual(false) await searchResults.processEvent('setPageNotesShown', { day, - pageId, + pageResultId: pageId, areShown: true, }) expect( @@ -847,7 +847,7 @@ describe('Dashboard search results logic', () => { ).toEqual(true) await searchResults.processEvent('setPageNotesShown', { day, - pageId, + pageResultId: pageId, areShown: false, }) expect( @@ -871,10 +871,10 @@ describe('Dashboard search results logic', () => { searchResults.state.searchResults.results[day].pages.byId[ pageId ].notesType, - ).toEqual(utils.getInitialPageResultState('').notesType) + ).toEqual(utils.getInitialPageResultState('', '').notesType) await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'followed', }) expect( @@ -884,7 +884,7 @@ describe('Dashboard search results logic', () => { ).toEqual('followed') await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'search', }) expect( @@ -894,7 +894,7 @@ describe('Dashboard search results logic', () => { ).toEqual('search') await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'user', }) expect( @@ -928,7 +928,7 @@ describe('Dashboard search results logic', () => { for (const hover of states) { await searchResults.processEvent('setPageHover', { day, - pageId, + pageResultId: pageId, hover, }) expect( @@ -955,7 +955,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'followed', }) expect( @@ -966,7 +966,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'search', }) expect( @@ -977,7 +977,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'user', }) expect( @@ -1006,7 +1006,7 @@ describe('Dashboard search results logic', () => { 'setPageNewNoteTagPickerShown', { day, - pageId, + pageResultId: pageId, isShown: true, }, ) @@ -1020,7 +1020,7 @@ describe('Dashboard search results logic', () => { 'setPageNewNoteTagPickerShown', { day, - pageId, + pageResultId: pageId, isShown: false, }, ) @@ -1050,7 +1050,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: newNoteComment, }) @@ -1062,7 +1062,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('cancelPageNewNote', { day, - pageId, + pageResultId: pageId, }) expect( @@ -1089,7 +1089,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: newNoteComment, }) @@ -1106,7 +1106,7 @@ describe('Dashboard search results logic', () => { 'savePageNewNote', { day, - pageId, + pageResultId: pageId, fullPageUrl: 'https://' + pageId, shouldShare: false, }, @@ -1177,7 +1177,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('savePageNewNote', { day, - pageId, + pageResultId: pageId, fullPageUrl: 'https://' + pageId, shouldShare: true, }) @@ -1204,7 +1204,7 @@ describe('Dashboard search results logic', () => { ).toBe(true) await searchResults.processEvent('setPageNotesShown', { day, - pageId, + pageResultId: pageId, areShown: false, }) expect( @@ -1216,7 +1216,7 @@ describe('Dashboard search results logic', () => { ).toBe(false) await searchResults.processEvent('setPageNotesShown', { day, - pageId, + pageResultId: pageId, areShown: true, }) expect( @@ -1238,10 +1238,10 @@ describe('Dashboard search results logic', () => { expect( searchResults.state.searchResults.results[day].pages .byId[pageId].notesType, - ).toEqual(utils.getInitialPageResultState('').notesType) + ).toEqual(utils.getInitialPageResultState('', '').notesType) await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'followed', }) expect( @@ -1250,7 +1250,7 @@ describe('Dashboard search results logic', () => { ).toEqual('followed') await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'search', }) expect( @@ -1259,7 +1259,7 @@ describe('Dashboard search results logic', () => { ).toEqual('search') await searchResults.processEvent('setPageNotesType', { day, - pageId, + pageResultId: pageId, noteType: 'user', }) expect( @@ -1285,7 +1285,7 @@ describe('Dashboard search results logic', () => { 'setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'followed', }, ) @@ -1297,7 +1297,7 @@ describe('Dashboard search results logic', () => { 'setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'search', }, ) @@ -1309,7 +1309,7 @@ describe('Dashboard search results logic', () => { 'setPageNewNoteCommentValue', { day, - pageId, + pageResultId: pageId, value: 'user', }, ) @@ -1361,7 +1361,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('removePageFromList', { day: DATA.DAY_1, - pageId, + pageResultId: pageId, }) expect( @@ -1424,7 +1424,7 @@ describe('Dashboard search results logic', () => { ).toEqual(true) await searchResults.processEvent('setDeletingPageArgs', { - pageId, + pageResultId: pageId, day: DATA.DAY_1, instaDelete: false, }) @@ -3822,7 +3822,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setDeletingNoteArgs', { noteId, - pageId: DATA.PAGE_1.normalizedUrl, + pageResultId: DATA.PAGE_1.normalizedUrl, day: PAGE_SEARCH_DUMMY_DAY, }) expect(searchResults.state.modals.deletingNoteArgs).toEqual({ @@ -3891,7 +3891,7 @@ describe('Dashboard search results logic', () => { await searchResults.processEvent('setDeletingNoteArgs', { noteId, - pageId: DATA.PAGE_1.normalizedUrl, + pageResultId: DATA.PAGE_1.normalizedUrl, day: PAGE_SEARCH_DUMMY_DAY, }) expect(searchResults.state.modals.deletingNoteArgs).toEqual({ diff --git a/src/dashboard-refactor/search-results/types.ts b/src/dashboard-refactor/search-results/types.ts index 19745f08aa..0181f8a90c 100644 --- a/src/dashboard-refactor/search-results/types.ts +++ b/src/dashboard-refactor/search-results/types.ts @@ -197,6 +197,7 @@ export interface NoteResult { export interface PageResult { pageId: string + pageResultId: string notesType: NotesType areNotesShown: boolean activePage: boolean @@ -266,7 +267,7 @@ export interface RootState { } export interface PageEventArgs { - pageId: string + pageResultId: string day: number } diff --git a/src/dashboard-refactor/search-results/util.ts b/src/dashboard-refactor/search-results/util.ts index 93ca88f10e..0a97ab1891 100644 --- a/src/dashboard-refactor/search-results/util.ts +++ b/src/dashboard-refactor/search-results/util.ts @@ -102,9 +102,11 @@ export const bindFunctionalProps = < export const getInitialPageResultState = ( pageId: string, + pageResultId: string, noteIds: string[] = [], ): PageResult => ({ pageId, + pageResultId, notesType: 'user', activePage: undefined, areNotesShown: false, @@ -226,7 +228,11 @@ export const pageSearchResultToState = ( const noteIds = sortedAnnots.map((a) => a.url) pageData.byId[pageId] = pageResultToPageData(pageResult, cache) - pageResults.byId[resultId] = getInitialPageResultState(pageId, noteIds) + pageResults.byId[resultId] = getInitialPageResultState( + pageId, + resultId, + noteIds, + ) pageData.allIds.push(pageId) pageResults.allIds.push(resultId) From b81ae84108af33525e965b8c8f876ace4fc68893 Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Thu, 2 May 2024 16:05:22 +0700 Subject: [PATCH 07/12] Get saving new notes on page results working --- src/dashboard-refactor/index.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index a2d311fe1b..ece4a117fe 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1268,15 +1268,22 @@ export class DashboardContainer extends StatefulUIElement< ), }) }, - onSave: (day, pageId) => (shouldShare, isProtected) => - this.processEvent('savePageNewNote', { + onSave: (day, pageResultId) => async ( + shouldShare, + isProtected, + ) => { + const pageResult = + searchResults.results[-1].pages.byId[pageResultId] + await this.processEvent('savePageNewNote', { day, - pageResultId: pageId, + pageResultId: pageResultId, isProtected, shouldShare, fullPageUrl: - searchResults.pageData.byId[pageId].fullUrl, - }), + searchResults.pageData.byId[pageResult.pageId] + .fullUrl, + }) + }, addNewSpaceViaWikiLinksNewNote: (day, pageId) => ( spaceName: string, ) => { From e0ceb2011e37611979435c405fc62a8bd892e3ad Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Fri, 3 May 2024 15:29:28 +0700 Subject: [PATCH 08/12] Update page note result event handlers to use result ID not page ID --- src/dashboard-refactor/index.tsx | 6 ++++-- src/dashboard-refactor/search-results/index.tsx | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index ece4a117fe..10fa775dd8 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -1421,10 +1421,12 @@ export class DashboardContainer extends StatefulUIElement< }, ) }, - onTrashBtnClick: (noteId, day, pageId) => (instaDelete) => + onTrashBtnClick: (noteId, day, pageResultId) => ( + instaDelete, + ) => this.processEvent('setDeletingNoteArgs', { noteId, - pageResultId: pageId, + pageResultId, day, }), onCommentChange: (noteId) => (event) => { diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index 4ff4705710..c9786db214 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -335,15 +335,15 @@ export default class SearchResultsContainer extends React.Component< private renderNoteResult = ( day: number, - pageId: string, + pageResultId: string, zIndex: number, ) => (noteId: string) => { - const pageData = this.props.pageData.byId[pageId] + const pageData = this.props.pageData.byId[pageResultId] const noteData = this.props.noteData.byId[noteId] const interactionProps = bindFunctionalProps< NoteInteractionAugdProps, NoteInteractionProps - >(this.props.noteInteractionProps, noteId, day, pageId) + >(this.props.noteInteractionProps, noteId, day, pageResultId) const dummyEvent = {} as any @@ -473,7 +473,7 @@ export default class SearchResultsContainer extends React.Component< }, }) } - normalizedPageUrlToFilterPageLinksBy={pageId} + normalizedPageUrlToFilterPageLinksBy={pageResultId} analyticsBG={this.props.spacePickerBGProps.analyticsBG} /> )} @@ -495,7 +495,7 @@ export default class SearchResultsContainer extends React.Component< postShareHook={interactionProps.updateShareInfo} spacePickerProps={{ ...this.props.spacePickerBGProps, - normalizedPageUrlToFilterPageLinksBy: pageId, + normalizedPageUrlToFilterPageLinksBy: pageResultId, annotationsCache: this.props.annotationsCache, initialSelectedListIds: () => localListIds, selectEntry: (listId, options) => @@ -674,7 +674,7 @@ export default class SearchResultsContainer extends React.Component< return this.renderNoteResult( day, - normalizedUrl, + pageResultId, zIndex, )(noteId) })} From 8280d9772df4500a2a8be564364a99ed0dbb9c2a Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Mon, 6 May 2024 13:41:17 +0700 Subject: [PATCH 09/12] Fix bug merging page ID->result IDs reverse index --- src/dashboard-refactor/logic.ts | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index 38926bd6c3..71eb13d4fd 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -1272,6 +1272,29 @@ export class DashboardLogic extends UILogic { return } + // Merge page ID -> result IDs indices, if we're paginating + let nextPageIdToResultIds: State['searchResults']['pageIdToResultIds'] = {} + if (event?.paginate) { + const allPageIds = new Set([ + ...Object.keys(pageIdToResultIds), + ...Object.keys( + previousState.searchResults.pageIdToResultIds, + ), + ]) + for (const pageId of allPageIds) { + const next = pageIdToResultIds[pageId] ?? [] + const prev = + previousState.searchResults.pageIdToResultIds[ + pageId + ] ?? [] + nextPageIdToResultIds[pageId] = [ + ...new Set([...prev, ...next]), + ] + } + } else { + nextPageIdToResultIds = pageIdToResultIds + } + this.emitMutation({ searchFilters: mutation.searchFilters, searchResults: { @@ -1284,6 +1307,7 @@ export class DashboardLogic extends UILogic { searchState: { $set: 'success' }, searchPaginationState: { $set: 'success' }, noResultsType: { $set: noResultsType }, + pageIdToResultIds: { $set: nextPageIdToResultIds }, ...(event?.paginate ? { results: { @@ -1307,17 +1331,11 @@ export class DashboardLogic extends UILogic { noteData, ), }, - pageIdToResultIds: { - $merge: pageIdToResultIds, - }, } : { results: { $set: results }, pageData: { $set: pageData }, noteData: { $set: noteData }, - pageIdToResultIds: { - $set: pageIdToResultIds, - }, }), }, }) From a4d26ef971e05ab2515f7ad5792fee63822b06fc Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Mon, 6 May 2024 13:42:30 +0700 Subject: [PATCH 10/12] Get page deletes working --- src/dashboard-refactor/index.tsx | 2 +- src/dashboard-refactor/logic.ts | 48 ++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/dashboard-refactor/index.tsx b/src/dashboard-refactor/index.tsx index 10fa775dd8..ea98ef0671 100644 --- a/src/dashboard-refactor/index.tsx +++ b/src/dashboard-refactor/index.tsx @@ -905,7 +905,7 @@ export class DashboardContainer extends StatefulUIElement< isShown: !searchResults.isSortMenuShown, }) } - searchResults={searchResults.pageData} + searchResults={searchResults.pageData} // TODO: Why is this being passed down multiple times? searchFilters={searchFilters} searchQuery={searchFilters.searchQuery} isDisplayed={searchFilters.searchFiltersOpen} diff --git a/src/dashboard-refactor/logic.ts b/src/dashboard-refactor/logic.ts index 71eb13d4fd..7923b596d5 100644 --- a/src/dashboard-refactor/logic.ts +++ b/src/dashboard-refactor/logic.ts @@ -1916,19 +1916,17 @@ export class DashboardLogic extends UILogic { } confirmPageDelete: EventHandler<'confirmPageDelete'> = async ({ - previousState: { - searchResults: { pageData, results }, - modals, - }, + previousState: { searchResults, modals }, }) => { if (!modals.deletingPageArgs) { throw new Error('No page ID is set for deletion') } - const { pageResultId: pageId, day } = modals.deletingPageArgs + const { pageResultId, day } = modals.deletingPageArgs - const pageLists = pageData.byId[pageId].lists - const isPageInInbox = pageLists.some( + const pageResult = searchResults.results[-1].pages.byId[pageResultId] + const pageData = searchResults.pageData.byId[pageResult.pageId] + const isPageInInbox = pageData.lists.some( (listId) => this.options.annotationsCache.lists.byId[listId].localId === SPECIAL_LIST_IDS.INBOX, @@ -1949,31 +1947,39 @@ export class DashboardLogic extends UILogic { async () => { const resultsMutation: UIMutation = { pageData: { - byId: { $unset: [pageId] }, + byId: { $unset: [pageResult.pageId] }, allIds: { - $set: pageData.allIds.filter((id) => id !== pageId), + $set: searchResults.pageData.allIds.filter( + (id) => id !== pageResult.pageId, + ), }, }, } + const pageResultIds = + searchResults.pageIdToResultIds[pageResult.pageId] + if (day === PAGE_SEARCH_DUMMY_DAY) { resultsMutation.results = { [day]: { pages: { - byId: { $unset: [pageId] }, + byId: { $unset: pageResultIds }, allIds: { - $set: results[day].pages.allIds.filter( - (id) => id !== pageId, + $set: searchResults.results[ + day + ].pages.allIds.filter( + (id) => !pageResultIds.includes(id), ), }, }, }, } - } else { - resultsMutation.results = removeAllResultOccurrencesOfPage( - results, - pageId, - ) + // TODO: Add support for other pages if we add them back in + // } else { + // resultsMutation.results = removeAllResultOccurrencesOfPage( + // results, + // pageId, + // ) } this.emitMutation({ @@ -1982,7 +1988,7 @@ export class DashboardLogic extends UILogic { deletingPageArgs: { $set: undefined }, }, }) - await this.options.searchBG.delPages([pageId]) + await this.options.searchBG.delPages([pageResult.pageId]) }, ) } @@ -2930,8 +2936,8 @@ export class DashboardLogic extends UILogic { throw new Error('No note ID is set for deletion') } - const { noteId, pageResultId: pageId, day } = modals.deletingNoteArgs - const pageResult = searchResults.results[day].pages.byId[pageId] + const { noteId, pageResultId, day } = modals.deletingNoteArgs + const pageResult = searchResults.results[day].pages.byId[pageResultId] const pageResultNoteIds = pageResult.noteIds[ pageResult.notesType ].filter((id) => id !== noteId) @@ -2956,7 +2962,7 @@ export class DashboardLogic extends UILogic { [day]: { pages: { byId: { - [pageId]: { + [pageResultId]: { noteIds: { [pageResult.notesType]: { $set: pageResultNoteIds, From 38ede7f0361a6bf7c8c3bc0a9b8e8d8a95fe6266 Mon Sep 17 00:00:00 2001 From: Jonathan Poltak Samosir Date: Mon, 6 May 2024 13:48:43 +0700 Subject: [PATCH 11/12] Fix page data being ref'd via page result ID --- src/dashboard-refactor/search-results/index.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dashboard-refactor/search-results/index.tsx b/src/dashboard-refactor/search-results/index.tsx index c9786db214..e52b162f99 100644 --- a/src/dashboard-refactor/search-results/index.tsx +++ b/src/dashboard-refactor/search-results/index.tsx @@ -338,7 +338,8 @@ export default class SearchResultsContainer extends React.Component< pageResultId: string, zIndex: number, ) => (noteId: string) => { - const pageData = this.props.pageData.byId[pageResultId] + const pageResult = this.props.results[-1].pages.byId[pageResultId] + const pageData = this.props.pageData.byId[pageResult.pageId] const noteData = this.props.noteData.byId[noteId] const interactionProps = bindFunctionalProps< NoteInteractionAugdProps, @@ -350,10 +351,9 @@ export default class SearchResultsContainer extends React.Component< const cachedListIds = noteData.isShared ? [ ...new Set([ - ...pageData?.lists?.filter( + ...pageData.lists.filter( (listId) => - this.props.listData.byId[listId]?.remoteId != - null, + this.props.listData.byId[listId].remoteId != null, ), ...noteData.lists, ]), From bc6e1a2fb1cdc114b026ad2eb92645375f9f7590 Mon Sep 17 00:00:00 2001 From: Oliver Sauter Date: Tue, 7 May 2024 09:10:45 +0200 Subject: [PATCH 12/12] update memex-common to master --- external/@worldbrain/memex-common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/external/@worldbrain/memex-common b/external/@worldbrain/memex-common index 4c0a2e438f..a516fa998b 160000 --- a/external/@worldbrain/memex-common +++ b/external/@worldbrain/memex-common @@ -1 +1 @@ -Subproject commit 4c0a2e438f1c0fc87a2a1313e2020dc7eac50cef +Subproject commit a516fa998b3ce91499ebec5449872cd6f01558df