瀏覽代碼

added reset appearance setting

appflowy 3 年之前
父節點
當前提交
728d60239a

+ 1 - 1
frontend/app_flowy/lib/startup/tasks/application_widget.dart

@@ -59,7 +59,7 @@ class ApplicationWidget extends StatelessWidget {
           const ratio = 1.73;
           const minWidth = 600.0;
           setWindowMinSize(const Size(minWidth, minWidth / ratio));
-          settingModel.updateWithBuildContext(context);
+          settingModel.readLocaleWhenAppLaunch(context);
           AppTheme theme = context.select<AppearanceSettingModel, AppTheme>(
             (value) => value.theme,
           );

+ 16 - 4
frontend/app_flowy/lib/workspace/application/appearance.dart

@@ -5,11 +5,13 @@ import 'package:flowy_infra/language.dart';
 import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_setting.pb.dart';
 import 'package:flutter/material.dart';
 import 'package:easy_localization/easy_localization.dart';
+import 'package:async/async.dart';
 
 class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
   AppearanceSettings setting;
   AppTheme _theme;
   AppLanguage _language;
+  CancelableOperation? _saveOperation;
 
   AppearanceSettingModel(this.setting)
       : _theme = AppTheme.fromName(name: setting.theme),
@@ -19,7 +21,12 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
   AppLanguage get language => _language;
 
   Future<void> save() async {
-    await UserSettingReppsitory().setAppearanceSettings(setting);
+    _saveOperation?.cancel;
+    _saveOperation = CancelableOperation.fromFuture(
+      Future.delayed(const Duration(seconds: 1), () async {
+        await UserSettingReppsitory().setAppearanceSettings(setting);
+      }),
+    );
   }
 
   @override
@@ -50,8 +57,13 @@ class AppearanceSettingModel extends ChangeNotifier with EquatableMixin {
     }
   }
 
-  void updateWithBuildContext(BuildContext context) {
-    final language = languageFromLocale(context.deviceLocale);
-    setLanguage(context, language);
+  void readLocaleWhenAppLaunch(BuildContext context) {
+    if (setting.resetAsDefault) {
+      setting.resetAsDefault = false;
+      save();
+
+      final language = languageFromLocale(context.deviceLocale);
+      setLanguage(context, language);
+    }
   }
 }

+ 30 - 0
frontend/app_flowy/packages/flowy_infra/lib/icon_data.dart

@@ -0,0 +1,30 @@
+/// Flutter icons FlowyIconData
+/// Copyright (C) 2021 by original authors @ fluttericon.com, fontello.com
+/// This font was generated by FlutterIcon.com, which is derived from Fontello.
+///
+/// To use this font, place it in your fonts/ directory and include the
+/// following in your pubspec.yaml
+///
+/// flutter:
+///   fonts:
+///    - family:  FlowyIconData
+///      fonts:
+///       - asset: fonts/FlowyIconData.ttf
+///
+///
+///
+// ignore_for_file: constant_identifier_names
+
+import 'package:flutter/widgets.dart';
+
+class FlowyIconData {
+  FlowyIconData._();
+
+  static const _kFontFam = 'FlowyIconData';
+  static const String? _kFontPkg = null;
+
+  static const IconData drop_down_hide =
+      IconData(0xe800, fontFamily: _kFontFam, fontPackage: _kFontPkg);
+  static const IconData drop_down_show =
+      IconData(0xe801, fontFamily: _kFontFam, fontPackage: _kFontPkg);
+}

+ 14 - 0
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/user_setting.pb.dart

