Skip to content

Commit

Permalink
Fixes: Rename 'night mode' to 'dark theme' (#2)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
aritroCoder authored Dec 14, 2022
1 parent b6218db commit 62aa251
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions src/emoji/codePointMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ 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:
'1f17f': '1f17f-fe0f', // :p:
// (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',
};

Expand Down
2 changes: 1 addition & 1 deletion src/reduxTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 2 additions & 2 deletions src/settings/SettingsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Screen title="Settings">
<SwitchRow label="Night mode" value={theme === 'night'} onValueChange={handleThemeChange} />
<SwitchRow label="Dark theme" value={theme === 'dark'} onValueChange={handleThemeChange} />
<SwitchRow
label="Open links with in-app browser"
value={shouldUseInAppBrowser(browser)}
Expand Down
4 changes: 2 additions & 2 deletions src/settings/__tests__/settingsReducer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ describe('settingsReducer', () => {
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);
Expand Down
16 changes: 15 additions & 1 deletion src/storage/__tests__/migrations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -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 () => {
Expand Down
6 changes: 6 additions & 0 deletions src/storage/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
};
Expand Down
2 changes: 1 addition & 1 deletion static/translations/messages_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion static/translations/messages_tl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 62aa251

Please sign in to comment.