Fix initial load, remove fixed todos
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
ChangeDetectionStrategy,
|
ChangeDetectionStrategy,
|
||||||
|
ChangeDetectorRef,
|
||||||
Component,
|
Component,
|
||||||
computed,
|
computed,
|
||||||
effect,
|
effect,
|
||||||
@@ -67,6 +68,7 @@ export class FileViewerComponent {
|
|||||||
file = input<File | undefined>();
|
file = input<File | undefined>();
|
||||||
|
|
||||||
private duckdbService = inject(DuckdbService);
|
private duckdbService = inject(DuckdbService);
|
||||||
|
private cdr = inject(ChangeDetectorRef);
|
||||||
|
|
||||||
// Can't be computed since effect has to run first so file exists in duckdb
|
// Can't be computed since effect has to run first so file exists in duckdb
|
||||||
protected columns = signal<Column[]>([]);
|
protected columns = signal<Column[]>([]);
|
||||||
@@ -95,16 +97,11 @@ export class FileViewerComponent {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
const newValue = Array.from({ length: Number(rows.totalRows) });
|
const newValue = Array.from({ length: Number(rows.totalRows) });
|
||||||
newValue.splice(0, 100, ...rows.rows);
|
|
||||||
this.currentValue.set(newValue);
|
this.currentValue.set(newValue);
|
||||||
}
|
}
|
||||||
// TODO: Refresh table? Or is this automatic when columns change?
|
|
||||||
// this.table().
|
|
||||||
//TODO: Get rows in file
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Getting an infinite loop
|
|
||||||
protected async onLazyLoad(event: TableLazyLoadEvent) {
|
protected async onLazyLoad(event: TableLazyLoadEvent) {
|
||||||
const file = this.file();
|
const file = this.file();
|
||||||
if (file) {
|
if (file) {
|
||||||
@@ -116,10 +113,11 @@ export class FileViewerComponent {
|
|||||||
[],
|
[],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
if (!this.currentValue()) {
|
// First clear out existing data, don't want to risk loading entire file into memory
|
||||||
this.currentValue.set(Array.from({ length: Number(rows.totalRows) }));
|
this.currentValue().fill(undefined);
|
||||||
}
|
// Can't update the current value, otherwise we get an infinite loop
|
||||||
this.currentValue().splice(event.first!, event.rows!, ...rows.rows);
|
this.currentValue().splice(event.first!, event.rows!, ...rows.rows);
|
||||||
|
this.cdr.markForCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user