Skip to content

Commit

Permalink
Make non-working features invisible for end users
Browse files Browse the repository at this point in the history
It makes all broken features visible only in development. This helps reduce visual clutter.
  • Loading branch information
lefterisgar authored and sindresorhus committed Aug 4, 2022
1 parent bdc7738 commit 8fd711e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
13 changes: 8 additions & 5 deletions source/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Response,
Menu
} from 'electron';
import {is} from 'electron-util';
import {memoize} from 'lodash';
import config from './config';
import {showRestartDialog, getWindow, sendBackgroundAction} from './util';
Expand Down Expand Up @@ -340,10 +341,12 @@ export async function generateSubmenu(
): Promise<MenuItemConstructorOptions[]> {
const emojiMenuOption = async (
label: string,
style: EmojiStyle
style: EmojiStyle,
visibility: boolean
): Promise<MenuItemConstructorOptions> => ({
label,
type: 'checkbox',
visible: visibility,
icon: await getEmojiIcon(style),
checked: config.get('emojiStyle') === style,
async click() {
Expand All @@ -359,10 +362,10 @@ export async function generateSubmenu(
});

return Promise.all([
emojiMenuOption('System', EmojiStyle.Native),
emojiMenuOption('System', EmojiStyle.Native, true),
{type: 'separator'} as const,
emojiMenuOption('Facebook 3.0', EmojiStyle.Facebook30),
emojiMenuOption('Messenger 1.0', EmojiStyle.Messenger10),
emojiMenuOption('Facebook 2.2', EmojiStyle.Facebook22)
emojiMenuOption('Facebook 3.0', EmojiStyle.Facebook30, true),
emojiMenuOption('Messenger 1.0', EmojiStyle.Messenger10, !is.linux || is.development),
emojiMenuOption('Facebook 2.2', EmojiStyle.Facebook22, true)
]);
}
19 changes: 12 additions & 7 deletions source/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ Press Command/Ctrl+R in Caprine to see your changes.
const preferencesSubmenu: MenuItemConstructorOptions[] = [
{
label: 'Privacy',
visible: is.development,
submenu: privacySubmenu
},
{
Expand Down Expand Up @@ -268,6 +269,7 @@ Press Command/Ctrl+R in Caprine to see your changes.
{
label: 'Show Message Preview in Notifications',
type: 'checkbox',
visible: is.development,
checked: config.get('notificationMessagePreview'),
click(menuItem) {
config.set('notificationMessagePreview', menuItem.checked);
Expand All @@ -277,6 +279,7 @@ Press Command/Ctrl+R in Caprine to see your changes.
label: 'Mute Notifications',
id: 'mute-notifications',
type: 'checkbox',
visible: is.development,
checked: config.get('notificationsMuted'),
click() {
sendAction('toggle-mute-notifications', {isNewDesign});
Expand All @@ -293,6 +296,7 @@ Press Command/Ctrl+R in Caprine to see your changes.
{
label: 'Show Unread Badge',
type: 'checkbox',
visible: is.development,
checked: config.get('showUnreadBadge'),
click() {
config.set('showUnreadBadge', !config.get('showUnreadBadge'));
Expand Down Expand Up @@ -404,7 +408,7 @@ Press Command/Ctrl+R in Caprine to see your changes.
{
label: 'Flash Window on Message',
type: 'checkbox',
visible: !is.macos,
visible: is.development,
checked: config.get('flashWindowOnMessage'),
click(menuItem) {
config.set('flashWindowOnMessage', menuItem.checked);
Expand Down Expand Up @@ -568,54 +572,55 @@ Press Command/Ctrl+R in Caprine to see your changes.
const conversationSubmenu: MenuItemConstructorOptions[] = [
{
label: 'Mute Conversation',
visible: is.development,
accelerator: 'CommandOrControl+Shift+M',
click() {
sendAction<INewDesign>('mute-conversation', {isNewDesign});
}
},
{
label: 'Hide Conversation',
visible: is.development,
accelerator: 'CommandOrControl+Shift+H',
click() {
sendAction<INewDesign>('hide-conversation', {isNewDesign});
}
},
{
label: 'Delete Conversation',
visible: is.development,
accelerator: 'CommandOrControl+Shift+D',
click() {
sendAction<INewDesign>('delete-conversation', {isNewDesign});
}
},
{
type: 'separator'
},
{
label: 'Select Next Conversation',
visible: is.development,
accelerator: 'Control+Tab',
click() {
sendAction('next-conversation');
}
},
{
label: 'Select Previous Conversation',
visible: is.development,
accelerator: 'Control+Shift+Tab',
click() {
sendAction('previous-conversation');
}
},
{
type: 'separator'
},
{
label: 'Find Conversation',
visible: is.development,
accelerator: 'CommandOrControl+K',
click() {
sendAction('find');
}
},
{
label: 'Search in Conversation',
visible: is.development,
accelerator: 'CommandOrControl+F',
click() {
sendAction('search', isNewDesign);
Expand Down

0 comments on commit 8fd711e

Please sign in to comment.