ui: comments etc

This commit is contained in:
nick-delirium 2025-03-19 17:29:50 +01:00 committed by Delirium
parent d9868928be
commit c9c1ad4dde
2 changed files with 5 additions and 11 deletions

View file

@ -298,7 +298,6 @@ function MobileNetworkPanelCont({ panelHeight }: { panelHeight: number }) {
); );
} }
// Custom hook for infinite scrolling
const useInfiniteScroll = (loadMoreCallback: () => void, hasMore: boolean) => { const useInfiniteScroll = (loadMoreCallback: () => void, hasMore: boolean) => {
const observerRef = useRef<IntersectionObserver>(null); const observerRef = useRef<IntersectionObserver>(null);
const loadingRef = useRef<HTMLDivElement>(null); const loadingRef = useRef<HTMLDivElement>(null);
@ -401,7 +400,6 @@ export const NetworkPanelComp = observer(
transferredSize: 0, transferredSize: 0,
}); });
// Store original data in refs to avoid reprocessing
const originalListRef = useRef([]); const originalListRef = useRef([]);
const socketListRef = useRef([]); const socketListRef = useRef([]);
@ -799,7 +797,7 @@ export const NetworkPanelComp = observer(
<div className="flex items-center justify-center h-full"> <div className="flex items-center justify-center h-full">
<div className="text-center"> <div className="text-center">
<div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-2"></div> <div className="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto mb-2"></div>
<p>Loading network data...</p> <p>Processing initial network data...</p>
</div> </div>
</div> </div>
) : ( ) : (

View file

@ -13,11 +13,7 @@ export function mergeListsWithZoom<
return []; return [];
} }
// Create result array with pre-allocated size estimation // Optimized for common case - no zoom
// (We'll set an initial capacity based on rough estimate)
const merged = [];
// Optimize for common case - no zoom
if (!zoom?.enabled) { if (!zoom?.enabled) {
return mergeThreeSortedArrays(arr1, arr2, arr3); return mergeThreeSortedArrays(arr1, arr2, arr3);
} }
@ -40,7 +36,6 @@ export function mergeListsWithZoom<
); );
} }
// Helper function to perform binary search to find index of first element >= threshold
function binarySearchStartIndex<T extends Record<string, any>>( function binarySearchStartIndex<T extends Record<string, any>>(
arr: T[], arr: T[],
threshold: number, threshold: number,
@ -67,13 +62,13 @@ function binarySearchStartIndex<T extends Record<string, any>>(
return low; return low;
} }
// Specialized function for when no zoom is applied
function mergeThreeSortedArrays< function mergeThreeSortedArrays<
T extends Record<string, any>, T extends Record<string, any>,
Y extends Record<string, any>, Y extends Record<string, any>,
Z extends Record<string, any>, Z extends Record<string, any>,
>(arr1: T[], arr2: Y[], arr3: Z[]): Array<T | Y | Z> { >(arr1: T[], arr2: Y[], arr3: Z[]): Array<T | Y | Z> {
const totalLength = arr1.length + arr2.length + arr3.length; const totalLength = arr1.length + arr2.length + arr3.length;
// prealloc array size
const result = new Array(totalLength); const result = new Array(totalLength);
let i = 0, let i = 0,
@ -98,7 +93,7 @@ function mergeThreeSortedArrays<
return result; return result;
} }
// Specialized function for merging with zoom range // same as above, just with zoom stuff
function mergeThreeSortedArraysWithinRange< function mergeThreeSortedArraysWithinRange<
T extends Record<string, any>, T extends Record<string, any>,
Y extends Record<string, any>, Y extends Record<string, any>,
@ -113,6 +108,7 @@ function mergeThreeSortedArraysWithinRange<
start: number, start: number,
end: number, end: number,
): Array<T | Y | Z> { ): Array<T | Y | Z> {
// we don't know beforehand how many items will be there
const result = []; const result = [];
let i = startIdx1; let i = startIdx1;