feat: add current feed block
This commit is contained in:
parent
48e84ca209
commit
5cb2a2647e
|
|
@ -15,7 +15,7 @@ import {
|
|||
|
||||
import { EntryTitle, FeedTitle } from "./TitleComponents"
|
||||
|
||||
const blockTypeCanNotBeRemoved = new Set(["mainEntry", "mainView"])
|
||||
const blockTypeCanNotBeRemoved = new Set(["mainEntry", "mainFeed", "mainView"])
|
||||
|
||||
export const ContextBlock: FC<{ block: AIChatContextBlock }> = memo(({ block }) => {
|
||||
const { t } = useTranslation("common")
|
||||
|
|
@ -33,6 +33,7 @@ export const ContextBlock: FC<{ block: AIChatContextBlock }> = memo(({ block })
|
|||
case "referEntry": {
|
||||
return "i-mgc-paper-cute-fi"
|
||||
}
|
||||
case "mainFeed":
|
||||
case "referFeed": {
|
||||
return "i-mgc-rss-cute-fi"
|
||||
}
|
||||
|
|
@ -67,6 +68,7 @@ export const ContextBlock: FC<{ block: AIChatContextBlock }> = memo(({ block })
|
|||
case "referEntry": {
|
||||
return <EntryTitle entryId={block.value} fallback={block.value} />
|
||||
}
|
||||
case "mainFeed":
|
||||
case "referFeed": {
|
||||
return <FeedTitle feedId={block.value} fallback={block.value} />
|
||||
}
|
||||
|
|
@ -164,6 +166,9 @@ export const ContextBlock: FC<{ block: AIChatContextBlock }> = memo(({ block })
|
|||
case "mainEntry": {
|
||||
return "Current"
|
||||
}
|
||||
case "mainFeed": {
|
||||
return "Current"
|
||||
}
|
||||
case "referEntry": {
|
||||
return "Ref"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,9 @@ export const AIChatContextBar: Component<{ onSendShortcut?: (prompt: string) =>
|
|||
fileInputRef.current?.click()
|
||||
}, [])
|
||||
|
||||
const view = useRouteParamsSelector((i) => i.view)
|
||||
const { addOrUpdateBlock, removeBlock } = useBlockActions()
|
||||
const view = useRouteParamsSelector((i) => i.view)
|
||||
const feedId = useRouteParamsSelector((i) => i.feedId)
|
||||
useEffect(() => {
|
||||
addOrUpdateBlock({
|
||||
id: BlockSliceAction.SPECIAL_TYPES.mainView,
|
||||
|
|
@ -43,6 +44,21 @@ export const AIChatContextBar: Component<{ onSendShortcut?: (prompt: string) =>
|
|||
}
|
||||
}, [addOrUpdateBlock, view, removeBlock])
|
||||
|
||||
useEffect(() => {
|
||||
if (feedId) {
|
||||
addOrUpdateBlock({
|
||||
id: BlockSliceAction.SPECIAL_TYPES.mainFeed,
|
||||
type: "mainFeed",
|
||||
value: feedId,
|
||||
})
|
||||
} else {
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.mainFeed)
|
||||
}
|
||||
return () => {
|
||||
removeBlock(BlockSliceAction.SPECIAL_TYPES.mainFeed)
|
||||
}
|
||||
}, [addOrUpdateBlock, feedId, removeBlock])
|
||||
|
||||
return (
|
||||
<div className={cn("flex flex-wrap items-center gap-2 px-4 py-3", className)}>
|
||||
{/* Add Context Button */}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ const getDisplayContent = (block: AIChatContextBlock): React.ReactNode => {
|
|||
case "referEntry": {
|
||||
return <EntryTitle entryId={block.value} fallback={block.value} />
|
||||
}
|
||||
case "mainFeed":
|
||||
case "referFeed": {
|
||||
return <FeedTitle feedId={block.value} fallback={block.value} />
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ export const BLOCK_STYLES = {
|
|||
icon: "bg-orange/10 text-orange",
|
||||
label: "text-orange",
|
||||
},
|
||||
mainFeed: {
|
||||
container: "from-orange/5 to-orange/10 border-orange/20 hover:border-orange/30",
|
||||
icon: "bg-orange/10 text-orange",
|
||||
label: "text-orange",
|
||||
},
|
||||
referEntry: {
|
||||
container: "from-blue/5 to-blue/10 border-blue/20 hover:border-blue/30",
|
||||
icon: "bg-blue/10 text-blue",
|
||||
|
|
@ -51,6 +56,7 @@ export const DEFAULT_BLOCK_STYLES = {
|
|||
*/
|
||||
export const BLOCK_ICONS = {
|
||||
mainEntry: "i-mgc-star-cute-fi",
|
||||
mainFeed: "i-mgc-rss-cute-fi",
|
||||
referEntry: "i-mgc-paper-cute-fi",
|
||||
referFeed: "i-mgc-rss-cute-fi",
|
||||
selectedText: "i-mgc-quill-pen-cute-re",
|
||||
|
|
@ -62,6 +68,7 @@ export const BLOCK_ICONS = {
|
|||
*/
|
||||
export const BLOCK_LABELS = {
|
||||
mainEntry: "Current",
|
||||
mainFeed: "Current",
|
||||
referEntry: "Ref",
|
||||
referFeed: "Feed",
|
||||
selectedText: "Text",
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ export class BlockSliceAction {
|
|||
static SPECIAL_TYPES = {
|
||||
mainView: "mainView",
|
||||
mainEntry: "mainEntry",
|
||||
mainFeed: "mainFeed",
|
||||
selectedText: "selectedText",
|
||||
}
|
||||
get set() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ interface BaseContextBlock {
|
|||
}
|
||||
|
||||
export interface ValueContextBlock extends BaseContextBlock {
|
||||
type: "mainView" | "mainEntry" | "referEntry" | "referFeed" | "selectedText"
|
||||
type: "mainView" | "mainEntry" | "mainFeed" | "referEntry" | "referFeed" | "selectedText"
|
||||
value: string
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue