From 6edd8307e61fe5d67f40f3a83c2c8954c6544db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Warnault?= Date: Wed, 8 Apr 2020 18:23:01 +0200 Subject: [PATCH] Make sure themes are reset when updating from previous version --- Sources/WCBoardThreadController.m | 4 +--- Sources/WCBoards.m | 8 ++------ Sources/WCSettings.m | 15 ++++++++++++++- en.lproj/PublicChatWindow.xib | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Sources/WCBoardThreadController.m b/Sources/WCBoardThreadController.m index c1a8dd25..da5bea27 100644 --- a/Sources/WCBoardThreadController.m +++ b/Sources/WCBoardThreadController.m @@ -390,9 +390,7 @@ - (void)reloadDataAndSelectPost:(WCBoardPost *)selectPost { #pragma mark - #pragma mark Reload CSS Template -- (void)reloadTemplate { - NSLog(@"Thread reloadTemplate"); - +- (void)reloadTemplate { WITemplateBundle *template; template = [WITemplateBundle templateWithPath:_templatePath]; diff --git a/Sources/WCBoards.m b/Sources/WCBoards.m index dda62e7b..4acf26fa 100644 --- a/Sources/WCBoards.m +++ b/Sources/WCBoards.m @@ -323,9 +323,7 @@ - (void)appleInterfaceThemeChanged:(NSNotification *) notification { -- (void)_themeDidChange { - NSLog(@"_themeDidChange"); - +- (void)_themeDidChange { NSDictionary *theme; NSString *templatePath; WITemplateBundle *templateBundle; @@ -333,9 +331,7 @@ - (void)_themeDidChange { theme = [[WCSettings settings] themeWithIdentifier:[[WCSettings settings] objectForKey:WCTheme]]; templateBundle = [[WCSettings settings] templateBundleWithIdentifier:[theme objectForKey:WCThemesTemplate]]; templatePath = [templateBundle bundlePath]; - - NSLog(@"theme : %@", [theme valueForKey:WCThemesName]); - + [_threadController setFont:WIFontFromString([theme objectForKey:WCThemesBoardsFont])]; [_threadController setTextColor:WIColorFromString([theme objectForKey:WCThemesBoardsTextColor])]; [_threadController setBackgroundColor:WIColorFromString([theme objectForKey:WCThemesBoardsBackgroundColor])]; diff --git a/Sources/WCSettings.m b/Sources/WCSettings.m index e3901c50..e38232bb 100644 --- a/Sources/WCSettings.m +++ b/Sources/WCSettings.m @@ -539,7 +539,20 @@ - (void)_upgrade { // if(![self objectForKey:WCApplicationMenuEnabled]) // [self setObject:[NSNumber numberWithBool:NO] forKey:WCApplicationMenuEnabled]; - NSLog(@"upgrade"); + NSLog(@"Upgrade settings..."); + + if (![self boolForKey:@"WCMigratedTo_2_5__31"]) { + NSLog(@"Upgrade settings to 2_5__31..."); + + // make sure to reset old versions themes + [self removeObjectForKey:WCThemes]; + [self setString:[NSApp darkModeEnabled] ? darkThemeIdentifier : lightThemeIdentifier forKey:WCTheme]; + + [self setObject:[NSArray arrayWithObjects: [self _defaultLightTheme], [self _defaultDarkTheme], NULL] + forKey:WCThemes]; + + [self setBool:true forKey:@"WCMigratedTo_2_5__31"]; + } } diff --git a/en.lproj/PublicChatWindow.xib b/en.lproj/PublicChatWindow.xib index cdff563b..a0482e59 100644 --- a/en.lproj/PublicChatWindow.xib +++ b/en.lproj/PublicChatWindow.xib @@ -196,7 +196,7 @@ - +