Skip to content

Commit 64dff44

Browse files
authored
fix: revert some date picker code and fix notification issue (#7861)
* fix: revert some date picker code and fix notification issue * fix: UI overflow issue * chore: update reminder remove logic
1 parent 8b1eb49 commit 64dff44

File tree

8 files changed

+230
-114
lines changed

8 files changed

+230
-114
lines changed

frontend/appflowy_flutter/lib/plugins/database/application/cell/bloc/date_cell_editor_bloc.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ class DateCellEditorBloc
5555
didReceiveCellUpdate: (DateCellDataPB? cellData) {
5656
final dateCellData = DateCellData.fromPB(cellData);
5757

58-
ReminderOption reminderOption = ReminderOption.none;
58+
ReminderOption reminderOption = state.reminderOption;
5959

6060
if (dateCellData.reminderId.isNotEmpty &&
61-
dateCellData.dateTime != null) {
61+
dateCellData.dateTime != null &&
62+
reminderOption != ReminderOption.none) {
6263
final reminder = _reminderBloc.state.reminders
6364
.firstWhereOrNull((r) => r.id == dateCellData.reminderId);
6465
if (reminder != null) {
@@ -119,6 +120,7 @@ class DateCellEditorBloc
119120
await _clearDate();
120121
},
121122
setReminderOption: (ReminderOption option) async {
123+
emit(state.copyWith(reminderOption: option));
122124
await _setReminderOption(option);
123125
},
124126
);
@@ -246,9 +248,7 @@ class DateCellEditorBloc
246248
void _updateReminderIfNecessary(
247249
DateTime? dateTime,
248250
) {
249-
if (state.reminderId.isEmpty ||
250-
state.reminderOption == ReminderOption.none ||
251-
dateTime == null) {
251+
if (state.reminderId.isEmpty || dateTime == null) {
252252
return;
253253
}
254254

@@ -400,7 +400,7 @@ class DateCellEditorState with _$DateCellEditorState {
400400
ReminderOption reminderOption = ReminderOption.none;
401401

402402
if (dateCellData.reminderId.isNotEmpty && dateCellData.dateTime != null) {
403-
final reminder = reminderBloc.state.reminders
403+
final reminder = reminderBloc.state.allReminders
404404
.firstWhereOrNull((r) => r.id == dateCellData.reminderId);
405405
if (reminder != null) {
406406
final eventDate = dateCellData.includeTime

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/desktop_toolbar/link/link_search_text_field.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ class LinkSearchTextField {
7878
focusNode: focusNode,
7979
textAlign: TextAlign.left,
8080
controller: textEditingController,
81-
style: textStyle ?? TextStyle(
82-
fontSize: 14,
83-
height: 20 / 14,
84-
fontWeight: FontWeight.w400,
85-
),
81+
style: textStyle ??
82+
TextStyle(
83+
fontSize: 14,
84+
height: 20 / 14,
85+
fontWeight: FontWeight.w400,
86+
),
8687
onChanged: (text) {
8788
if (text.isEmpty) {
8889
searchedViews.clear();

frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/mention/mention_date_block.dart

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
6363
late bool _includeTime = widget.includeTime;
6464
late DateTime? parsedDate = DateTime.tryParse(widget.date);
6565
late String? _reminderId = widget.reminderId;
66+
late ReminderOption _reminderOption = widget.reminderOption;
6667

6768
ReminderPB? getReminder(BuildContext context) {
68-
if (!context.mounted) return null;
69+
if (!context.mounted || _reminderId == null) return null;
6970
final reminderBloc = context.read<ReminderBloc?>();
70-
return reminderBloc?.state.serverReminders
71+
return reminderBloc?.state.allReminders
7172
.firstWhereOrNull((r) => r.id == _reminderId);
7273
}
7374

@@ -115,11 +116,11 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
115116
includeTime: _includeTime,
116117
dateFormat: appearance.dateFormat,
117118
timeFormat: appearance.timeFormat,
118-
selectedReminderOption: widget.reminderOption,
119+
selectedReminderOption: _reminderOption,
119120
onIncludeTimeChanged: (includeTime, dateTime, _) {
120121
_includeTime = includeTime;
121122

122-
if (widget.reminderOption != ReminderOption.none) {
123+
if (_reminderOption != ReminderOption.none) {
123124
_updateReminder(
124125
widget.reminderOption,
125126
context,
@@ -136,18 +137,26 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
136137
onDaySelected: (selectedDay) {
137138
parsedDate = selectedDay;
138139

139-
if (widget.reminderOption != ReminderOption.none) {
140+
if (_reminderOption != ReminderOption.none) {
140141
_updateReminder(
141-
widget.reminderOption,
142+
_reminderOption,
142143
context,
143144
_includeTime,
144145
);
145146
} else {
147+
final rootContext = widget.editorState.document.root.context;
148+
if (rootContext != null && _reminderId != null) {
149+
rootContext
150+
.read<ReminderBloc?>()
151+
?.add(ReminderEvent.remove(reminderId: _reminderId!));
152+
}
146153
_updateBlock(selectedDay, includeTime: _includeTime);
147154
}
148155
},
149-
onReminderSelected: (reminderOption) =>
150-
_updateReminder(reminderOption, context, _includeTime),
156+
onReminderSelected: (reminderOption) {
157+
_reminderOption = reminderOption;
158+
_updateReminder(reminderOption, context, _includeTime);
159+
},
151160
);
152161

153162
Color? color;
@@ -245,7 +254,7 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
245254
if (parsedDate == null || rootContext == null) {
246255
return;
247256
}
248-
final reminder = getReminder(context);
257+
final reminder = getReminder(rootContext);
249258
if (reminder != null) {
250259
_updateBlock(
251260
parsedDate!,
@@ -273,8 +282,8 @@ class _MentionDateBlockState extends State<MentionDateBlock> {
273282
);
274283
}
275284

276-
final reminderId = nanoid();
277-
_reminderId = reminderId;
285+
_reminderId ??= nanoid();
286+
final reminderId = _reminderId;
278287
_updateBlock(
279288
parsedDate!,
280289
includeTime: includeTime,

0 commit comments

Comments
 (0)