From 62aa251f6a28685a6ee4cbc64717432d5d13b4a6 Mon Sep 17 00:00:00 2001 From: Aritra Bhaduri <92646038+aritroCoder@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:42:47 +0530 Subject: [PATCH] Fixes: Rename 'night mode' to 'dark theme' (#2) Changed night mode to dark theme in the app to avoid difference between the web and app interface of zulip(web-app parity) App works fine under the testing environments --- docs/changelog.md | 2 +- src/emoji/codePointMap.js | 4 ++-- src/reduxTypes.js | 2 +- src/settings/SettingsScreen.js | 4 ++-- src/settings/__tests__/settingsReducer-test.js | 4 ++-- src/storage/__tests__/migrations-test.js | 16 +++++++++++++++- src/storage/migrations.js | 6 ++++++ static/translations/messages_en.json | 2 +- static/translations/messages_tl.json | 2 +- 9 files changed, 31 insertions(+), 11 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index 20bc44f55b2..be71e8e79c8 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2687,4 +2687,4 @@ This was an alpha-only release, superseded by 16.2.96. ## 14.0.90 and earlier -TODO?: backfill some of this information from notes in other places. +TODO?: backfill some of this information from notes in other places. \ No newline at end of file diff --git a/src/emoji/codePointMap.js b/src/emoji/codePointMap.js index 846fedc7d98..6d502efe720 100644 --- a/src/emoji/codePointMap.js +++ b/src/emoji/codePointMap.js @@ -20,7 +20,7 @@ export const override: {| [code: string]: string |} = { // Fix the "letter" emoji. The codes in Zulip's emoji database would give // these a text-style rather than emoji-style presentation; that's subtler - // than we want, plus when not in night mode it's actually invisible. + // than we want, plus when not in Dark theme it's actually invisible. '1f170': '1f170-fe0f', // :a: '1f171': '1f171-fe0f', // :b: '1f17e': '1f17e-fe0f', // :o: @@ -28,7 +28,7 @@ export const override: {| [code: string]: string |} = { // (Zulip only actually offers a handful of these letter emoji.) // :check_mark: -> :check: because the former is invisible on a light - // background, i.e. when not in night mode. + // background, i.e. when not in Dark theme. '2714': '2705', }; diff --git a/src/reduxTypes.js b/src/reduxTypes.js index 37a1b623b8a..aee5d42e705 100644 --- a/src/reduxTypes.js +++ b/src/reduxTypes.js @@ -372,7 +372,7 @@ export type ThemeName = 'light' | 'dark'; * To determine the actual theme to show the user, use a ThemeName; * see there for details. */ -export type ThemeSetting = 'default' | 'night'; +export type ThemeSetting = 'default' | 'dark'; /** What browser the user has set to use for opening links in messages. * diff --git a/src/settings/SettingsScreen.js b/src/settings/SettingsScreen.js index 1c6cd4fc933..dc8738cf447 100644 --- a/src/settings/SettingsScreen.js +++ b/src/settings/SettingsScreen.js @@ -35,12 +35,12 @@ export default function SettingsScreen(props: Props): Node { const { navigation } = props; const handleThemeChange = useCallback(() => { - dispatch(setGlobalSettings({ theme: theme === 'default' ? 'night' : 'default' })); + dispatch(setGlobalSettings({ theme: theme === 'default' ? 'dark' : 'default' })); }, [theme, dispatch]); return ( - + { test('changes value of a key', () => { const action = deepFreeze({ type: SET_GLOBAL_SETTINGS, - update: { theme: 'night' }, + update: { theme: 'dark' }, }); const expectedState = { ...baseState, - theme: 'night', + theme: 'dark', }; const actualState = settingsReducer(baseState, action); diff --git a/src/storage/__tests__/migrations-test.js b/src/storage/__tests__/migrations-test.js index 23f4cd26920..4c3bbaceeb5 100644 --- a/src/storage/__tests__/migrations-test.js +++ b/src/storage/__tests__/migrations-test.js @@ -104,7 +104,7 @@ describe('migrations', () => { // What `base` becomes after all migrations. const endBase = { ...base52, - migrations: { version: 56 }, + migrations: { version: 57 }, }; for (const [desc, before, after] of [ @@ -278,6 +278,20 @@ describe('migrations', () => { }, { ...endBase, settings: { ...endBase.settings, markMessagesReadOnScroll: 'never' } }, ], + [ + "check 57 with 'night'", + { ...base52, migrations: { version: 56 }, settings: { ...base52.settings, theme: 'night' } }, + { ...endBase, settings: { ...endBase.settings, theme: 'dark' } }, + ], + [ + "check 57 with 'default'", + { + ...base52, + migrations: { version: 56 }, + settings: { ...base52.settings, theme: 'default' }, + }, + { ...endBase, settings: { ...endBase.settings, theme: 'default' } }, + ], ]) { /* eslint-disable no-loop-func */ test(desc, async () => { diff --git a/src/storage/migrations.js b/src/storage/migrations.js index b169c9617ba..176fbe3cab6 100644 --- a/src/storage/migrations.js +++ b/src/storage/migrations.js @@ -472,6 +472,12 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} = // Add presenceEnabled to state.realm. '56': dropCache, + // Rename 'night' to 'dark' in state.settings.theme + '57': state => ({ + ...state, + settings: { ...state.settings, theme: state.settings.theme === 'night' ? 'dark' : 'default' }, + }), + // TIP: When adding a migration, consider just using `dropCache`. // (See its jsdoc for guidance on when that's the right answer.) }; diff --git a/static/translations/messages_en.json b/static/translations/messages_en.json index 514d2f85944..4c88974fef7 100644 --- a/static/translations/messages_en.json +++ b/static/translations/messages_en.json @@ -162,7 +162,7 @@ "Learn more": "Learn more", "Full profile": "Full profile", "Settings": "Settings", - "Night mode": "Night mode", + "Dark theme": "Dark theme", "Open links with in-app browser": "Open links with in-app browser", "Language": "Language", "Arabic": "Arabic", diff --git a/static/translations/messages_tl.json b/static/translations/messages_tl.json index e7b690b225b..e05fc1d6d6a 100644 --- a/static/translations/messages_tl.json +++ b/static/translations/messages_tl.json @@ -370,4 +370,4 @@ "Failed to copy stream link": "Failed to copy stream link", "A stream with this name already exists.": "A stream with this name already exists.", "Streams": "Streams" -} +} \ No newline at end of file