Skip to content

Commit fff58b3

Browse files
authored
settings: Rename 'night mode' to 'dark theme'
Fixes: zulip#5169 Changed night mode to dark theme. Added tests, migrations, and updated comments.
1 parent fc2dab7 commit fff58b3

File tree

7 files changed

+29
-9
lines changed

7 files changed

+29
-9
lines changed

src/emoji/codePointMap.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ export const override: {| [code: string]: string |} = {
2020

2121
// Fix the "letter" emoji. The codes in Zulip's emoji database would give
2222
// these a text-style rather than emoji-style presentation; that's subtler
23-
// than we want, plus when not in night mode it's actually invisible.
23+
// than we want, plus when not in dark theme it's actually invisible.
2424
'1f170': '1f170-fe0f', // :a:
2525
'1f171': '1f171-fe0f', // :b:
2626
'1f17e': '1f17e-fe0f', // :o:
2727
'1f17f': '1f17f-fe0f', // :p:
2828
// (Zulip only actually offers a handful of these letter emoji.)
2929

3030
// :check_mark: -> :check: because the former is invisible on a light
31-
// background, i.e. when not in night mode.
31+
// background, i.e. when not in Dark theme.
3232
'2714': '2705',
3333
};
3434

src/reduxTypes.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ export type ThemeName = 'light' | 'dark';
372372
* To determine the actual theme to show the user, use a ThemeName;
373373
* see there for details.
374374
*/
375-
export type ThemeSetting = 'default' | 'night';
375+
export type ThemeSetting = 'default' | 'dark';
376376

377377
/** What browser the user has set to use for opening links in messages.
378378
*

src/settings/SettingsScreen.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export default function SettingsScreen(props: Props): Node {
3535
const { navigation } = props;
3636

3737
const handleThemeChange = useCallback(() => {
38-
dispatch(setGlobalSettings({ theme: theme === 'default' ? 'night' : 'default' }));
38+
dispatch(setGlobalSettings({ theme: theme === 'default' ? 'dark' : 'default' }));
3939
}, [theme, dispatch]);
4040

4141
return (
4242
<Screen title="Settings">
43-
<SwitchRow label="Night mode" value={theme === 'night'} onValueChange={handleThemeChange} />
43+
<SwitchRow label="Dark theme" value={theme === 'dark'} onValueChange={handleThemeChange} />
4444
<SwitchRow
4545
label="Open links with in-app browser"
4646
value={shouldUseInAppBrowser(browser)}

src/settings/__tests__/settingsReducer-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ describe('settingsReducer', () => {
7979
test('changes value of a key', () => {
8080
const action = deepFreeze({
8181
type: SET_GLOBAL_SETTINGS,
82-
update: { theme: 'night' },
82+
update: { theme: 'dark' },
8383
});
8484

8585
const expectedState = {
8686
...baseState,
87-
theme: 'night',
87+
theme: 'dark',
8888
};
8989

9090
const actualState = settingsReducer(baseState, action);

src/storage/__tests__/migrations-test.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ describe('migrations', () => {
104104
// What `base` becomes after all migrations.
105105
const endBase = {
106106
...base52,
107-
migrations: { version: 56 },
107+
migrations: { version: 57 },
108108
};
109109

110110
for (const [desc, before, after] of [
@@ -278,6 +278,20 @@ describe('migrations', () => {
278278
},
279279
{ ...endBase, settings: { ...endBase.settings, markMessagesReadOnScroll: 'never' } },
280280
],
281+
[
282+
"check 57 with 'night'",
283+
{ ...base52, migrations: { version: 56 }, settings: { ...base52.settings, theme: 'night' } },
284+
{ ...endBase, settings: { ...endBase.settings, theme: 'dark' } },
285+
],
286+
[
287+
"check 57 with 'default'",
288+
{
289+
...base52,
290+
migrations: { version: 56 },
291+
settings: { ...base52.settings, theme: 'default' },
292+
},
293+
{ ...endBase, settings: { ...endBase.settings, theme: 'default' } },
294+
],
281295
]) {
282296
/* eslint-disable no-loop-func */
283297
test(desc, async () => {

src/storage/migrations.js

+6
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,12 @@ const migrationsInner: {| [string]: (LessPartialState) => LessPartialState |} =
472472
// Add presenceEnabled to state.realm.
473473
'56': dropCache,
474474

475+
// Rename 'night' to 'dark' in state.settings.theme
476+
'57': state => ({
477+
...state,
478+
settings: { ...state.settings, theme: state.settings.theme === 'night' ? 'dark' : 'default' },
479+
}),
480+
475481
// TIP: When adding a migration, consider just using `dropCache`.
476482
// (See its jsdoc for guidance on when that's the right answer.)
477483
};

static/translations/messages_en.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"Learn more": "Learn more",
163163
"Full profile": "Full profile",
164164
"Settings": "Settings",
165-
"Night mode": "Night mode",
165+
"Dark theme": "Dark theme",
166166
"Open links with in-app browser": "Open links with in-app browser",
167167
"Language": "Language",
168168
"Arabic": "Arabic",

0 commit comments

Comments
 (0)