Skip to content

Commit

Permalink
fix: fix ci spec case
Browse files Browse the repository at this point in the history
chore: revert rowcol visible back
  • Loading branch information
lumixraku committed Sep 11, 2024
1 parent 3f0dc53 commit feb2eba
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
12 changes: 2 additions & 10 deletions packages/core/src/sheets/worksheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class Worksheet {
protected _columnManager: ColumnManager;

protected readonly _viewModel: SheetViewModel;
private _filteredRowCacheMap: Map<number, boolean> = new Map();

constructor(
public readonly unitId: string,
Expand Down Expand Up @@ -466,17 +465,10 @@ export class Worksheet {
/**
* Row is filtered out, that means this row is invisible.
* @param row
* @returns {boolean}
* @returns {boolean} is row hidden by filter
*/
isRowFiltered(row: number): boolean {
if (!this._filteredRowCacheMap.has(row)) {
this._filteredRowCacheMap.set(row, this._viewModel.getRowFiltered(row));
}
return !!this._filteredRowCacheMap.get(row);
}

clearFilteredRowCacheMap() {
this._filteredRowCacheMap.clear();
return this._viewModel.getRowFiltered(row);
}

/**
Expand Down
7 changes: 3 additions & 4 deletions packages/sheets-filter/src/services/sheet-filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import type { Nullable, Workbook } from '@univerjs/core';
import {
CommandType, Disposable,
fromCallback,
Expand All @@ -24,14 +23,15 @@ import {
UniverInstanceType,
} from '@univerjs/core';
import { BehaviorSubject, filter, merge, of, switchMap } from 'rxjs';
import type { Nullable, Workbook } from '@univerjs/core';

import { FilterModel } from '../models/filter-model';
import {
ReCalcSheetsFilterMutation,
RemoveSheetsFilterMutation,
SetSheetsFilterCriteriaMutation,
SetSheetsFilterRangeMutation,
} from '../commands/mutations/sheets-filter.mutation';
import { FilterModel } from '../models/filter-model';
import type { IAutoFilter } from '../models/types';

export const FILTER_MUTATIONS = new Set([
Expand Down Expand Up @@ -131,6 +131,7 @@ export class SheetsFilterService extends Disposable {
return;
}
} catch (err) {
console.error('[SheetsFilterService]: could not get active workbook!', err);
return;
}

Expand All @@ -145,8 +146,6 @@ export class SheetsFilterService extends Disposable {
const subUnitId = activeSheet.getSheetId();
const filterModel = this.getFilterModel(unitId, subUnitId);
this._activeFilterModel$.next(filterModel);

workbook.getActiveSheet().clearFilteredRowCacheMap();
}

private _initActiveFilterModel(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* limitations under the License.
*/

import type { ICellData, Injector, Nullable, Univer, Workbook } from '@univerjs/core';
import { createInterceptorKey, IUniverInstanceService, UniverInstanceType } from '@univerjs/core';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import type { ICellData, Injector, Nullable, Univer, Workbook } from '@univerjs/core';

import { INTERCEPTOR_POINT } from '../interceptor-const';
import { SheetInterceptorService } from '../sheet-interceptor.service';
import type { ISheetLocation } from '../utils/interceptor';
import { createSheetTestBed } from './create-core-test-bed';
import type { ISheetLocation } from '../utils/interceptor';

describe('Test SheetInterceptorService', () => {
let univer: Univer;
Expand Down Expand Up @@ -49,7 +49,7 @@ describe('Test SheetInterceptorService', () => {
return sheet.getRowFiltered(row);
}

function getRowRawVisible(row: number): boolean {
function getRowVisible(row: number): boolean {
const cus = get(IUniverInstanceService);
const sheet = cus.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!.getActiveSheet()!;
return sheet.getRowVisible(row);
Expand Down Expand Up @@ -112,13 +112,13 @@ describe('Test SheetInterceptorService', () => {
});

expect(getRowFiltered(1)).toBeFalsy();
expect(getRowRawVisible(1)).toBeTruthy();
expect(getRowVisible(1)).toBeTruthy();

realFiltered = true;
expect(getRowFiltered(1)).toBeTruthy();
expect(getRowRawVisible(1)).toBeFalsy();
expect(getRowVisible(1)).toBeFalsy();
expect(getRowFiltered(2)).toBeFalsy();
expect(getRowRawVisible(2)).toBeTruthy();
expect(getRowVisible(2)).toBeTruthy();
});
});

Expand Down

0 comments on commit feb2eba

Please sign in to comment.