Skip to content

Commit

Permalink
add types and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rjmacarthy committed Apr 18, 2024
1 parent 860c4fe commit c10df6a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/webview/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useRef, useState } from 'react'

import {
VSCodeButton,
VSCodeTextArea,
VSCodePanelView,
VSCodeProgressRing,
VSCodeBadge
Expand Down Expand Up @@ -60,8 +59,7 @@ export const Chat = () => {
const { conversation, saveLastConversation, setActiveConversation } =
useConversationHistory()

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chatRef = useRef<any>(null) // TODO: type...
const chatRef = useRef<HTMLTextAreaElement>(null)
useAutosizeTextArea(chatRef, inputText)

const scrollBottom = () => {
Expand Down
7 changes: 5 additions & 2 deletions src/webview/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,12 @@ export const useOllamaModels = () => {
return { models }
}

const useAutosizeTextArea = (chatRef: any, value: string) => {
const useAutosizeTextArea = (
chatRef: React.RefObject<HTMLTextAreaElement> | null,
value: string
) => {
useEffect(() => {
if (chatRef) {
if (chatRef?.current) {
chatRef.current.style.height = '0px'
const scrollHeight = chatRef.current.scrollHeight
chatRef.current.style.height = `${scrollHeight + 5}px`
Expand Down

0 comments on commit c10df6a

Please sign in to comment.