Skip to content

Commit

Permalink
Fix broken "remove page from list" functionality in dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
poltak committed Jun 18, 2024
1 parent 11b681a commit ed1e55d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 40 deletions.
33 changes: 14 additions & 19 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1864,36 +1864,31 @@ export class DashboardLogic extends UILogic<State, Events> {
},
})

const listData = getListData(
let listData = getListData(
previousState.listsSidebar.selectedListId,
previousState,
{ mustBeLocal: true, source: 'removePageFromList' },
)
const filterOutPage = (ids: string[]) =>
ids.filter((id) => id !== event.pageResultId)

const mutation: UIMutation<State['searchResults']> = {
pageData: {
byId: { $unset: [event.pageResultId] },
allIds: {
$set: filterOutPage(
previousState.searchResults.pageData.allIds,
),
},
},
let resultItem =
previousState.searchResults.results[event.day]?.pages.byId[
event.pageResultId
]
if (!resultItem) {
throw new Error(
`Page to remove from list not found in UI results state: ${event.pageResultId}`,
)
}

let mutation: UIMutation<State['searchResults']> = {}

if (event.day === PAGE_SEARCH_DUMMY_DAY) {
mutation.results = {
[PAGE_SEARCH_DUMMY_DAY]: {
pages: {
byId: { $unset: [event.pageResultId] },
allIds: {
$set: filterOutPage(
previousState.searchResults.results[
PAGE_SEARCH_DUMMY_DAY
]?.pages.allIds,
),
$apply: (ids: string[]) =>
ids.filter((id) => id !== event.pageResultId),
},
},
},
Expand All @@ -1916,7 +1911,7 @@ export class DashboardLogic extends UILogic<State, Events> {

await this.options.listsBG.removePageFromList({
id: listData.localId,
url: event.pageResultId,
url: resultItem.pageId,
})
}

Expand Down
34 changes: 13 additions & 21 deletions src/dashboard-refactor/search-results/components/page-result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -437,23 +437,16 @@ export default class PageResultView extends PureComponent<Props> {
return (
<TooltipBox
tooltipText={
this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX ? (
<span>
Remove from Inbox
<br />
<strong>+ shift + Click</strong> or{' '}
<strong>+ shift + Backspace</strong> to remove
without confirmation
</span>
) : (
<span>
Remove from Space
<br />
<strong>+ shift + Click</strong> or{' '}
<strong>+ shift + Backspace</strong> to remove
without confirmation
</span>
)
<span>
Remove from{' '}
{this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX
? 'Inbox'
: 'Space'}
<br />
<strong>+ shift + Click</strong> or{' '}
<strong>+ shift + Backspace</strong> to remove without
confirmation
</span>
}
placement="bottom"
getPortalRoot={this.props.getRootElement}
Expand Down Expand Up @@ -1000,8 +993,8 @@ export default class PageResultView extends PureComponent<Props> {
tabIndex={-1}
hasSpaces={this.displayLists.length > 0}
>
{this.props.hoverState != null ||
this.props.isBulkSelected ? (
{(this.props.hoverState != null ||
this.props.isBulkSelected) && (
<PageActionBox inPageMode={this.props.inPageMode}>
{this.props.hoverState != null && (
<ExtraButtonsActionBar>
Expand All @@ -1014,8 +1007,7 @@ export default class PageResultView extends PureComponent<Props> {

{this.renderBulkSelectBtn()}
</PageActionBox>
) : undefined}

)}
<BlockContent
type={this.props.type}
normalizedUrl={this.props.normalizedUrl}
Expand Down

0 comments on commit ed1e55d

Please sign in to comment.