Merge pull request #431 from SableClient/persona-patches
hide persona tab behind an experimental setting
This commit is contained in:
4 files changed
+62
-15
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Place persona settings behind a toggle in experimental.
|
||||
@@ -26,6 +26,8 @@ import { nameInitials } from '$utils/common';
|
||||
import { UseStateProvider } from '$components/UseStateProvider';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import { LogoutDialog } from '$components/LogoutDialog';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { Notifications } from './notifications';
|
||||
import { Devices } from './devices';
|
||||
import { EmojisStickers } from './emojis-stickers';
|
||||
@@ -41,7 +43,7 @@ import { PerMessageProfilePage } from './Persona/ProfilesPage';
|
||||
export enum SettingsPages {
|
||||
GeneralPage,
|
||||
AccountPage,
|
||||
PerMessageProfilesPage, // Renamed to avoid conflict
|
||||
PerMessageProfilesPage,
|
||||
NotificationPage,
|
||||
DevicesPage,
|
||||
EmojisStickersPage,
|
||||
@@ -59,9 +61,9 @@ type SettingsMenuItem = {
|
||||
activeIcon?: IconSrc;
|
||||
};
|
||||
|
||||
const useSettingsMenuItems = (): SettingsMenuItem[] =>
|
||||
useMemo(
|
||||
() => [
|
||||
const useSettingsMenuItems = (showPersona: boolean): SettingsMenuItem[] =>
|
||||
useMemo(() => {
|
||||
const items: SettingsMenuItem[] = [
|
||||
{
|
||||
page: SettingsPages.GeneralPage,
|
||||
name: 'General',
|
||||
@@ -72,11 +74,6 @@ const useSettingsMenuItems = (): SettingsMenuItem[] =>
|
||||
name: 'Account',
|
||||
icon: Icons.User,
|
||||
},
|
||||
{
|
||||
page: SettingsPages.PerMessageProfilesPage,
|
||||
name: 'Persona',
|
||||
icon: Icons.User,
|
||||
},
|
||||
{
|
||||
page: SettingsPages.CosmeticsPage,
|
||||
name: 'Appearance',
|
||||
@@ -118,9 +115,18 @@ const useSettingsMenuItems = (): SettingsMenuItem[] =>
|
||||
name: 'Keyboard Shortcuts',
|
||||
icon: Icons.BlockCode,
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
];
|
||||
|
||||
if (showPersona) {
|
||||
items.splice(2, 0, {
|
||||
page: SettingsPages.PerMessageProfilesPage,
|
||||
name: 'Persona',
|
||||
icon: Icons.User,
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}, [showPersona]);
|
||||
|
||||
type SettingsProps = {
|
||||
initialPage?: SettingsPages;
|
||||
@@ -136,12 +142,18 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
? (mxcUrlToHttp(mx, profile.avatarUrl, useAuthentication, 96, 96, 'crop') ?? undefined)
|
||||
: undefined;
|
||||
|
||||
const [showPersona] = useSetting(settingsAtom, 'showPersonaSetting');
|
||||
|
||||
const screenSize = useScreenSizeContext();
|
||||
const [activePage, setActivePage] = useState<SettingsPages | undefined>(() => {
|
||||
if (initialPage === SettingsPages.PerMessageProfilesPage && !showPersona) {
|
||||
return SettingsPages.GeneralPage;
|
||||
}
|
||||
if (initialPage) return initialPage;
|
||||
return screenSize === ScreenSize.Mobile ? undefined : SettingsPages.GeneralPage;
|
||||
});
|
||||
const menuItems = useSettingsMenuItems();
|
||||
|
||||
const menuItems = useSettingsMenuItems(showPersona);
|
||||
|
||||
const handlePageRequestClose = () => {
|
||||
if (screenSize === ScreenSize.Mobile) {
|
||||
@@ -254,7 +266,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
||||
{activePage === SettingsPages.AccountPage && (
|
||||
<Account requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.PerMessageProfilesPage && (
|
||||
{activePage === SettingsPages.PerMessageProfilesPage && showPersona && (
|
||||
<PerMessageProfilePage requestClose={handlePageRequestClose} />
|
||||
)}
|
||||
{activePage === SettingsPages.CosmeticsPage && (
|
||||
|
||||
@@ -1,11 +1,38 @@
|
||||
import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds';
|
||||
import { Box, Text, IconButton, Icon, Icons, Scroll, Switch } from 'folds';
|
||||
import { Page, PageContent, PageHeader } from '$components/page';
|
||||
import { InfoCard } from '$components/info-card';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import { SequenceCardStyle } from '$features/common-settings/styles.css';
|
||||
import { SettingTile } from '$components/setting-tile';
|
||||
import { SequenceCard } from '$components/sequence-card';
|
||||
import { LanguageSpecificPronouns } from '../cosmetics/LanguageSpecificPronouns';
|
||||
import { Sync } from '../general';
|
||||
import { BandwidthSavingEmojis } from './BandwithSavingEmojis';
|
||||
import { MSC4268HistoryShare } from './MSC4268HistoryShare';
|
||||
|
||||
function PersonaToggle() {
|
||||
const [showPersonaSetting, setShowPersonaSetting] = useSetting(
|
||||
settingsAtom,
|
||||
'showPersonaSetting'
|
||||
);
|
||||
|
||||
return (
|
||||
<Box direction="Column" gap="100">
|
||||
<Text size="L400">Personas (Per-Message Profiles)</Text>
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Personas Tab"
|
||||
description="Enables the personas tab in the settings menu for per-message profiles"
|
||||
after={
|
||||
<Switch variant="Primary" value={showPersonaSetting} onChange={setShowPersonaSetting} />
|
||||
}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
type ExperimentalProps = {
|
||||
requestClose: () => void;
|
||||
};
|
||||
@@ -47,6 +74,7 @@ export function Experimental({ requestClose }: Readonly<ExperimentalProps>) {
|
||||
<MSC4268HistoryShare />
|
||||
<LanguageSpecificPronouns />
|
||||
<BandwidthSavingEmojis />
|
||||
<PersonaToggle />
|
||||
</Box>
|
||||
</PageContent>
|
||||
</Scroll>
|
||||
|
||||
@@ -100,6 +100,7 @@ export interface Settings {
|
||||
faviconForMentionsOnly: boolean;
|
||||
highlightMentions: boolean;
|
||||
mentionInReplies: boolean;
|
||||
showPersonaSetting: boolean;
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: boolean;
|
||||
@@ -184,6 +185,7 @@ const defaultSettings: Settings = {
|
||||
faviconForMentionsOnly: false,
|
||||
highlightMentions: true,
|
||||
mentionInReplies: true,
|
||||
showPersonaSetting: false,
|
||||
|
||||
// furry stuff
|
||||
renderAnimals: true,
|
||||
|
||||
Reference in new issue
Block a user