Skip to content

Commit

Permalink
Finish personal review
Browse files Browse the repository at this point in the history
  • Loading branch information
hudson-newey committed Nov 20, 2024
1 parent 3ad37fc commit 61e7f33
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/components/verification-grid/verification-grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,11 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
}

/**
* Represents the first index of the subjectBuffer that is currently being
* displayed in the verification grid
* The first index of the currently displayed page in the verification grid
*/
public get viewHead(): number {
return this._viewHead;
}

public set viewHead(value: number) {
this._viewHead = value;
this.renderVirtualPageIndex(value);
Expand All @@ -221,10 +219,7 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
return this.populatedTileCount - this.hiddenTiles;
}

/**
* Represents a subjectBuffer index where the next verification prompt will be
* taken from
*/
/** A subjectBuffer index for the current undecided page */
public verificationHead = 0;
public subjectBuffer: SubjectWrapper[] = [];

Expand Down Expand Up @@ -332,9 +327,8 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
this.handleTileInvalidation();
}

// invalidating the source will cause the grid tiles and spectrogram to
// invalidate meaning that each grid tile will re-render, however
// they will not be re-created
// invalidating the verification grids source will cause the grid tiles and
// spectrograms to re-render, from the start of the new data source
const gridSourceInvalidationKeys: (keyof this)[] = ["getPage", "urlTransformer"];
if (gridSourceInvalidationKeys.some((key) => change.has(key))) {
await this.handleGridSourceInvalidation();
Expand Down Expand Up @@ -389,7 +383,7 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
}

/**
* handles the data source of the verification changing
* handles the data source of the verification grid changing
* this will reset the verification task and re-fetch the first page of
* subjects from the new data source
*/
Expand All @@ -415,6 +409,12 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
}
}

/**
* handles the currently rendered page of subjects changing
* e.g. the number of tiles being rendered, or the source of a singular tile
* changing
* causing the current page to be re-rendered from the viewHead position
*/
private handlePageInvalidation(): void {
this.renderVirtualPageIndex(this.viewHead);
}
Expand Down Expand Up @@ -915,6 +915,7 @@ export class VerificationGridComponent extends AbstractComponent(LitElement) {
this.removeSubSelection();
}

/** Changes the viewHead to the current page of undecided results */
private async resumeVerification(): Promise<void> {
this.viewHead = this.verificationHead;
}
Expand Down

0 comments on commit 61e7f33

Please sign in to comment.