-
-
Notifications
You must be signed in to change notification settings - Fork 804
quick refactor on viewmodels and components to make them more uniform #1945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -249,27 +249,67 @@ declare global { | |||||||||
| wholeWord?: PrimitiveAtom<boolean>; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| declare type ViewComponentProps<T extends ViewModel> = { | ||||||||||
| blockId: string; | ||||||||||
| blockRef: React.RefObject<HTMLDivElement>; | ||||||||||
| contentRef: React.RefObject<HTMLDivElement>; | ||||||||||
| model: T; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| declare type ViewComponent = React.FC<ViewComponentProps>; | ||||||||||
|
|
||||||||||
| type ViewModelClass = new (blockId: string, nodeModel: BlockNodeModel) => ViewModel; | ||||||||||
|
|
||||||||||
| interface ViewModel { | ||||||||||
| // The type of view, used for identifying and rendering the appropriate component. | ||||||||||
| viewType: string; | ||||||||||
|
|
||||||||||
| // Icon representing the view, can be a string or an IconButton declaration. | ||||||||||
| viewIcon?: jotai.Atom<string | IconButtonDecl>; | ||||||||||
|
|
||||||||||
| // Display name for the view, used in UI headers. | ||||||||||
| viewName?: jotai.Atom<string>; | ||||||||||
|
|
||||||||||
| // Optional header text or elements for the view. | ||||||||||
| viewText?: jotai.Atom<string | HeaderElem[]>; | ||||||||||
|
|
||||||||||
| // Icon button displayed before the title in the header. | ||||||||||
| preIconButton?: jotai.Atom<IconButtonDecl>; | ||||||||||
|
|
||||||||||
| // Icon buttons displayed at the end of the block header. | ||||||||||
| endIconButtons?: jotai.Atom<IconButtonDecl[]>; | ||||||||||
|
|
||||||||||
| // Background styling metadata for the block. | ||||||||||
| blockBg?: jotai.Atom<MetaType>; | ||||||||||
|
|
||||||||||
| // Whether the block manages its own connection (e.g., for remote access). | ||||||||||
| manageConnection?: jotai.Atom<boolean>; | ||||||||||
| noPadding?: jotai.Atom<boolean>; | ||||||||||
|
|
||||||||||
| // If true, filters out 'nowsh' connections (when managing connections) | ||||||||||
| filterOutNowsh?: jotai.Atom<boolean>; | ||||||||||
|
|
||||||||||
| // If true, removes padding inside the block content area. | ||||||||||
| noPadding?: jotai.Atom<boolean>; | ||||||||||
|
|
||||||||||
| // Atoms used for managing search functionality within the block. | ||||||||||
| searchAtoms?: SearchAtoms; | ||||||||||
|
|
||||||||||
| // just for terminal | ||||||||||
| // The main view component associated with this ViewModel. | ||||||||||
| viewComponent: ViewComponent<ViewModel>; | ||||||||||
|
|
||||||||||
|
Comment on lines
+297
to
+299
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Fix the type of The - viewComponent: ViewComponent<ViewModel>;
+ viewComponent: ViewComponent<this>;📝 Committable suggestion
Suggested change
|
||||||||||
| // Function to determine if this is a basic terminal block. | ||||||||||
| isBasicTerm?: (getFn: jotai.Getter) => boolean; | ||||||||||
|
|
||||||||||
| onBack?: () => void; | ||||||||||
| onForward?: () => void; | ||||||||||
| // Returns menu items for the settings dropdown. | ||||||||||
| getSettingsMenuItems?: () => ContextMenuItem[]; | ||||||||||
|
|
||||||||||
| // Attempts to give focus to the block, returning true if successful. | ||||||||||
| giveFocus?: () => boolean; | ||||||||||
|
|
||||||||||
| // Handles keydown events within the block. | ||||||||||
| keyDownHandler?: (e: WaveKeyboardEvent) => boolean; | ||||||||||
|
|
||||||||||
| // Cleans up resources when the block is disposed. | ||||||||||
| dispose?: () => void; | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify the usage of contentRef prop.
The
contentRefprop is added to the interface but appears to be unused in the WebView component implementation.🏁 Script executed:
Length of output: 293
Content Reference Prop Issue in WebView Component
contentRefproperty is declared in theWebViewPropsinterface but is not deconstructed or used in theWebViewcomponent.{ model, onFailLoad, blockRef }, confirming thatcontentRefis currently unused.