mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-12-28 05:34:41 +00:00
fix: workspace name conflicts (#7992)
This commit is contained in:
parent
29f8f0d317
commit
c78564ea79
@ -241,7 +241,9 @@ class _WorkspaceNameSetting extends StatefulWidget {
|
||||
class _WorkspaceNameSettingState extends State<_WorkspaceNameSetting> {
|
||||
final TextEditingController workspaceNameController = TextEditingController();
|
||||
final focusNode = FocusNode();
|
||||
Timer? _debounce;
|
||||
|
||||
Timer? debounce;
|
||||
bool isSaving = false;
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
@ -254,6 +256,10 @@ class _WorkspaceNameSettingState extends State<_WorkspaceNameSetting> {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocConsumer<WorkspaceSettingsBloc, WorkspaceSettingsState>(
|
||||
listener: (_, state) {
|
||||
if (isSaving) {
|
||||
return;
|
||||
}
|
||||
|
||||
final newName = state.workspace?.name;
|
||||
if (newName != null && newName != workspaceNameController.text) {
|
||||
workspaceNameController.text = newName;
|
||||
@ -287,10 +293,15 @@ class _WorkspaceNameSettingState extends State<_WorkspaceNameSetting> {
|
||||
}
|
||||
|
||||
void _debounceSaveName(String name) {
|
||||
_debounce?.cancel();
|
||||
_debounce = Timer(
|
||||
isSaving = true;
|
||||
|
||||
debounce?.cancel();
|
||||
debounce = Timer(
|
||||
const Duration(milliseconds: 300),
|
||||
() => _saveWorkspaceName(name: name),
|
||||
() {
|
||||
_saveWorkspaceName(name: name);
|
||||
isSaving = false;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user