Merge pull request #535 from AppFlowy-IO/refactor/text_block_event

chore: rename some struct in Rust
This commit is contained in:
Nathan.fooo 2022-06-05 19:32:04 +08:00 committed by GitHub
commit 7c03924e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 48 additions and 48 deletions

View File

@ -12,14 +12,14 @@ class DocumentService {
await FolderEventSetLatestView(ViewId(value: docId)).send();
final payload = TextBlockId(value: docId);
return BlockEventGetBlockData(payload).send();
return TextBlockEventGetBlockData(payload).send();
}
Future<Either<TextBlockDelta, FlowyError>> composeDelta({required String docId, required String data}) {
final payload = TextBlockDelta.create()
..blockId = docId
..deltaStr = data;
return BlockEventApplyDelta(payload).send();
return TextBlockEventApplyDelta(payload).send();
}
Future<Either<Unit, FlowyError>> closeDocument({required String docId}) {

View File

@ -10,7 +10,7 @@ class ShareService {
..viewId = docId
..exportType = type;
return BlockEventExportDocument(request).send();
return TextBlockEventExportDocument(request).send();
}
Future<Either<ExportData, FlowyError>> exportText(String docId) {

View File

@ -1,13 +1,13 @@
/// Auto generate. Do not edit
part of '../../dispatch.dart';
class BlockEventGetBlockData {
class TextBlockEventGetBlockData {
TextBlockId request;
BlockEventGetBlockData(this.request);
TextBlockEventGetBlockData(this.request);
Future<Either<TextBlockDelta, FlowyError>> send() {
final request = FFIRequest.create()
..event = BlockEvent.GetBlockData.toString()
..event = TextBlockEvent.GetBlockData.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
@ -18,13 +18,13 @@ class BlockEventGetBlockData {
}
}
class BlockEventApplyDelta {
class TextBlockEventApplyDelta {
TextBlockDelta request;
BlockEventApplyDelta(this.request);
TextBlockEventApplyDelta(this.request);
Future<Either<TextBlockDelta, FlowyError>> send() {
final request = FFIRequest.create()
..event = BlockEvent.ApplyDelta.toString()
..event = TextBlockEvent.ApplyDelta.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
@ -35,13 +35,13 @@ class BlockEventApplyDelta {
}
}
class BlockEventExportDocument {
class TextBlockEventExportDocument {
ExportPayload request;
BlockEventExportDocument(this.request);
TextBlockEventExportDocument(this.request);
Future<Either<ExportData, FlowyError>> send() {
final request = FFIRequest.create()
..event = BlockEvent.ExportDocument.toString()
..event = TextBlockEvent.ExportDocument.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)

View File

@ -9,20 +9,20 @@
import 'dart:core' as $core;
import 'package:protobuf/protobuf.dart' as $pb;
class BlockEvent extends $pb.ProtobufEnum {
static const BlockEvent GetBlockData = BlockEvent._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetBlockData');
static const BlockEvent ApplyDelta = BlockEvent._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ApplyDelta');
static const BlockEvent ExportDocument = BlockEvent._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ExportDocument');
class TextBlockEvent extends $pb.ProtobufEnum {
static const TextBlockEvent GetBlockData = TextBlockEvent._(0, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'GetBlockData');
static const TextBlockEvent ApplyDelta = TextBlockEvent._(1, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ApplyDelta');
static const TextBlockEvent ExportDocument = TextBlockEvent._(2, const $core.bool.fromEnvironment('protobuf.omit_enum_names') ? '' : 'ExportDocument');
static const $core.List<BlockEvent> values = <BlockEvent> [
static const $core.List<TextBlockEvent> values = <TextBlockEvent> [
GetBlockData,
ApplyDelta,
ExportDocument,
];
static final $core.Map<$core.int, BlockEvent> _byValue = $pb.ProtobufEnum.initByValue(values);
static BlockEvent? valueOf($core.int value) => _byValue[value];
static final $core.Map<$core.int, TextBlockEvent> _byValue = $pb.ProtobufEnum.initByValue(values);
static TextBlockEvent? valueOf($core.int value) => _byValue[value];
const BlockEvent._($core.int v, $core.String n) : super(v, n);
const TextBlockEvent._($core.int v, $core.String n) : super(v, n);
}

View File

@ -8,9 +8,9 @@
import 'dart:core' as $core;
import 'dart:convert' as $convert;
import 'dart:typed_data' as $typed_data;
@$core.Deprecated('Use blockEventDescriptor instead')
const BlockEvent$json = const {
'1': 'BlockEvent',
@$core.Deprecated('Use textBlockEventDescriptor instead')
const TextBlockEvent$json = const {
'1': 'TextBlockEvent',
'2': const [
const {'1': 'GetBlockData', '2': 0},
const {'1': 'ApplyDelta', '2': 1},
@ -18,5 +18,5 @@ const BlockEvent$json = const {
],
};
/// Descriptor for `BlockEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List blockEventDescriptor = $convert.base64Decode('CgpCbG9ja0V2ZW50EhAKDEdldEJsb2NrRGF0YRAAEg4KCkFwcGx5RGVsdGEQARISCg5FeHBvcnREb2N1bWVudBAC');
/// Descriptor for `TextBlockEvent`. Decode as a `google.protobuf.EnumDescriptorProto`.
final $typed_data.Uint8List textBlockEventDescriptor = $convert.base64Decode('Cg5UZXh0QmxvY2tFdmVudBIQCgxHZXRCbG9ja0RhdGEQABIOCgpBcHBseURlbHRhEAESEgoORXhwb3J0RG9jdW1lbnQQAg==');

View File

@ -9,16 +9,16 @@ pub fn create(block_manager: Arc<TextBlockManager>) -> Module {
let mut module = Module::new().name(env!("CARGO_PKG_NAME")).data(block_manager);
module = module
.event(BlockEvent::GetBlockData, get_block_data_handler)
.event(BlockEvent::ApplyDelta, apply_delta_handler)
.event(BlockEvent::ExportDocument, export_handler);
.event(TextBlockEvent::GetBlockData, get_block_data_handler)
.event(TextBlockEvent::ApplyDelta, apply_delta_handler)
.event(TextBlockEvent::ExportDocument, export_handler);
module
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Display, Hash, ProtoBuf_Enum, Flowy_Event)]
#[event_err = "FlowyError"]
pub enum BlockEvent {
pub enum TextBlockEvent {
#[event(input = "TextBlockId", output = "TextBlockDelta")]
GetBlockData = 0,

View File

@ -24,31 +24,31 @@
// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_2;
#[derive(Clone,PartialEq,Eq,Debug,Hash)]
pub enum BlockEvent {
pub enum TextBlockEvent {
GetBlockData = 0,
ApplyDelta = 1,
ExportDocument = 2,
}
impl ::protobuf::ProtobufEnum for BlockEvent {
impl ::protobuf::ProtobufEnum for TextBlockEvent {
fn value(&self) -> i32 {
*self as i32
}
fn from_i32(value: i32) -> ::std::option::Option<BlockEvent> {
fn from_i32(value: i32) -> ::std::option::Option<TextBlockEvent> {
match value {
0 => ::std::option::Option::Some(BlockEvent::GetBlockData),
1 => ::std::option::Option::Some(BlockEvent::ApplyDelta),
2 => ::std::option::Option::Some(BlockEvent::ExportDocument),
0 => ::std::option::Option::Some(TextBlockEvent::GetBlockData),
1 => ::std::option::Option::Some(TextBlockEvent::ApplyDelta),
2 => ::std::option::Option::Some(TextBlockEvent::ExportDocument),
_ => ::std::option::Option::None
}
}
fn values() -> &'static [Self] {
static values: &'static [BlockEvent] = &[
BlockEvent::GetBlockData,
BlockEvent::ApplyDelta,
BlockEvent::ExportDocument,
static values: &'static [TextBlockEvent] = &[
TextBlockEvent::GetBlockData,
TextBlockEvent::ApplyDelta,
TextBlockEvent::ExportDocument,
];
values
}
@ -56,30 +56,30 @@ impl ::protobuf::ProtobufEnum for BlockEvent {
fn enum_descriptor_static() -> &'static ::protobuf::reflect::EnumDescriptor {
static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::EnumDescriptor> = ::protobuf::rt::LazyV2::INIT;
descriptor.get(|| {
::protobuf::reflect::EnumDescriptor::new_pb_name::<BlockEvent>("BlockEvent", file_descriptor_proto())
::protobuf::reflect::EnumDescriptor::new_pb_name::<TextBlockEvent>("TextBlockEvent", file_descriptor_proto())
})
}
}
impl ::std::marker::Copy for BlockEvent {
impl ::std::marker::Copy for TextBlockEvent {
}
impl ::std::default::Default for BlockEvent {
impl ::std::default::Default for TextBlockEvent {
fn default() -> Self {
BlockEvent::GetBlockData
TextBlockEvent::GetBlockData
}
}
impl ::protobuf::reflect::ProtobufValue for BlockEvent {
impl ::protobuf::reflect::ProtobufValue for TextBlockEvent {
fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef {
::protobuf::reflect::ReflectValueRef::Enum(::protobuf::ProtobufEnum::descriptor(self))
}
}
static file_descriptor_proto_data: &'static [u8] = b"\
\n\x0fevent_map.proto*B\n\nBlockEvent\x12\x10\n\x0cGetBlockData\x10\0\
\x12\x0e\n\nApplyDelta\x10\x01\x12\x12\n\x0eExportDocument\x10\x02b\x06p\
roto3\
\n\x0fevent_map.proto*F\n\x0eTextBlockEvent\x12\x10\n\x0cGetBlockData\
\x10\0\x12\x0e\n\nApplyDelta\x10\x01\x12\x12\n\x0eExportDocument\x10\x02\
b\x06proto3\
";
static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

View File

@ -1,6 +1,6 @@
syntax = "proto3";
enum BlockEvent {
enum TextBlockEvent {
GetBlockData = 0;
ApplyDelta = 1;
ExportDocument = 2;