Skip to content

Commit ed1e55d

Browse files
committed
Fix broken "remove page from list" functionality in dashboard
1 parent 11b681a commit ed1e55d

File tree

2 files changed

+27
-40
lines changed

2 files changed

+27
-40
lines changed

src/dashboard-refactor/logic.ts

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,36 +1864,31 @@ export class DashboardLogic extends UILogic<State, Events> {
18641864
},
18651865
})
18661866

1867-
const listData = getListData(
1867+
let listData = getListData(
18681868
previousState.listsSidebar.selectedListId,
18691869
previousState,
18701870
{ mustBeLocal: true, source: 'removePageFromList' },
18711871
)
1872-
const filterOutPage = (ids: string[]) =>
1873-
ids.filter((id) => id !== event.pageResultId)
1874-
1875-
const mutation: UIMutation<State['searchResults']> = {
1876-
pageData: {
1877-
byId: { $unset: [event.pageResultId] },
1878-
allIds: {
1879-
$set: filterOutPage(
1880-
previousState.searchResults.pageData.allIds,
1881-
),
1882-
},
1883-
},
1872+
let resultItem =
1873+
previousState.searchResults.results[event.day]?.pages.byId[
1874+
event.pageResultId
1875+
]
1876+
if (!resultItem) {
1877+
throw new Error(
1878+
`Page to remove from list not found in UI results state: ${event.pageResultId}`,
1879+
)
18841880
}
18851881

1882+
let mutation: UIMutation<State['searchResults']> = {}
1883+
18861884
if (event.day === PAGE_SEARCH_DUMMY_DAY) {
18871885
mutation.results = {
18881886
[PAGE_SEARCH_DUMMY_DAY]: {
18891887
pages: {
18901888
byId: { $unset: [event.pageResultId] },
18911889
allIds: {
1892-
$set: filterOutPage(
1893-
previousState.searchResults.results[
1894-
PAGE_SEARCH_DUMMY_DAY
1895-
]?.pages.allIds,
1896-
),
1890+
$apply: (ids: string[]) =>
1891+
ids.filter((id) => id !== event.pageResultId),
18971892
},
18981893
},
18991894
},
@@ -1916,7 +1911,7 @@ export class DashboardLogic extends UILogic<State, Events> {
19161911

19171912
await this.options.listsBG.removePageFromList({
19181913
id: listData.localId,
1919-
url: event.pageResultId,
1914+
url: resultItem.pageId,
19201915
})
19211916
}
19221917

src/dashboard-refactor/search-results/components/page-result.tsx

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -437,23 +437,16 @@ export default class PageResultView extends PureComponent<Props> {
437437
return (
438438
<TooltipBox
439439
tooltipText={
440-
this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX ? (
441-
<span>
442-
Remove from Inbox
443-
<br />
444-
<strong>+ shift + Click</strong> or{' '}
445-
<strong>+ shift + Backspace</strong> to remove
446-
without confirmation
447-
</span>
448-
) : (
449-
<span>
450-
Remove from Space
451-
<br />
452-
<strong>+ shift + Click</strong> or{' '}
453-
<strong>+ shift + Backspace</strong> to remove
454-
without confirmation
455-
</span>
456-
)
440+
<span>
441+
Remove from{' '}
442+
{this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX
443+
? 'Inbox'
444+
: 'Space'}
445+
<br />
446+
<strong>+ shift + Click</strong> or{' '}
447+
<strong>+ shift + Backspace</strong> to remove without
448+
confirmation
449+
</span>
457450
}
458451
placement="bottom"
459452
getPortalRoot={this.props.getRootElement}
@@ -1000,8 +993,8 @@ export default class PageResultView extends PureComponent<Props> {
1000993
tabIndex={-1}
1001994
hasSpaces={this.displayLists.length > 0}
1002995
>
1003-
{this.props.hoverState != null ||
1004-
this.props.isBulkSelected ? (
996+
{(this.props.hoverState != null ||
997+
this.props.isBulkSelected) && (
1005998
<PageActionBox inPageMode={this.props.inPageMode}>
1006999
{this.props.hoverState != null && (
10071000
<ExtraButtonsActionBar>
@@ -1014,8 +1007,7 @@ export default class PageResultView extends PureComponent<Props> {
10141007

10151008
{this.renderBulkSelectBtn()}
10161009
</PageActionBox>
1017-
) : undefined}
1018-
1010+
)}
10191011
<BlockContent
10201012
type={this.props.type}
10211013
normalizedUrl={this.props.normalizedUrl}

0 commit comments

Comments
 (0)