Skip to content

Commit

Permalink
finish title edit
Browse files Browse the repository at this point in the history
  • Loading branch information
blackforestboi committed Feb 15, 2024
1 parent 18ae3c1 commit bda1df0
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion external/@worldbrain/memex-common
1 change: 0 additions & 1 deletion src/copy-paster/background/template-data-fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ async function convertHTMLintoMarkdown(inputHtml, imageSupport) {
codeBlockStyle: 'fenced',
})
const markdown = turndownService.turndown(html)
console.log('markdown', markdown)
return markdown
} else {
return
Expand Down
9 changes: 9 additions & 0 deletions src/dashboard-refactor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -979,6 +979,15 @@ export class DashboardContainer extends StatefulUIElement<
pageId,
shareStates,
}),
onEditPageBtnClick: (day, pageId) => (
normalizedPageUrl,
changedTitle,
) => {
this.processEvent('updatePageTitle', {
normalizedPageUrl,
changedTitle,
})
},
}}
pagePickerProps={{
onListPickerUpdate: (pageId) => (args) =>
Expand Down
1 change: 1 addition & 0 deletions src/dashboard-refactor/lists-sidebar/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export type Events = UIEvent<{
setListPrivacy: { listId: string; isPrivate: boolean }
confirmListEdit: { value: string; listId: string; skipDBOps?: boolean }
cancelListEdit: null
updatePageTitle: { normalizedPageUrl: string; changedTitle: string }
setDragOverListId: { listId?: string }
setEditingListId: { listId: string }
setSelectedListId: { listId: string }
Expand Down
21 changes: 21 additions & 0 deletions src/dashboard-refactor/logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,27 @@ export class DashboardLogic extends UILogic<State, Events> {
})
}

updatePageTitle: EventHandler<'updatePageTitle'> = async ({
event,
previousState,
}) => {
this.emitMutation({
searchResults: {
pageData: {
byId: {
[event.normalizedPageUrl]: {
fullTitle: { $set: event.changedTitle },
},
},
},
},
})
this.options.pageIndexingBG.updatePageTitle({
normaliedPageUrl: event.normalizedPageUrl,
title: event.changedTitle,
})
}

setDragOverListId: EventHandler<'setDragOverListId'> = async ({
event,
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ export default class PageResultView extends PureComponent<Props> {
}
memexIcon={MemexIcon}
getRootElement={this.props.getRootElement}
onEditPageBtnClick={(changedTitle) => {
this.props.onEditPageBtnClick(
this.props.normalizedUrl,
changedTitle,
)
}}
/>
</PageContentBox>
{this.displayLists.length > 0 && (
Expand Down
4 changes: 4 additions & 0 deletions src/dashboard-refactor/search-results/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export type Props = RootState &
getHighlightColorSettings?: () => void
highlightColorSettings: string
getRootElement: () => HTMLElement
// onEditPageBtnClick: (
// normalizedPageUrl: string,
// changedTitle: string,
// ) => void
}

export interface State {
Expand Down
1 change: 1 addition & 0 deletions src/dashboard-refactor/search-results/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type PageInteractionProps = Omit<
onListsHover: React.MouseEventHandler
onUnhover: React.MouseEventHandler
onClick: React.MouseEventHandler
onEditPageBtnClick: (normalizedPageUrl, changedTitle) => void
}

// NOTE: Derived type - edit the original
Expand Down

0 comments on commit bda1df0

Please sign in to comment.