diff --git a/docs/howto/new-feature.md b/docs/howto/new-feature.md index f5c7661c645..cbf9d1e1efb 100644 --- a/docs/howto/new-feature.md +++ b/docs/howto/new-feature.md @@ -296,7 +296,7 @@ list, which we show in a WebView. type. * Your new feature may require some new CSS to style the new HTML. - See `src/webview/static/base.css` and `src/webview/css/cssNight.js`. + See `src/webview/static/base.css` and `src/webview/css/cssDark.js`. * If your new feature involves any interaction inside the message list, it may require some JS logic running inside the WebView. diff --git a/src/emoji/codePointMap.js b/src/emoji/codePointMap.js index 846fedc7d98..5b27f2ec616 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 ( - + { describe('SET_GLOBAL_SETTINGS', () => { test('changes value of a key', () => { - expect( - settingsReducer( - baseState, - deepFreeze({ type: SET_GLOBAL_SETTINGS, update: { theme: 'night' } }), - ), - ).toEqual({ ...baseState, theme: 'night' }); + const action = deepFreeze({ + type: SET_GLOBAL_SETTINGS, + update: { theme: 'dark' }, + }); + + const expectedState = { + ...baseState, + theme: 'dark', + }; + + const actualState = settingsReducer(baseState, action); + + expect(actualState).toEqual(expectedState); }); }); 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/src/webview/css/css.js b/src/webview/css/css.js index 35f199a6251..9b50a1f8350 100644 --- a/src/webview/css/css.js +++ b/src/webview/css/css.js @@ -3,7 +3,7 @@ import { Platform } from 'react-native'; import type { ThemeName } from '../../types'; import cssPygments from './cssPygments'; import cssEmojis from './cssEmojis'; -import cssNight from './cssNight'; +import cssDark from './cssDark'; import type { ServerEmojiData } from '../../api/modelTypes'; /** @@ -27,7 +27,7 @@ export default (theme: ThemeName, serverEmojiData: ServerEmojiData | null): stri diff --git a/src/webview/css/cssNight.js b/src/webview/css/cssDark.js similarity index 100% rename from src/webview/css/cssNight.js rename to src/webview/css/cssDark.js 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",