Skip to content

Commit

Permalink
fix: Include Body settings not honored on fresh install
Browse files Browse the repository at this point in the history
closes #47
  • Loading branch information
sanzoghenzo committed Sep 27, 2023
1 parent c365938 commit 3b1cee0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ class _MyHomePageState extends State<MyHomePage> {
Future<bool> getSettings(String settingName,
{bool defaultValue = false}) async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
return prefs.getBool(settingName) ?? defaultValue;
var retrievedValue = prefs.getBool(settingName);
if (retrievedValue == null) {
prefs.setBool(settingName, defaultValue);
return defaultValue;
}
return retrievedValue;
}

setSettings(String name, bool value) async {
Expand Down Expand Up @@ -260,7 +265,7 @@ class _MyHomePageState extends State<MyHomePage> {
var readable = readableResults["html"] as String;
var author = readableResults["author"] as String;
var excerpt = readableResults["excerpt"] as String;
var markdown = await getSettings("includeBody")
var markdown = await getSettings("includeBody", defaultValue: true)
? html2md.convert(readable, styleOptions: {
"headingStyle": "atx",
"hr": "---",
Expand Down

0 comments on commit 3b1cee0

Please sign in to comment.