chore: fix tauri build

This commit is contained in:
nathan 2023-03-03 19:06:57 +08:00
parent a2bdb08a84
commit 24340f3091
2 changed files with 22 additions and 20 deletions

View File

@ -1,6 +1,5 @@
import { CellIdentifier } from './cell_bd_svc'; import { CellIdentifier } from './cell_bd_svc';
import { CellCache, CellCacheKey } from './cell_cache'; import { CellCache, CellCacheKey } from './cell_cache';
import { FieldController } from '../field/field_controller';
import { CellDataLoader } from './data_parser'; import { CellDataLoader } from './data_parser';
import { CellDataPersistence } from './data_persistence'; import { CellDataPersistence } from './data_persistence';
import { FieldBackendService, TypeOptionParser } from '../field/field_bd_svc'; import { FieldBackendService, TypeOptionParser } from '../field/field_bd_svc';
@ -112,21 +111,24 @@ export class CellController<T, D> {
} }
class CellDataNotifier<T> extends ChangeNotifier<T | null> { class CellDataNotifier<T> extends ChangeNotifier<T | null> {
_cellData: T | null; _cellData: Option<T>;
constructor(cellData: T) { constructor(cellData: T) {
super(); super();
this._cellData = cellData; this._cellData = Some(cellData);
} }
set cellData(data: T | null) { set cellData(data: Option<T>) {
if (this._cellData !== data) { if (this._cellData !== data) {
this._cellData = data; this._cellData = data;
this.notify(this._cellData);
if (this._cellData.some) {
this.notify(this._cellData.val);
}
} }
} }
get cellData(): T | null { get cellData(): Option<T> {
return this._cellData; return this._cellData;
} }
} }

View File

@ -3,11 +3,11 @@ import { CellBackendService, CellIdentifier } from './cell_bd_svc';
import { DateCellDataPB } from '../../../../../services/backend/models/flowy-database/date_type_option_entities'; import { DateCellDataPB } from '../../../../../services/backend/models/flowy-database/date_type_option_entities';
import { SelectOptionCellDataPB } from '../../../../../services/backend/models/flowy-database/select_type_option'; import { SelectOptionCellDataPB } from '../../../../../services/backend/models/flowy-database/select_type_option';
import { URLCellDataPB } from '../../../../../services/backend/models/flowy-database/url_type_option_entities'; import { URLCellDataPB } from '../../../../../services/backend/models/flowy-database/url_type_option_entities';
import { Err, Ok } from 'ts-results'; import { Err, None, Ok, Option, Some } from 'ts-results';
import { Log } from '../../../../utils/log'; import { Log } from '../../../../utils/log';
abstract class CellDataParser<T> { abstract class CellDataParser<T> {
abstract parserData(data: Uint8Array): T; abstract parserData(data: Uint8Array): Option<T>;
} }
class CellDataLoader<T> { class CellDataLoader<T> {
@ -34,32 +34,32 @@ export const utf8Decoder = new TextDecoder('utf-8');
export const utf8Encoder = new TextEncoder(); export const utf8Encoder = new TextEncoder();
class StringCellDataParser extends CellDataParser<string> { class StringCellDataParser extends CellDataParser<string> {
parserData(data: Uint8Array): string { parserData(data: Uint8Array): Option<string> {
return utf8Decoder.decode(data); return Some(utf8Decoder.decode(data));
} }
} }
class DateCellDataParser extends CellDataParser<DateCellDataPB> { class DateCellDataParser extends CellDataParser<DateCellDataPB> {
parserData(data: Uint8Array): DateCellDataPB { parserData(data: Uint8Array): Option<DateCellDataPB> {
return DateCellDataPB.deserializeBinary(data); return Some(DateCellDataPB.deserializeBinary(data));
} }
} }
class SelectOptionCellDataParser extends CellDataParser<SelectOptionCellDataPB | undefined> { class SelectOptionCellDataParser extends CellDataParser<SelectOptionCellDataPB> {
parserData(data: Uint8Array): SelectOptionCellDataPB | undefined { parserData(data: Uint8Array): Option<SelectOptionCellDataPB> {
if (data.length === 0) { if (data.length === 0) {
return undefined; return None;
} }
return SelectOptionCellDataPB.deserializeBinary(data); return Some(SelectOptionCellDataPB.deserializeBinary(data));
} }
} }
class URLCellDataParser extends CellDataParser<URLCellDataPB | undefined> { class URLCellDataParser extends CellDataParser<URLCellDataPB> {
parserData(data: Uint8Array): URLCellDataPB | undefined { parserData(data: Uint8Array): Option<URLCellDataPB> {
if (data.length === 0) { if (data.length === 0) {
return undefined; return None;
} }
return URLCellDataPB.deserializeBinary(data); return Some(URLCellDataPB.deserializeBinary(data));
} }
} }