Skip to content

Commit

Permalink
Merge pull request AY2425S1-CS2103T-W12-3#156 from SlothyCat/fix-swit…
Browse files Browse the repository at this point in the history
…ch-bug

Fix Switch Command Bug
  • Loading branch information
SlothyCat authored Nov 7, 2024
2 parents 662c8ca + 110c0e2 commit 67c59ae
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/seedu/address/storage/ThemePreference.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ private Optional<String> loadThemePreference() {
}

/**
* Saves the current theme preference to the JSON file.
* Saves the current theme preference to the JSON file after ensuring data directory exists
*
* @param theme The theme to save ('light' or 'dark').
*/
public void saveThemePreference(String theme) {
this.theme = theme;
try {
// Ensure the data directory exists
if (!Files.exists(THEME_PREF_FILE_PATH.getParent())) {
Files.createDirectories(THEME_PREF_FILE_PATH.getParent());
}
JsonUtil.saveJsonFile(theme, THEME_PREF_FILE_PATH);
} catch (IOException e) {
logger.log(Level.WARNING, "Unable to save theme preference", e);
Expand Down

0 comments on commit 67c59ae

Please sign in to comment.