@@ -76,6 +76,7 @@ class AppearanceSettings extends $pb.GeneratedMessage {
   static final $pb.BuilderInfo _i = $pb.BuilderInfo(const $core.bool.fromEnvironment('protobuf.omit_message_names') ? '' : 'AppearanceSettings', createEmptyInstance: create)
     ..aOS(1, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'theme')
     ..aOS(2, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'language')
+    ..aOB(3, const $core.bool.fromEnvironment('protobuf.omit_field_names') ? '' : 'resetAsDefault')
     ..hasRequiredFields = false
   ;
 
@@ -83,6 +84,7 @@ class AppearanceSettings extends $pb.GeneratedMessage {
   factory AppearanceSettings({
     $core.String? theme,
     $core.String? language,
+    $core.bool? resetAsDefault,
   }) {
     final _result = create();
     if (theme != null) {
@@ -91,6 +93,9 @@ class AppearanceSettings extends $pb.GeneratedMessage {
     if (language != null) {
       _result.language = language;
     }
+    if (resetAsDefault != null) {
+      _result.resetAsDefault = resetAsDefault;
+    }
     return _result;
   }
   factory AppearanceSettings.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r);
@@ -131,5 +136,14 @@ class AppearanceSettings extends $pb.GeneratedMessage {
   $core.bool hasLanguage() => $_has(1);
   @$pb.TagNumber(2)
   void clearLanguage() => clearField(2);
+
+  @$pb.TagNumber(3)
+  $core.bool get resetAsDefault => $_getBF(2);
+  @$pb.TagNumber(3)
+  set resetAsDefault($core.bool v) { $_setBool(2, v); }
+  @$pb.TagNumber(3)
+  $core.bool hasResetAsDefault() => $_has(2);
+  @$pb.TagNumber(3)
+  void clearResetAsDefault() => clearField(3);
 }
 

+ 2 - 1
frontend/app_flowy/packages/flowy_sdk/lib/protobuf/flowy-user-data-model/user_setting.pbjson.dart

@@ -25,8 +25,9 @@ const AppearanceSettings$json = const {
   '2': const [
     const {'1': 'theme', '3': 1, '4': 1, '5': 9, '10': 'theme'},
     const {'1': 'language', '3': 2, '4': 1, '5': 9, '10': 'language'},
+    const {'1': 'reset_as_default', '3': 3, '4': 1, '5': 8, '10': 'resetAsDefault'},
   ],
 };
 
 /// Descriptor for `AppearanceSettings`. Decode as a `google.protobuf.DescriptorProto`.
-final $typed_data.Uint8List appearanceSettingsDescriptor = $convert.base64Decode('ChJBcHBlYXJhbmNlU2V0dGluZ3MSFAoFdGhlbWUYASABKAlSBXRoZW1lEhoKCGxhbmd1YWdlGAIgASgJUghsYW5ndWFnZQ==');
+final $typed_data.Uint8List appearanceSettingsDescriptor = $convert.base64Decode('ChJBcHBlYXJhbmNlU2V0dGluZ3MSFAoFdGhlbWUYASABKAlSBXRoZW1lEhoKCGxhbmd1YWdlGAIgASgJUghsYW5ndWFnZRIoChByZXNldF9hc19kZWZhdWx0GAMgASgIUg5yZXNldEFzRGVmYXVsdA==');

+ 53 - 53
frontend/rust-lib/flowy-folder/src/protobuf/model/event_map.rs

@@ -156,59 +156,59 @@ static file_descriptor_proto_data: &'static [u8] = b"\
     \x10\n\x0bDeleteTrash\x10\xae\x02\x12\x14\n\x0fRestoreAllTrash\x10\xaf\
     \x02\x12\x13\n\x0eDeleteAllTrash\x10\xb0\x02\x12\x12\n\rApplyDocDelta\
     \x10\x90\x03\x12\x13\n\x0eExportDocument\x10\xf4\x03J\xab\x08\n\x06\x12\
-    \x04\0\0\x1b\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\
-    \x01\0\x1b\x01\n\n\n\x03\x05\0\x01\x12\x03\x01\x05\x10\n\x0b\n\x04\x05\0\
-    \x02\0\x12\x03\x02\x04\x18\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x02\x04\
-    \x13\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x02\x16\x17\n\x0b\n\x04\x05\0\
-    \x02\x01\x12\x03\x03\x04\x19\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x03\
-    \x04\x14\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x03\x17\x18\n\x0b\n\x04\
-    \x05\0\x02\x02\x12\x03\x04\x04\x17\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\
-    \x04\x04\x12\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x04\x15\x16\n\x0b\n\
-    \x04\x05\0\x02\x03\x12\x03\x05\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\
-    \x03\x05\x04\x13\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x05\x16\x17\n\x0b\
-    \n\x04\x05\0\x02\x04\x12\x03\x06\x04\x16\n\x0c\n\x05\x05\0\x02\x04\x01\
-    \x12\x03\x06\x04\x11\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x06\x14\x15\n\
-    \x0b\n\x04\x05\0\x02\x05\x12\x03\x07\x04\x1a\n\x0c\n\x05\x05\0\x02\x05\
-    \x01\x12\x03\x07\x04\x15\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x07\x18\
-    \x19\n\x0b\n\x04\x05\0\x02\x06\x12\x03\x08\x04\x14\n\x0c\n\x05\x05\0\x02\
-    \x06\x01\x12\x03\x08\x04\r\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\x08\x10\
-    \x13\n\x0b\n\x04\x05\0\x02\x07\x12\x03\t\x04\x14\n\x0c\n\x05\x05\0\x02\
-    \x07\x01\x12\x03\t\x04\r\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\t\x10\x13\
-    \n\x0b\n\x04\x05\0\x02\x08\x12\x03\n\x04\x12\n\x0c\n\x05\x05\0\x02\x08\
-    \x01\x12\x03\n\x04\x0b\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\n\x0e\x11\n\
-    \x0b\n\x04\x05\0\x02\t\x12\x03\x0b\x04\x14\n\x0c\n\x05\x05\0\x02\t\x01\
-    \x12\x03\x0b\x04\r\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x0b\x10\x13\n\x0b\
-    \n\x04\x05\0\x02\n\x12\x03\x0c\x04\x15\n\x0c\n\x05\x05\0\x02\n\x01\x12\
-    \x03\x0c\x04\x0e\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\x0c\x11\x14\n\x0b\n\
-    \x04\x05\0\x02\x0b\x12\x03\r\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\
-    \x03\r\x04\x0c\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\r\x0f\x12\n\x0b\n\
-    \x04\x05\0\x02\x0c\x12\x03\x0e\x04\x15\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\
-    \x03\x0e\x04\x0e\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x0e\x11\x14\n\x0b\
-    \n\x04\x05\0\x02\r\x12\x03\x0f\x04\x15\n\x0c\n\x05\x05\0\x02\r\x01\x12\
-    \x03\x0f\x04\x0e\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x0f\x11\x14\n\x0b\n\
-    \x04\x05\0\x02\x0e\x12\x03\x10\x04\x18\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\
-    \x03\x10\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x10\x14\x17\n\x0b\
-    \n\x04\x05\0\x02\x0f\x12\x03\x11\x04\x13\n\x0c\n\x05\x05\0\x02\x0f\x01\
-    \x12\x03\x11\x04\x0c\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x11\x0f\x12\n\
-    \x0b\n\x04\x05\0\x02\x10\x12\x03\x12\x04\x17\n\x0c\n\x05\x05\0\x02\x10\
-    \x01\x12\x03\x12\x04\x10\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x12\x13\
-    \x16\n\x0b\n\x04\x05\0\x02\x11\x12\x03\x13\x04\x14\n\x0c\n\x05\x05\0\x02\
-    \x11\x01\x12\x03\x13\x04\r\n\x0c\n\x05\x05\0\x02\x11\x02\x12\x03\x13\x10\
-    \x13\n\x0b\n\x04\x05\0\x02\x12\x12\x03\x14\x04\x14\n\x0c\n\x05\x05\0\x02\
-    \x12\x01\x12\x03\x14\x04\r\n\x0c\n\x05\x05\0\x02\x12\x02\x12\x03\x14\x10\
-    \x13\n\x0b\n\x04\x05\0\x02\x13\x12\x03\x15\x04\x17\n\x0c\n\x05\x05\0\x02\
-    \x13\x01\x12\x03\x15\x04\x10\n\x0c\n\x05\x05\0\x02\x13\x02\x12\x03\x15\
-    \x13\x16\n\x0b\n\x04\x05\0\x02\x14\x12\x03\x16\x04\x16\n\x0c\n\x05\x05\0\
-    \x02\x14\x01\x12\x03\x16\x04\x0f\n\x0c\n\x05\x05\0\x02\x14\x02\x12\x03\
-    \x16\x12\x15\n\x0b\n\x04\x05\0\x02\x15\x12\x03\x17\x04\x1a\n\x0c\n\x05\
-    \x05\0\x02\x15\x01\x12\x03\x17\x04\x13\n\x0c\n\x05\x05\0\x02\x15\x02\x12\
-    \x03\x17\x16\x19\n\x0b\n\x04\x05\0\x02\x16\x12\x03\x18\x04\x19\n\x0c\n\
-    \x05\x05\0\x02\x16\x01\x12\x03\x18\x04\x12\n\x0c\n\x05\x05\0\x02\x16\x02\
-    \x12\x03\x18\x15\x18\n\x0b\n\x04\x05\0\x02\x17\x12\x03\x19\x04\x18\n\x0c\
-    \n\x05\x05\0\x02\x17\x01\x12\x03\x19\x04\x11\n\x0c\n\x05\x05\0\x02\x17\
-    \x02\x12\x03\x19\x14\x17\n\x0b\n\x04\x05\0\x02\x18\x12\x03\x1a\x04\x19\n\
-    \x0c\n\x05\x05\0\x02\x18\x01\x12\x03\x1a\x04\x12\n\x0c\n\x05\x05\0\x02\
-    \x18\x02\x12\x03\x1a\x15\x18b\x06proto3\
+    \x04\0\0\x1c\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x05\0\x12\x04\
+    \x02\0\x1c\x01\n\n\n\x03\x05\0\x01\x12\x03\x02\x05\x10\n\x0b\n\x04\x05\0\
+    \x02\0\x12\x03\x03\x04\x18\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x03\x04\
+    \x13\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\x16\x17\n\x0b\n\x04\x05\0\
+    \x02\x01\x12\x03\x04\x04\x19\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x04\
+    \x04\x14\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\x17\x18\n\x0b\n\x04\
+    \x05\0\x02\x02\x12\x03\x05\x04\x17\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\
+    \x05\x04\x12\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\x05\x15\x16\n\x0b\n\
+    \x04\x05\0\x02\x03\x12\x03\x06\x04\x18\n\x0c\n\x05\x05\0\x02\x03\x01\x12\
+    \x03\x06\x04\x13\n\x0c\n\x05\x05\0\x02\x03\x02\x12\x03\x06\x16\x17\n\x0b\
+    \n\x04\x05\0\x02\x04\x12\x03\x07\x04\x16\n\x0c\n\x05\x05\0\x02\x04\x01\
+    \x12\x03\x07\x04\x11\n\x0c\n\x05\x05\0\x02\x04\x02\x12\x03\x07\x14\x15\n\
+    \x0b\n\x04\x05\0\x02\x05\x12\x03\x08\x04\x1a\n\x0c\n\x05\x05\0\x02\x05\
+    \x01\x12\x03\x08\x04\x15\n\x0c\n\x05\x05\0\x02\x05\x02\x12\x03\x08\x18\
+    \x19\n\x0b\n\x04\x05\0\x02\x06\x12\x03\t\x04\x14\n\x0c\n\x05\x05\0\x02\
+    \x06\x01\x12\x03\t\x04\r\n\x0c\n\x05\x05\0\x02\x06\x02\x12\x03\t\x10\x13\
+    \n\x0b\n\x04\x05\0\x02\x07\x12\x03\n\x04\x14\n\x0c\n\x05\x05\0\x02\x07\
+    \x01\x12\x03\n\x04\r\n\x0c\n\x05\x05\0\x02\x07\x02\x12\x03\n\x10\x13\n\
+    \x0b\n\x04\x05\0\x02\x08\x12\x03\x0b\x04\x12\n\x0c\n\x05\x05\0\x02\x08\
+    \x01\x12\x03\x0b\x04\x0b\n\x0c\n\x05\x05\0\x02\x08\x02\x12\x03\x0b\x0e\
+    \x11\n\x0b\n\x04\x05\0\x02\t\x12\x03\x0c\x04\x14\n\x0c\n\x05\x05\0\x02\t\
+    \x01\x12\x03\x0c\x04\r\n\x0c\n\x05\x05\0\x02\t\x02\x12\x03\x0c\x10\x13\n\
+    \x0b\n\x04\x05\0\x02\n\x12\x03\r\x04\x15\n\x0c\n\x05\x05\0\x02\n\x01\x12\
+    \x03\r\x04\x0e\n\x0c\n\x05\x05\0\x02\n\x02\x12\x03\r\x11\x14\n\x0b\n\x04\
+    \x05\0\x02\x0b\x12\x03\x0e\x04\x13\n\x0c\n\x05\x05\0\x02\x0b\x01\x12\x03\
+    \x0e\x04\x0c\n\x0c\n\x05\x05\0\x02\x0b\x02\x12\x03\x0e\x0f\x12\n\x0b\n\
+    \x04\x05\0\x02\x0c\x12\x03\x0f\x04\x15\n\x0c\n\x05\x05\0\x02\x0c\x01\x12\
+    \x03\x0f\x04\x0e\n\x0c\n\x05\x05\0\x02\x0c\x02\x12\x03\x0f\x11\x14\n\x0b\
+    \n\x04\x05\0\x02\r\x12\x03\x10\x04\x15\n\x0c\n\x05\x05\0\x02\r\x01\x12\
+    \x03\x10\x04\x0e\n\x0c\n\x05\x05\0\x02\r\x02\x12\x03\x10\x11\x14\n\x0b\n\
+    \x04\x05\0\x02\x0e\x12\x03\x11\x04\x18\n\x0c\n\x05\x05\0\x02\x0e\x01\x12\
+    \x03\x11\x04\x11\n\x0c\n\x05\x05\0\x02\x0e\x02\x12\x03\x11\x14\x17\n\x0b\
+    \n\x04\x05\0\x02\x0f\x12\x03\x12\x04\x13\n\x0c\n\x05\x05\0\x02\x0f\x01\
+    \x12\x03\x12\x04\x0c\n\x0c\n\x05\x05\0\x02\x0f\x02\x12\x03\x12\x0f\x12\n\
+    \x0b\n\x04\x05\0\x02\x10\x12\x03\x13\x04\x17\n\x0c\n\x05\x05\0\x02\x10\
+    \x01\x12\x03\x13\x04\x10\n\x0c\n\x05\x05\0\x02\x10\x02\x12\x03\x13\x13\
+    \x16\n\x0b\n\x04\x05\0\x02\x11\x12\x03\x14\x04\x14\n\x0c\n\x05\x05\0\x02\
+    \x11\x01\x12\x03\x14\x04\r\n\x0c\n\x05\x05\0\x02\x11\x02\x12\x03\x14\x10\
+    \x13\n\x0b\n\x04\x05\0\x02\x12\x12\x03\x15\x04\x14\n\x0c\n\x05\x05\0\x02\
+    \x12\x01\x12\x03\x15\x04\r\n\x0c\n\x05\x05\0\x02\x12\x02\x12\x03\x15\x10\
+    \x13\n\x0b\n\x04\x05\0\x02\x13\x12\x03\x16\x04\x17\n\x0c\n\x05\x05\0\x02\
+    \x13\x01\x12\x03\x16\x04\x10\n\x0c\n\x05\x05\0\x02\x13\x02\x12\x03\x16\
+    \x13\x16\n\x0b\n\x04\x05\0\x02\x14\x12\x03\x17\x04\x16\n\x0c\n\x05\x05\0\
+    \x02\x14\x01\x12\x03\x17\x04\x0f\n\x0c\n\x05\x05\0\x02\x14\x02\x12\x03\
+    \x17\x12\x15\n\x0b\n\x04\x05\0\x02\x15\x12\x03\x18\x04\x1a\n\x0c\n\x05\
+    \x05\0\x02\x15\x01\x12\x03\x18\x04\x13\n\x0c\n\x05\x05\0\x02\x15\x02\x12\
+    \x03\x18\x16\x19\n\x0b\n\x04\x05\0\x02\x16\x12\x03\x19\x04\x19\n\x0c\n\
+    \x05\x05\0\x02\x16\x01\x12\x03\x19\x04\x12\n\x0c\n\x05\x05\0\x02\x16\x02\
+    \x12\x03\x19\x15\x18\n\x0b\n\x04\x05\0\x02\x17\x12\x03\x1a\x04\x18\n\x0c\
+    \n\x05\x05\0\x02\x17\x01\x12\x03\x1a\x04\x11\n\x0c\n\x05\x05\0\x02\x17\
+    \x02\x12\x03\x1a\x14\x17\n\x0b\n\x04\x05\0\x02\x18\x12\x03\x1b\x04\x19\n\
+    \x0c\n\x05\x05\0\x02\x18\x01\x12\x03\x1b\x04\x12\n\x0c\n\x05\x05\0\x02\
+    \x18\x02\x12\x03\x1b\x15\x18b\x06proto3\
 ";
 
 static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

+ 1 - 0
frontend/rust-lib/flowy-folder/src/protobuf/proto/event_map.proto

@@ -1,4 +1,5 @@
 syntax = "proto3";
+
 enum FolderEvent {
     CreateWorkspace = 0;
     ReadCurWorkspace = 1;

+ 10 - 0
shared-lib/flowy-user-data-model/src/entities/user_setting.rs

@@ -17,16 +17,26 @@ pub struct AppearanceSettings {
 
     #[pb(index = 2)]
     pub language: String,
+
+    #[pb(index = 3)]
+    #[serde(default = "reset_default_value")]
+    pub reset_as_default: bool,
+}
+
+fn reset_default_value() -> bool {
+    APPEARANCE_RESET_AS_DEFAULT
 }
 
 pub const APPEARANCE_DEFAULT_THEME: &str = "light";
 pub const APPEARANCE_DEFAULT_LANGUAGE: &str = "en";
+pub const APPEARANCE_RESET_AS_DEFAULT: bool = true;
 
 impl std::default::Default for AppearanceSettings {
     fn default() -> Self {
         AppearanceSettings {
             theme: APPEARANCE_DEFAULT_THEME.to_owned(),
             language: APPEARANCE_DEFAULT_LANGUAGE.to_owned(),
+            reset_as_default: APPEARANCE_RESET_AS_DEFAULT,
         }
     }
 }

+ 55 - 16
shared-lib/flowy-user-data-model/src/protobuf/model/user_setting.rs

@@ -244,6 +244,7 @@ pub struct AppearanceSettings {
     // message fields
     pub theme: ::std::string::String,
     pub language: ::std::string::String,
+    pub reset_as_default: bool,
     // special fields
     pub unknown_fields: ::protobuf::UnknownFields,
     pub cached_size: ::protobuf::CachedSize,
@@ -311,6 +312,21 @@ impl AppearanceSettings {
     pub fn take_language(&mut self) -> ::std::string::String {
         ::std::mem::replace(&mut self.language, ::std::string::String::new())
     }
+
+    // bool reset_as_default = 3;
+
+
+    pub fn get_reset_as_default(&self) -> bool {
+        self.reset_as_default
+    }
+    pub fn clear_reset_as_default(&mut self) {
+        self.reset_as_default = false;
+    }
+
+    // Param is passed by value, moved
+    pub fn set_reset_as_default(&mut self, v: bool) {
+        self.reset_as_default = v;
+    }
 }
 
 impl ::protobuf::Message for AppearanceSettings {
@@ -328,6 +344,13 @@ impl ::protobuf::Message for AppearanceSettings {
                 2 => {
                     ::protobuf::rt::read_singular_proto3_string_into(wire_type, is, &mut self.language)?;
                 },
+                3 => {
+                    if wire_type != ::protobuf::wire_format::WireTypeVarint {
+                        return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type));
+                    }
+                    let tmp = is.read_bool()?;
+                    self.reset_as_default = tmp;
+                },
                 _ => {
                     ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?;
                 },
@@ -346,6 +369,9 @@ impl ::protobuf::Message for AppearanceSettings {
         if !self.language.is_empty() {
             my_size += ::protobuf::rt::string_size(2, &self.language);
         }
+        if self.reset_as_default != false {
+            my_size += 2;
+        }
         my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields());
         self.cached_size.set(my_size);
         my_size
@@ -358,6 +384,9 @@ impl ::protobuf::Message for AppearanceSettings {
         if !self.language.is_empty() {
             os.write_string(2, &self.language)?;
         }
+        if self.reset_as_default != false {
+            os.write_bool(3, self.reset_as_default)?;
+        }
         os.write_unknown_fields(self.get_unknown_fields())?;
         ::std::result::Result::Ok(())
     }
@@ -406,6 +435,11 @@ impl ::protobuf::Message for AppearanceSettings {
                 |m: &AppearanceSettings| { &m.language },
                 |m: &mut AppearanceSettings| { &mut m.language },
             ));
+            fields.push(::protobuf::reflect::accessor::make_simple_field_accessor::<_, ::protobuf::types::ProtobufTypeBool>(
+                "reset_as_default",
+                |m: &AppearanceSettings| { &m.reset_as_default },
+                |m: &mut AppearanceSettings| { &mut m.reset_as_default },
+            ));
             ::protobuf::reflect::MessageDescriptor::new_pb_name::<AppearanceSettings>(
                 "AppearanceSettings",
                 fields,
@@ -424,6 +458,7 @@ impl ::protobuf::Clear for AppearanceSettings {
     fn clear(&mut self) {
         self.theme.clear();
         self.language.clear();
+        self.reset_as_default = false;
         self.unknown_fields.clear();
     }
 }
@@ -443,23 +478,27 @@ impl ::protobuf::reflect::ProtobufValue for AppearanceSettings {
 static file_descriptor_proto_data: &'static [u8] = b"\
     \n\x12user_setting.proto\"n\n\x0fUserPreferences\x12\x17\n\x07user_id\
     \x18\x01\x20\x01(\tR\x06userId\x12B\n\x12appearance_setting\x18\x02\x20\
-    \x01(\x0b2\x13.AppearanceSettingsR\x11appearanceSetting\"F\n\x12Appearan\
+    \x01(\x0b2\x13.AppearanceSettingsR\x11appearanceSetting\"p\n\x12Appearan\
     ceSettings\x12\x14\n\x05theme\x18\x01\x20\x01(\tR\x05theme\x12\x1a\n\x08\
-    language\x18\x02\x20\x01(\tR\x08languageJ\x9e\x02\n\x06\x12\x04\0\0\t\
-    \x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\
-    \x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x17\n\x0b\n\x04\x04\0\x02\0\x12\
-    \x03\x03\x04\x17\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\
-    \x05\x04\0\x02\0\x01\x12\x03\x03\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\
-    \x03\x03\x15\x16\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04.\n\x0c\n\x05\
-    \x04\0\x02\x01\x06\x12\x03\x04\x04\x16\n\x0c\n\x05\x04\0\x02\x01\x01\x12\
-    \x03\x04\x17)\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04,-\n\n\n\x02\x04\
-    \x01\x12\x04\x06\0\t\x01\n\n\n\x03\x04\x01\x01\x12\x03\x06\x08\x1a\n\x0b\
-    \n\x04\x04\x01\x02\0\x12\x03\x07\x04\x15\n\x0c\n\x05\x04\x01\x02\0\x05\
-    \x12\x03\x07\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\x07\x0b\x10\n\
-    \x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x07\x13\x14\n\x0b\n\x04\x04\x01\x02\
-    \x01\x12\x03\x08\x04\x18\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\x08\x04\
-    \n\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x08\x0b\x13\n\x0c\n\x05\x04\
-    \x01\x02\x01\x03\x12\x03\x08\x16\x17b\x06proto3\
+    language\x18\x02\x20\x01(\tR\x08language\x12(\n\x10reset_as_default\x18\
+    \x03\x20\x01(\x08R\x0eresetAsDefaultJ\xd5\x02\n\x06\x12\x04\0\0\n\x01\n\
+    \x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\x05\x01\n\n\
+    \n\x03\x04\0\x01\x12\x03\x02\x08\x17\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\
+    \x04\x17\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\x04\n\n\x0c\n\x05\x04\0\
+    \x02\0\x01\x12\x03\x03\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03\
+    \x15\x16\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\x04.\n\x0c\n\x05\x04\0\
+    \x02\x01\x06\x12\x03\x04\x04\x16\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\
+    \x04\x17)\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04,-\n\n\n\x02\x04\x01\
+    \x12\x04\x06\0\n\x01\n\n\n\x03\x04\x01\x01\x12\x03\x06\x08\x1a\n\x0b\n\
+    \x04\x04\x01\x02\0\x12\x03\x07\x04\x15\n\x0c\n\x05\x04\x01\x02\0\x05\x12\
+    \x03\x07\x04\n\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\x07\x0b\x10\n\x0c\n\
+    \x05\x04\x01\x02\0\x03\x12\x03\x07\x13\x14\n\x0b\n\x04\x04\x01\x02\x01\
+    \x12\x03\x08\x04\x18\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\x08\x04\n\n\
+    \x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x08\x0b\x13\n\x0c\n\x05\x04\x01\
+    \x02\x01\x03\x12\x03\x08\x16\x17\n\x0b\n\x04\x04\x01\x02\x02\x12\x03\t\
+    \x04\x1e\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\t\x04\x08\n\x0c\n\x05\
+    \x04\x01\x02\x02\x01\x12\x03\t\t\x19\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\
+    \x03\t\x1c\x1db\x06proto3\
 ";
 
 static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT;

+ 1 - 0
shared-lib/flowy-user-data-model/src/protobuf/proto/user_setting.proto

@@ -7,4 +7,5 @@ message UserPreferences {
 message AppearanceSettings {
     string theme = 1;
     string language = 2;
+    bool reset_as_default = 3;
 }