Skip to content

Commit

Permalink
Merge pull request #345 from Sivan22:docs/add_comments_and_docstrings
Browse files Browse the repository at this point in the history
docs: fix app_model.dart documentation
  • Loading branch information
Sivan22 authored Nov 25, 2024
2 parents 5c73811 + 62cadce commit 83eabf5
Show file tree
Hide file tree
Showing 5 changed files with 123 additions and 73 deletions.
2 changes: 0 additions & 2 deletions lib/data/data_providers/cache_provider.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'package:flutter_settings_screens/flutter_settings_screens.dart';
import 'package:path_provider/path_provider.dart';
Expand All @@ -11,7 +10,6 @@ class HiveCache extends CacheProvider {

@override
Future<void> init() async {
WidgetsFlutterBinding.ensureInitialized();
if (!kIsWeb) {
final defaultDirectory = await getApplicationSupportDirectory();
_preferences = Hive.box(name: keyName, directory: defaultDirectory.path);
Expand Down
5 changes: 1 addition & 4 deletions lib/data/data_providers/file_system_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,7 @@ class FileSystemData {
/// file system paths, excluding PDF files.
Future<Map<String, String>> _getTitleToPath() async {
Map<String, String> titleToPath = {};
if (!Settings.isInitialized) {
await Settings.init(cacheProvider: HiveCache());
}
final libraryPath = Settings.getValue('key-library-path');
final libraryPath = Settings.getValue('key-library-path') ?? 'C:\\אוצריא';
List<String> paths = await getAllBooksPathsFromDirecctory(libraryPath);
for (var path in paths) {
if (path.toLowerCase().endsWith('.pdf')) continue;
Expand Down
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ Future<void> createDirs() async {
/// For Windows, defaults to 'C:/אוצריא' if not previously set.
/// For other platforms, uses the existing settings value.
Future<void> initLibraryPath() async {
if (!Settings.isInitialized) {
await Settings.init(cacheProvider: HiveCache());
}
if (Platform.isAndroid || Platform.isIOS) {
// Mobile platforms use the app's documents directory
await Settings.setValue(
Expand Down
Loading

0 comments on commit 83eabf5

Please sign in to comment.