Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove redundant code #3575

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions examples/src/docs/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
* limitations under the License.
*/

/* eslint-disable node/prefer-global/process */
/* eslint-disable no-console */

import { LocaleType, LogLevel, Univer, UniverInstanceType, UserManagerService } from '@univerjs/core';
import { UniverDebuggerPlugin } from '@univerjs/debugger';
import { defaultTheme } from '@univerjs/design';
Expand All @@ -33,16 +30,9 @@ import { UniverUIPlugin } from '@univerjs/ui';
import { DEFAULT_DOCUMENT_DATA_CN } from '../data';
import { enUS, ruRU, zhCN } from '../locales';

/* eslint-disable node/prefer-global/process */
const IS_E2E: boolean = !!process.env.IS_E2E;

// package info
console.table({
NODE_ENV: process.env.NODE_ENV,
GIT_COMMIT_HASH: process.env.GIT_COMMIT_HASH,
GIT_REF_NAME: process.env.GIT_REF_NAME,
BUILD_TIME: process.env.BUILD_TIME,
});

// univer
const univer = new Univer({
theme: defaultTheme,
Expand All @@ -61,7 +51,6 @@ univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverDebuggerPlugin);
univer.registerPlugin(UniverUIPlugin, {
container: 'app',
// footer: false,
});

univer.registerPlugin(UniverDocsPlugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,19 @@ export const SaveSnapshotOptions: ICommand = {
const resourceLoaderService = accessor.get(IResourceLoaderService);
const localFileService = accessor.get(ILocalFileService);
const recordController = accessor.get(RecordController);
const gitHash = process.env.GIT_COMMIT_HASH;
const gitBranch = process.env.GIT_REF_NAME;
const buildTime = process.env.BUILD_TIME;

const preName = new Date().toLocaleString();
const workbook = univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;
if (!workbook) {
const doc = univerInstanceService.getCurrentUnitForType<DocumentDataModel>(UniverInstanceType.UNIVER_DOC)!;
const snapshot = resourceLoaderService.saveUnit(doc.getUnitId());
(snapshot as any).__env__ = { gitHash, gitBranch, buildTime };

if (process.env.NODE_ENV === 'production') {
const gitHash = process.env.GIT_COMMIT_HASH;
const gitBranch = process.env.GIT_REF_NAME;
const buildTime = process.env.BUILD_TIME;
(snapshot as any).__env__ = { gitHash, gitBranch, buildTime };
}
const text = JSON.stringify(snapshot, null, 2);
localFileService.downloadFile(new Blob([text]), `${preName} snapshot.json`);
return true;
Expand All @@ -72,7 +76,12 @@ export const SaveSnapshotOptions: ICommand = {
}
const snapshot = resourceLoaderService.saveUnit<ReturnType<typeof workbook.getSnapshot>>(workbook.getUnitId())!;

(snapshot as any).__env__ = { gitHash, gitBranch, buildTime };
if (process.env.NODE_ENV === 'production') {
const gitHash = process.env.GIT_COMMIT_HASH;
const gitBranch = process.env.GIT_REF_NAME;
const buildTime = process.env.BUILD_TIME;
(snapshot as any).__env__ = { gitHash, gitBranch, buildTime };
}

switch (params.value) {
case 'sheet': {
Expand Down
6 changes: 3 additions & 3 deletions packages/sheets/src/controllers/merge-cell.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class MergeCellController extends Disposable {
// TODO@Gggpound: get by unit id and subUnitId
const workbook = self._univerInstanceService.getCurrentUnitForType<Workbook>(UniverInstanceType.UNIVER_SHEET)!;
const unitId = workbook.getUnitId();
const worksheet = workbook.getActiveSheet();
const worksheet = workbook?.getActiveSheet();
if (!worksheet) {
return { redos: [], undos: [] };
}
Expand Down Expand Up @@ -331,10 +331,10 @@ export class MergeCellController extends Disposable {
);

this._univerInstanceService.getCurrentTypeOfUnit$<Workbook>(UniverInstanceType.UNIVER_SHEET).pipe(first((workbook) => !!workbook)).subscribe((workbook) => {
const sheet = workbook.getActiveSheet();
const sheet = workbook!.getActiveSheet();
if (!sheet) return;

registerRefRange(workbook.getUnitId(), sheet.getSheetId());
registerRefRange(workbook!.getUnitId(), sheet.getSheetId());
});
}

Expand Down
Loading