Skip to content

Commit

Permalink
chore: Merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
AnsahMohammad committed Feb 17, 2024
2 parents 38f6f12 + c159a5e commit a3c823a
Show file tree
Hide file tree
Showing 23 changed files with 710 additions and 160 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Release Notes
## Version 0.4.7 - 02/08/2024
## Version 0.4.8 - 02/13/2024
### Bug Fixes
- Fixed a possible error when loading workspaces

Expand Down
2 changes: 1 addition & 1 deletion frontend/Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true
CARGO_MAKE_CRATE_FS_NAME = "dart_ffi"
CARGO_MAKE_CRATE_NAME = "dart-ffi"
LIB_NAME = "dart_ffi"
APPFLOWY_VERSION = "0.4.7"
APPFLOWY_VERSION = "0.4.8"
FLUTTER_DESKTOP_FEATURES = "dart,rev-sqlite"
PRODUCT_NAME = "AppFlowy"
MACOSX_DEPLOYMENT_TARGET = "11.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../util/database_test_op.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

group('database filter', () {
group('grid filter:', () {
testWidgets('add text filter', (tester) async {
await tester.openV020database();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'dart:io';
import 'package:appflowy/workspace/presentation/settings/widgets/emoji_picker/emoji_picker.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:appflowy_editor/src/editor/editor_component/service/editor.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

import 'util/keyboard.dart';
import 'util/util.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// May be better to move this to an existing test but unsure what it fits with
group('Keyboard shortcuts related to emojis', () {
testWidgets('cmd/ctrl+alt+e shortcut opens the emoji picker',
(tester) async {
await tester.initializeAppFlowy();
await tester.tapGoButton();

final Finder editor = find.byType(AppFlowyEditor);
await tester.tap(editor);
await tester.pumpAndSettle();

expect(find.byType(EmojiSelectionMenu), findsNothing);

await FlowyTestKeyboard.simulateKeyDownEvent(
[
Platform.isMacOS
? LogicalKeyboardKey.meta
: LogicalKeyboardKey.control,
LogicalKeyboardKey.alt,
LogicalKeyboardKey.keyE,
],
tester: tester,
);

expect(find.byType(EmojiSelectionMenu), findsOneWidget);
});
});
}
2 changes: 2 additions & 0 deletions frontend/appflowy_flutter/integration_test/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import 'share_markdown_test.dart' as share_markdown_test;
import 'sidebar/sidebar_test_runner.dart' as sidebar_test_runner;
import 'switch_folder_test.dart' as switch_folder_test;
import 'tabs_test.dart' as tabs_test;
import 'emoji_shortcut_test.dart' as emoji_shortcut_test;
// import 'auth/supabase_auth_test.dart' as supabase_auth_test_runner;

/// The main task runner for all integration tests in AppFlowy.
Expand Down Expand Up @@ -69,6 +70,7 @@ Future<void> main() async {

// Others
hotkeys_test.main();
emoji_shortcut_test.main();

// Appearance integration test
appearance_test_runner.main();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:collection';

import 'package:appflowy/plugins/database/application/database_view_service.dart';
import 'package:appflowy/plugins/database/application/field_settings/field_settings_listener.dart';
import 'package:appflowy/plugins/database/application/field_settings/field_settings_service.dart';
Expand Down Expand Up @@ -333,6 +335,32 @@ class FieldController {
}
}

void updateFieldInfos(
List<SortInfo> newSortInfos,
SortChangesetNotificationPB changeset,
) {
final changedFieldIds = HashSet<String>.from([
...changeset.insertSorts.map((sort) => sort.sort.fieldId),
...changeset.updateSorts.map((sort) => sort.fieldId),
...changeset.deleteSorts.map((sort) => sort.fieldId),
]);

final newFieldInfos = [...fieldInfos];

for (final fieldId in changedFieldIds) {
final index =
newFieldInfos.indexWhere((fieldInfo) => fieldInfo.id == fieldId);
if (index == -1) {
continue;
}
newFieldInfos[index] = newFieldInfos[index].copyWith(
hasSort: newSortInfos.any((sort) => sort.fieldId == fieldId),
);
}

_fieldNotifier.fieldInfos = newFieldInfos;
}

_sortsListener.start(
onSortChanged: (result) {
if (_isDisposed) {
Expand All @@ -346,6 +374,7 @@ class FieldController {
updateSortFromChangeset(newSortInfos, changeset);

_sortNotifier?.sorts = newSortInfos;
updateFieldInfos(newSortInfos, changeset);
},
(err) => Log.error(err),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ class FieldInfo with _$FieldInfo {
}

bool get canCreateFilter {
if (hasFilter) return false;
if (hasFilter) {
return false;
}

switch (field.fieldType) {
case FieldType.Number:
case FieldType.Checkbox:
case FieldType.MultiSelect:
case FieldType.RichText:
Expand All @@ -62,7 +65,9 @@ class FieldInfo with _$FieldInfo {
}

bool get canCreateSort {
if (hasSort) return false;
if (hasSort) {
return false;
}

switch (field.fieldType) {
case FieldType.RichText:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import 'dart:async';

import 'package:appflowy/plugins/database/application/filter/filter_listener.dart';
import 'package:appflowy/plugins/database/application/filter/filter_service.dart';
import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_info.dart';
import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'number_filter_editor_bloc.freezed.dart';

class NumberFilterEditorBloc
extends Bloc<NumberFilterEditorEvent, NumberFilterEditorState> {
NumberFilterEditorBloc({required this.filterInfo})
: _filterBackendSvc = FilterBackendService(viewId: filterInfo.viewId),
_listener = FilterListener(
viewId: filterInfo.viewId,
filterId: filterInfo.filter.id,
),
super(NumberFilterEditorState.initial(filterInfo)) {
_dispatch();
_startListening();
}

final FilterInfo filterInfo;
final FilterBackendService _filterBackendSvc;
final FilterListener _listener;

void _dispatch() {
on<NumberFilterEditorEvent>(
(event, emit) async {
event.when(
didReceiveFilter: (filter) {
final filterInfo = state.filterInfo.copyWith(filter: filter);
emit(
state.copyWith(
filterInfo: filterInfo,
filter: filterInfo.numberFilter()!,
),
);
},
updateCondition: (NumberFilterConditionPB condition) {
_filterBackendSvc.insertNumberFilter(
filterId: filterInfo.filter.id,
fieldId: filterInfo.fieldInfo.id,
condition: condition,
content: state.filter.content,
);
},
updateContent: (content) {
_filterBackendSvc.insertNumberFilter(
filterId: filterInfo.filter.id,
fieldId: filterInfo.fieldInfo.id,
condition: state.filter.condition,
content: content,
);
},
delete: () {
_filterBackendSvc.deleteFilter(
fieldId: filterInfo.fieldInfo.id,
filterId: filterInfo.filter.id,
fieldType: filterInfo.fieldInfo.fieldType,
);
},
);
},
);
}

void _startListening() {
_listener.start(
onDeleted: () {
if (!isClosed) {
add(const NumberFilterEditorEvent.delete());
}
},
onUpdated: (filter) {
if (!isClosed) {
add(NumberFilterEditorEvent.didReceiveFilter(filter));
}
},
);
}

@override
Future<void> close() async {
await _listener.stop();
return super.close();
}
}

@freezed
class NumberFilterEditorEvent with _$NumberFilterEditorEvent {
const factory NumberFilterEditorEvent.didReceiveFilter(FilterPB filter) =
_DidReceiveFilter;
const factory NumberFilterEditorEvent.updateCondition(
NumberFilterConditionPB condition,
) = _UpdateCondition;
const factory NumberFilterEditorEvent.updateContent(String content) =
_UpdateContent;
const factory NumberFilterEditorEvent.delete() = _Delete;
}

@freezed
class NumberFilterEditorState with _$NumberFilterEditorState {
const factory NumberFilterEditorState({
required FilterInfo filterInfo,
required NumberFilterPB filter,
}) = _NumberFilterEditorState;

factory NumberFilterEditorState.initial(FilterInfo filterInfo) {
return NumberFilterEditorState(
filterInfo: filterInfo,
filter: filterInfo.numberFilter()!,
);
}
}
Loading

0 comments on commit a3c823a

Please sign in to comment.