Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cleanup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import re

with open('lib/core/theme/theme_registry_service.dart', 'r') as f:
content = f.read()

# Fix curly_braces_in_flow_control_structures
content = content.replace("if (!await directory.exists()) continue;", "if (!await directory.exists()) { continue; }")

# Fix unnecessary_brace_in_string_interps
content = content.replace("'${slug}-$counter'", "'$slug-$counter'")
content = content.replace("'${preferredBaseName}-$counter'", "'$preferredBaseName-$counter'")

# Fix unused hash
content = content.replace("final hash = _contentHash(raw);\n final json = _decodeRoot(raw);", "final json = _decodeRoot(raw);")
content = content.replace("final hash = _contentHash(raw);\n final json = _decodeRoot(raw);", "final json = _decodeRoot(raw);") # Handle multiple occurrences if any

# Remove unused methods
methods_to_remove = [
r'Future<void> _scanDirectory.*?^\s*\}\s*',
r'Future<_ResolvedImportDestination> _resolveImportDestination.*?^\s*\}\s*',
r'Future<String> _nextRenamedThemeId.*?^\s*\}\s*',
r'Future<bool> _themeIdExists.*?^\s*\}\s*',
r'Future<File> _nextAvailableThemeFile.*?^\s*\}\s*',
r'String _rewriteCustomThemeId.*?^\s*\}\s*',
r'class _ResolvedImportDestination.*?^\}\s*'
]

for pattern in methods_to_remove:
content = re.sub(pattern, '', content, flags=re.DOTALL | re.MULTILINE)

with open('lib/core/theme/theme_registry_service.dart', 'w') as f:
f.write(content)
6 changes: 3 additions & 3 deletions lib/core/theme/theme_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import 'theme_definition.dart';
import 'theme_folder_watcher.dart';
import 'theme_import_service.dart';
import 'theme_load_result.dart';
import 'theme_paths.dart';
import 'theme_registry_service.dart';
import 'theme_remote_install_service.dart';
import '../extensions/extension_paths.dart';

/// Active theme state: preset, optional imported colors, user overrides.
class ThemeController extends ChangeNotifier {
Expand Down Expand Up @@ -214,10 +214,10 @@ class ThemeController extends ChangeNotifier {
}
}

/// Watches `{appSupport}/themes/` and debounces [loadAvailableThemes].
/// Watches extensions directory and debounces [loadAvailableThemes].
Future<void> startThemeFolderWatcher() async {
_themeFolderWatcher ??= ThemeFolderWatcher(
themesDirectory: ThemePaths.userThemesDirectory,
themesDirectory: ExtensionPaths.extensionsDirectory,
onThemesChanged: loadAvailableThemes,
);
await _themeFolderWatcher!.start();
Expand Down
Loading
Loading