feat: added the ability to tail the logs on the LogViewer

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2023-01-30 16:04:55 +01:00
parent 5cc6278ddc
commit c230ae7920
2 changed files with 11 additions and 0 deletions
@@ -39,6 +39,10 @@ export interface LogViewerProps {
classes?: {
root?: string;
};
/**
* Whether the LogViewer should automatically scroll to the bottom of the log.
*/
tail?: boolean;
}
/**
@@ -32,6 +32,7 @@ import { useLogViewerSelection } from './useLogViewerSelection';
export interface RealLogViewerProps {
text: string;
classes?: { root?: string };
tail?: boolean;
}
export function RealLogViewer(props: RealLogViewerProps) {
@@ -52,6 +53,12 @@ export function RealLogViewer(props: RealLogViewerProps) {
}
}, [search.resultLine]);
useEffect(() => {
if (props.tail && listRef.current) {
listRef.current.scrollToItem(lines.length - 1, 'center');
}
}, [lines.length, props.tail]);
useEffect(() => {
if (location.hash) {
// #line-6 -> 6