Skip to content

Commit

Permalink
Merge branch 'hotfix/3.13.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Feb 27, 2024
2 parents dc7bc49 + ec2c6ae commit 1acce0e
Show file tree
Hide file tree
Showing 9 changed files with 199 additions and 34 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "worldbrain-extension",
"version": "3.13.4",
"version": "3.13.5",
"homepage": "https://memex.garden",
"repository": "https://github.com/WorldBrain/Memex",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/annotations/components/AnnotationFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as React from 'react'
export interface AnnotationFooterEventProps {
onDeleteConfirm: React.MouseEventHandler
onDeleteCancel: React.MouseEventHandler
onDeleteIconClick: React.MouseEventHandler
onDeleteIconClick: (instaDelete?: boolean) => void
onEditIconClick: React.MouseEventHandler
onEditHighlightIconClick: React.MouseEventHandler
onShareClick: React.MouseEventHandler
Expand Down
5 changes: 3 additions & 2 deletions src/dashboard-refactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1073,10 +1073,11 @@ export class DashboardContainer extends StatefulUIElement<
].isCopyPasterShown,
event: event,
}),
onTrashBtnClick: (day, pageId) => () =>
onTrashBtnClick: (day, pageId) => (instaDelete) =>
this.processEvent('setDeletingPageArgs', {
day,
pageId,
instaDelete,
}),
onShareBtnClick: (day, pageId) => () =>
this.processEvent('setPageShareMenuShown', {
Expand Down Expand Up @@ -1347,7 +1348,7 @@ export class DashboardContainer extends StatefulUIElement<
},
)
},
onTrashBtnClick: (noteId, day, pageId) => () =>
onTrashBtnClick: (noteId, day, pageId) => (instaDelete) =>
this.processEvent('setDeletingNoteArgs', {
noteId,
pageId,
Expand Down
57 changes: 54 additions & 3 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1573,10 +1573,61 @@ export class DashboardLogic extends UILogic<State, Events> {

setDeletingPageArgs: EventHandler<'setDeletingPageArgs'> = async ({
event,
previousState,
}) => {
this.emitMutation({
modals: { deletingPageArgs: { $set: event } },
})
if (event.instaDelete) {
await executeUITask(
this,
(taskState) => ({
searchResults: { pageDeleteState: { $set: taskState } },
}),
async () => {
const resultsMutation: UIMutation<
State['searchResults']
> = {
pageData: {
byId: { $unset: [event.pageId] },
allIds: {
$set: previousState.searchResults.pageData.allIds.filter(
(id) => id !== event.pageId,
),
},
},
}

if (event.day === PAGE_SEARCH_DUMMY_DAY) {
resultsMutation.results = {
[event.day]: {
pages: {
byId: { $unset: [event.pageId] },
allIds: {
$set: previousState.searchResults.results[
event.day
].pages.allIds.filter(
(id) => id !== event.pageId,
),
},
},
},
}
} else {
resultsMutation.results = removeAllResultOccurrencesOfPage(
previousState.searchResults.results,
event.pageId,
)
}

this.emitMutation({
searchResults: resultsMutation,
})
await this.options.searchBG.delPages([event.pageId])
},
)
} else {
this.emitMutation({
modals: { deletingPageArgs: { $set: event } },
})
}
}

setPrivatizeNoteConfirmArgs: EventHandler<
Expand Down
158 changes: 134 additions & 24 deletions src/dashboard-refactor/search-results/components/page-result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ export default class PageResultView extends PureComponent<Props> {

state = {
matchingTextContainerHeight: 100,
confirmRemoveFromList: false,
showVideoFullSize: false,
}

componentDidMount() {
Expand Down Expand Up @@ -318,6 +320,42 @@ export default class PageResultView extends PureComponent<Props> {
}
}

private renderVideoResizeButton() {
if (!this.props.fullUrl.includes('youtube.com')) {
return
}

return (
<TooltipBox
tooltipText={
this.state.showVideoFullSize
? 'Minimize Video'
: 'Maximize Video'
}
placement="bottom"
getPortalRoot={this.props.getRootElement}
>
<Icon
heightAndWidth="22px"
filePath={
this.state.showVideoFullSize
? icons.compress
: icons.expand
}
onClick={(event) => {
{
this.setState({
showVideoFullSize: !this.state
.showVideoFullSize,
})
event.preventDefault()
}
}}
/>
</TooltipBox>
)
}

private renderRemoveFromListBtn(): JSX.Element {
if (
!this.props.isSearchFilteredByList ||
Expand All @@ -326,23 +364,59 @@ export default class PageResultView extends PureComponent<Props> {
return undefined
}

if (this.state.confirmRemoveFromList) {
return (
<TooltipBox
tooltipText={'Confirm'}
placement="bottom"
getPortalRoot={this.props.getRootElement}
>
<Icon
heightAndWidth="22px"
filePath={icons.check}
onClick={(event) => {
{
this.props.onRemoveFromListBtnClick(event)
this.setState({ confirmRemoveFromList: true })
event.preventDefault()
}
}}
/>
</TooltipBox>
)
}

return (
<TooltipBox
tooltipText={
this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX
? 'Remove from Inbox'
: 'Remove from Space'
this.props.filteredbyListID === SPECIAL_LIST_IDS.INBOX ? (
<span>
Remove from Inbox
<br />
<strong>+ shift</strong> to remove without
confirmation
</span>
) : (
<span>
Remove from Space
<br />
<strong>+ shift</strong> to remove without
confirmation
</span>
)
}
placement="bottom"
getPortalRoot={this.props.getRootElement}
>
<Icon
heightAndWidth="22px"
filePath={icons.removeX}
darkBackground
onClick={(event) => {
{
if (event.shiftKey) {
this.props.onRemoveFromListBtnClick(event)
this.setState({ confirmRemoveFromList: true })
} else {
this.setState({ confirmRemoveFromList: true })
event.preventDefault()
}
}}
Expand Down Expand Up @@ -671,6 +745,56 @@ export default class PageResultView extends PureComponent<Props> {
))
}

private renderDeleteButton() {
return (
<TooltipBox
tooltipText={
<span>
Delete from Memex
<br />
<strong>+ shift</strong>to delete without confirmation
</span>
}
placement="bottom"
getPortalRoot={this.props.getRootElement}
>
<Icon
heightAndWidth="20px"
filePath={icons.trash}
onClick={(event) => {
let instaDelete = false

if (event.shiftKey) {
instaDelete = true
}
this.props.onTrashBtnClick(instaDelete)
}}
/>
</TooltipBox>
)
}

private renderEditButton() {
return (
<TooltipBox
tooltipText={<span>Edit Title</span>}
placement="bottom"
getPortalRoot={this.props.getRootElement}
>
<Icon
heightAndWidth="20px"
filePath={icons.edit}
onClick={() => {
this.props.onEditTitleChange(
this.props.normalizedUrl,
this.props.fullTitle ?? this.props.normalizedUrl,
)
}}
/>
</TooltipBox>
)
}

render() {
const hasTitle = this.props.fullTitle && this.props.fullTitle.length > 0

Expand Down Expand Up @@ -712,24 +836,10 @@ export default class PageResultView extends PureComponent<Props> {
<PageActionBox>
{this.props.hoverState != null && (
<ExtraButtonsActionBar>
{' '}
<Icon
heightAndWidth="20px"
filePath={icons.edit}
onClick={() => {
this.props.onEditTitleChange(
this.props.normalizedUrl,
this.props.fullTitle ??
this.props
.normalizedUrl,
)
}}
/>
<Icon
heightAndWidth="20px"
filePath={icons.trash}
onClick={this.props.onTrashBtnClick}
/>
{this.renderEditButton()}
{this.renderVideoResizeButton()}
{this.renderDeleteButton()}
{this.renderRemoveFromListBtn()}
</ExtraButtonsActionBar>
)}

Expand All @@ -745,9 +855,9 @@ export default class PageResultView extends PureComponent<Props> {
fullTitle={this.props.fullTitle}
pdfUrl={this.props.fullPdfUrl}
favIcon={this.props.favIconURI}
showVideoFullScreen={this.state.showVideoFullSize}
inPageMode={this.props.inPageMode}
youtubeService={this.props.youtubeService}
removeFromList={this.renderRemoveFromListBtn()}
mainContentHover={
this.props.hoverState != null
? this.props.hoverState
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard-refactor/search-results/logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ describe('Dashboard search results logic', () => {
await searchResults.processEvent('setDeletingPageArgs', {
pageId,
day: PAGE_SEARCH_DUMMY_DAY,
instaDelete: false,
})
expect(searchResults.state.modals.deletingPageArgs).toEqual({
pageId,
Expand Down Expand Up @@ -331,6 +332,7 @@ describe('Dashboard search results logic', () => {
await searchResults.processEvent('setDeletingPageArgs', {
pageId,
day: PAGE_SEARCH_DUMMY_DAY,
instaDelete: true,
})
expect(searchResults.state.modals.deletingPageArgs).toEqual({
pageId,
Expand Down Expand Up @@ -1434,6 +1436,7 @@ describe('Dashboard search results logic', () => {
await searchResults.processEvent('setDeletingPageArgs', {
pageId,
day: DATA.DAY_1,
instaDelete: false,
})
expect(searchResults.state.modals.deletingPageArgs).toEqual(
{
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard-refactor/search-results/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface CommonInteractionProps {
onListPickerFooterBtnClick: React.MouseEventHandler

onShareBtnClick: React.MouseEventHandler
onTrashBtnClick: React.MouseEventHandler
onTrashBtnClick: (instaDelete: boolean) => void
}

export type PageInteractionProps = Omit<
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard-refactor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export type DashboardModalsEvents = UIEvent<{
setShowNoteShareOnboardingModal: { isShown: boolean }

setDeletingListId: { listId: string }
setDeletingPageArgs: PageEventArgs
setDeletingPageArgs: PageEventArgs & { instaDelete: boolean }
setDeletingNoteArgs: NoteDataEventArgs
checkSharingAccess: null
setSpaceSidebarWidth: { width: string }
Expand Down

0 comments on commit 1acce0e

Please sign in to comment.