Skip to content

Commit 1df2619

Browse files
authored
docs: update code documentation (#1804)
* docs: update code documentation * chore: fix bloc test * chore: reduce lock granularity * chore: fix bloc test
1 parent 4d5063d commit 1df2619

File tree

29 files changed

+198
-212
lines changed

29 files changed

+198
-212
lines changed

frontend/.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"label": "AF: Build Appflowy Core",
5959
"type": "shell",
6060
"windows": {
61-
"command": "cargo make --profile development-windows appflowy-core-dev"
61+
"command": "cargo make --profile development-windows-x86 appflowy-core-dev"
6262
},
6363
"linux": {
6464
"command": "cargo make --profile \"development-linux-$(uname -m)\" appflowy-core-dev"

frontend/app_flowy/lib/plugins/document/document.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DocumentPluginBuilder extends PluginBuilder {
3434
PluginType get pluginType => PluginType.editor;
3535

3636
@override
37-
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat;
37+
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.NodeFormat;
3838
}
3939

4040
class DocumentPlugin extends Plugin<int> {

frontend/app_flowy/lib/plugins/grid/application/cell/select_option_editor_bloc.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,10 @@ class SelectOptionCellEditorBloc
147147
}
148148

149149
void _filterOption(String optionName, Emitter<SelectOptionEditorState> emit) {
150-
final _MakeOptionResult result =
151-
_makeOptions(Some(optionName), state.allOptions);
150+
final _MakeOptionResult result = _makeOptions(
151+
Some(optionName),
152+
state.allOptions,
153+
);
152154
emit(state.copyWith(
153155
filter: Some(optionName),
154156
options: result.options,
@@ -159,6 +161,7 @@ class SelectOptionCellEditorBloc
159161
Future<void> _loadOptions() async {
160162
final result = await _selectOptionService.getOptionContext();
161163
if (isClosed) {
164+
Log.warn("Unexpected closing the bloc");
162165
return;
163166
}
164167

@@ -177,7 +180,9 @@ class SelectOptionCellEditorBloc
177180
}
178181

179182
_MakeOptionResult _makeOptions(
180-
Option<String> filter, List<SelectOptionPB> allOptions) {
183+
Option<String> filter,
184+
List<SelectOptionPB> allOptions,
185+
) {
181186
final List<SelectOptionPB> options = List.from(allOptions);
182187
Option<String> createOption = filter;
183188

frontend/app_flowy/lib/plugins/grid/application/field/type_option/type_option_data_controller.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'type_option_context.dart';
1212
class TypeOptionDataController {
1313
final String databaseId;
1414
final IFieldTypeOptionLoader loader;
15-
late TypeOptionPB _data;
15+
late TypeOptionPB _typeOptiondata;
1616
final PublishNotifier<FieldPB> _fieldNotifier = PublishNotifier();
1717

1818
/// Returns a [TypeOptionDataController] used to modify the specified
@@ -27,7 +27,7 @@ class TypeOptionDataController {
2727
FieldInfo? fieldInfo,
2828
}) {
2929
if (fieldInfo != null) {
30-
_data = TypeOptionPB.create()
30+
_typeOptiondata = TypeOptionPB.create()
3131
..databaseId = databaseId
3232
..field_2 = fieldInfo.field;
3333
}
@@ -38,7 +38,7 @@ class TypeOptionDataController {
3838
return result.fold(
3939
(data) {
4040
data.freeze();
41-
_data = data;
41+
_typeOptiondata = data;
4242
_fieldNotifier.value = data.field_2;
4343
return left(data);
4444
},
@@ -50,28 +50,28 @@ class TypeOptionDataController {
5050
}
5151

5252
FieldPB get field {
53-
return _data.field_2;
53+
return _typeOptiondata.field_2;
5454
}
5555

5656
T getTypeOption<T>(TypeOptionDataParser<T> parser) {
57-
return parser.fromBuffer(_data.typeOptionData);
57+
return parser.fromBuffer(_typeOptiondata.typeOptionData);
5858
}
5959

6060
set fieldName(String name) {
61-
_data = _data.rebuild((rebuildData) {
61+
_typeOptiondata = _typeOptiondata.rebuild((rebuildData) {
6262
rebuildData.field_2 = rebuildData.field_2.rebuild((rebuildField) {
6363
rebuildField.name = name;
6464
});
6565
});
6666

67-
_fieldNotifier.value = _data.field_2;
67+
_fieldNotifier.value = _typeOptiondata.field_2;
6868

6969
FieldService(databaseId: databaseId, fieldId: field.id)
7070
.updateField(name: name);
7171
}
7272

7373
set typeOptionData(List<int> typeOptionData) {
74-
_data = _data.rebuild((rebuildData) {
74+
_typeOptiondata = _typeOptiondata.rebuild((rebuildData) {
7575
if (typeOptionData.isNotEmpty) {
7676
rebuildData.typeOptionData = typeOptionData;
7777
}

frontend/app_flowy/lib/startup/plugin/plugin.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ abstract class PluginBuilder {
5252

5353
PluginType get pluginType;
5454

55-
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.TreeFormat;
55+
ViewDataFormatPB get dataFormatType => ViewDataFormatPB.NodeFormat;
5656

5757
ViewLayoutTypePB? get layoutType => ViewLayoutTypePB.Document;
5858
}

frontend/app_flowy/lib/workspace/application/app/app_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class AppService {
7676
..to = toIndex
7777
..ty = MoveFolderItemType.MoveView;
7878

79-
return FolderEventMoveFolderItem(payload).send();
79+
return FolderEventMoveItem(payload).send();
8080
}
8181

8282
Future<List<Tuple2<AppPB, List<ViewPB>>>> fetchViews(

frontend/app_flowy/lib/workspace/application/workspace/workspace_service.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,6 @@ class WorkspaceService {
6565
..to = toIndex
6666
..ty = MoveFolderItemType.MoveApp;
6767

68-
return FolderEventMoveFolderItem(payload).send();
68+
return FolderEventMoveItem(payload).send();
6969
}
7070
}

frontend/app_flowy/test/bloc_test/board_test/group_by_checkbox_field_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void main() {
3333
final gridGroupBloc = GridGroupBloc(
3434
viewId: context.gridView.id,
3535
fieldController: context.fieldController,
36-
);
36+
)..add(const GridGroupEvent.initial());
3737
gridGroupBloc.add(GridGroupEvent.setGroupByField(
3838
checkboxField.id,
3939
checkboxField.fieldType,

frontend/app_flowy/test/bloc_test/board_test/group_by_multi_select_field_test.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ void main() {
1414
boardTest = await AppFlowyBoardTest.ensureInitialized();
1515
});
1616

17-
test('group by multi select with no options test', () async {
17+
test('no status group name test', () async {
1818
final context = await boardTest.createTestBoard();
1919

2020
// create multi-select field
@@ -27,7 +27,9 @@ void main() {
2727
final gridGroupBloc = GridGroupBloc(
2828
viewId: context.gridView.id,
2929
fieldController: context.fieldController,
30-
);
30+
)..add(const GridGroupEvent.initial());
31+
await boardResponseFuture();
32+
3133
gridGroupBloc.add(GridGroupEvent.setGroupByField(
3234
multiSelectField.id,
3335
multiSelectField.fieldType,
@@ -72,7 +74,9 @@ void main() {
7274
final gridGroupBloc = GridGroupBloc(
7375
viewId: context.gridView.id,
7476
fieldController: context.fieldController,
75-
);
77+
)..add(const GridGroupEvent.initial());
78+
await boardResponseFuture();
79+
7680
gridGroupBloc.add(GridGroupEvent.setGroupByField(
7781
multiSelectField.id,
7882
multiSelectField.fieldType,

frontend/app_flowy/test/bloc_test/grid_test/cell/select_option_cell_test.dart

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,24 @@ void main() {
6464

6565
bloc.add(const SelectOptionEditorEvent.newOption("A"));
6666
await gridResponseFuture();
67+
assert(bloc.state.options.length == 1,
68+
"Expect 1 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}");
69+
6770
bloc.add(const SelectOptionEditorEvent.newOption("B"));
6871
await gridResponseFuture();
72+
assert(bloc.state.options.length == 2,
73+
"Expect 2 but receive ${bloc.state.options.length}, Options: ${bloc.state.options}");
74+
6975
bloc.add(const SelectOptionEditorEvent.newOption("C"));
7076
await gridResponseFuture();
77+
assert(bloc.state.options.length == 3,
78+
"Expect 3 but receive ${bloc.state.options.length}. Options: ${bloc.state.options}");
7179

7280
bloc.add(const SelectOptionEditorEvent.deleteAllOptions());
7381
await gridResponseFuture();
7482

75-
assert(bloc.state.options.isEmpty);
83+
assert(bloc.state.options.isEmpty,
84+
"Expect empty but receive ${bloc.state.options.length}");
7685
});
7786

7887
test('select/unselect option', () async {
@@ -161,18 +170,41 @@ void main() {
161170

162171
bloc.add(const SelectOptionEditorEvent.newOption("abcd"));
163172
await gridResponseFuture();
173+
expect(
174+
bloc.state.options.length,
175+
1,
176+
reason: "Options: ${bloc.state.options}",
177+
);
164178

165179
bloc.add(const SelectOptionEditorEvent.newOption("aaaa"));
166180
await gridResponseFuture();
181+
expect(
182+
bloc.state.options.length,
183+
2,
184+
reason: "Options: ${bloc.state.options}",
185+
);
167186

168187
bloc.add(const SelectOptionEditorEvent.newOption("defg"));
169188
await gridResponseFuture();
189+
expect(
190+
bloc.state.options.length,
191+
3,
192+
reason: "Options: ${bloc.state.options}",
193+
);
170194

171195
bloc.add(const SelectOptionEditorEvent.filterOption("a"));
172196
await gridResponseFuture();
173197

174-
expect(bloc.state.options.length, 2);
175-
expect(bloc.state.allOptions.length, 3);
198+
expect(
199+
bloc.state.options.length,
200+
2,
201+
reason: "Options: ${bloc.state.options}",
202+
);
203+
expect(
204+
bloc.state.allOptions.length,
205+
3,
206+
reason: "Options: ${bloc.state.options}",
207+
);
176208
expect(bloc.state.createOption, const Some("a"));
177209
expect(bloc.state.filter, const Some("a"));
178210
});

0 commit comments

Comments
 (0)