add catination settings

This commit is contained in:
7w1 committed 2026-03-06 23:46:51 -06:00
1 parent a0b0fe312c
commit b345efde16
6 files changed
+119 -2

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
sable: minor
---
Added settings to Account that let you set if you are a cat or have cats, or not display other peoples cat status.
@@ -31,8 +31,9 @@ import {
} from '$plugins/react-custom-html-parser';
import { useSpoilerClickHandler } from '$hooks/useSpoilerClickHandler';
import { RenderBody } from '$components/message';
import { getSettings } from '$state/settings';
import { getSettings, settingsAtom } from '$state/settings';
import { filterPronounsByLanguage } from '$utils/pronouns';
import { useSetting } from '$state/hooks/settings';
import { CreatorChip } from './CreatorChip';
import { UserInviteAlert, UserBanAlert, UserModeration, UserKickAlert } from './UserModeration';
import { PowerChip } from './PowerChip';
@@ -50,6 +51,8 @@ const KNOWN_KEYS = [
'moe.sable.app.name_color',
'avatar_url',
'displayname',
'kitty.meow.has_cats',
'kitty.meow.is_cat',
];
type UserExtendedSectionProps = {
@@ -69,6 +72,18 @@ function UserExtendedSection({
};
const [showMore, setShowMore] = useState(false);
const [renderAnimals] = useSetting(settingsAtom, 'renderAnimals');
const isCat = profile.isCat === true;
const hasCats = profile.hasCats === true;
const catStatusText = useMemo(() => {
if (!renderAnimals) return null;
if (isCat && hasCats) return 'Cat with cats—needs pets & love!';
if (isCat) return 'Is a cat—give pets & love!';
if (hasCats) return 'Has cats—send love!';
return null;
}, [renderAnimals, isCat, hasCats]);
const renderValue = (val: any) => {
if (val === null || val === undefined) return 'n/a';
if (typeof val === 'boolean') return val ? 'Yes' : 'No';
@@ -152,6 +167,14 @@ function UserExtendedSection({
</Text>
</Box>
)}
{catStatusText && (
<Box alignItems="Center" gap="100">
<Icon size="50" src={Icons.Heart} style={{ opacity: 0.5 }} />
<Text size="T200" priority="400">
{catStatusText}
</Text>
</Box>
)}
</Box>
)}
+2
View File
@@ -1153,6 +1153,8 @@ export function RoomTimeline({
delete cleanExtended['moe.sable.app.name_color'];
delete cleanExtended.avatar_url;
delete cleanExtended.displayname;
delete cleanExtended['kitty.meow.has_cats'];
delete cleanExtended['kitty.meow.is_cat'];
}
openUserRoomProfile(
+74 -1
View File
@@ -23,6 +23,7 @@ import {
Header,
config,
Spinner,
Switch,
} from 'folds';
import FocusTrap from 'focus-trap-react';
import { useSetAtom } from 'jotai';
@@ -51,6 +52,8 @@ import { PronounEditor } from './PronounEditor';
import { BioEditor } from './BioEditor';
import { NameColorEditor } from './NameColorEditor';
import { StatusEditor } from './StatusEditor';
import { useSetting } from '$state/hooks/settings';
import { settingsAtom } from '$state/settings';
type PronounSet = {
summary: string;
@@ -484,9 +487,14 @@ function ProfileExtended({ profile, userId }: ProfileProps) {
const presence = useUserPresence(userId);
const currentStatus = presence?.status || '';
// Keys we don't render here nor handle seperately but still need to exclude
const EXCLUDED_KEYS = ['kitty.meow.is_cat', 'kitty.meow.has_cats'];
// Unknown fields / unimplemented non-matrix-spec fields
// Only renders them, can't edit or set
const extendedFields = Object.entries(profile.extended || {});
const extendedFields = Object.entries(profile.extended || {}).filter(
([key]) => !EXCLUDED_KEYS.includes(key)
);
const handleSaveField = useCallback(
async (key: string, value: any) => {
@@ -627,6 +635,70 @@ function ProfileExtended({ profile, userId }: ProfileProps) {
);
}
type AnimalCosmeticsProps = {
profile: UserProfile;
userId: string;
};
function AnimalCosmetics({ profile, userId }: AnimalCosmeticsProps) {
const mx = useMatrixClient();
const setGlobalProfiles = useSetAtom(profilesCacheAtom);
const [renderAnimals, setRenderAnimals] = useSetting(settingsAtom, 'renderAnimals');
const isCat = profile.isCat === true;
const hasCats = profile.hasCats === true;
const handleSaveField = useCallback(
async (key: string, value: any) => {
await mx.setExtendedProfileProperty?.(key, value);
setGlobalProfiles((prev) => {
const newCache = { ...prev };
delete newCache[userId];
return newCache;
});
},
[mx, userId, setGlobalProfiles]
);
return (
<Box direction="Column" gap="100">
<Text size="L400">Animal Identity</Text>
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
<SettingTile
title="Render Animals"
description="Render animals as animals as opposed to normal humans."
after={<Switch variant="Primary" value={renderAnimals} onChange={setRenderAnimals} />}
/>
</SequenceCard>
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
<SettingTile
title="Is Cat"
description="Marks you as a cat."
after={
<Switch
variant="Primary"
value={isCat}
onChange={() => handleSaveField('kitty.meow.is_cat', !isCat)}
/>
}
/>
</SequenceCard>
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
<SettingTile
title="Has Cats"
description="Marks that you have cats."
after={
<Switch
variant="Primary"
value={hasCats}
onChange={() => handleSaveField('kitty.meow.has_cats', !hasCats)}
/>
}
/>
</SequenceCard>
</Box>
);
}
export function Profile() {
const mx = useMatrixClient();
const userId = mx.getUserId()!;
@@ -662,6 +734,7 @@ export function Profile() {
</SequenceCard>
</Box>
<ProfileExtended userId={userId} profile={profile} />
<AnimalCosmetics userId={userId} profile={profile} />
</Box>
);
}
+6
View File
@@ -20,6 +20,8 @@ export type UserProfile = {
status?: string;
bannerUrl?: string;
nameColor?: string;
isCat?: boolean;
hasCats?: boolean;
extended?: Record<string, any>;
_fetched?: boolean;
};
@@ -36,6 +38,8 @@ const normalizeInfo = (info: any): UserProfile => {
'chat.commet.profile_banner',
'chat.commet.profile_status',
'moe.sable.app.name_color',
'kitty.meow.has_cats',
'kitty.meow.is_cat',
];
const extended: Record<string, any> = {};
@@ -54,6 +58,8 @@ const normalizeInfo = (info: any): UserProfile => {
status: info['chat.commet.profile_status'],
bannerUrl: info['chat.commet.profile_banner'],
nameColor: info['moe.sable.app.name_color'],
isCat: info['kitty.meow.is_cat'] === true,
hasCats: info['kitty.meow.has_cats'] === true,
extended,
_fetched: true,
};
+8
View File
@@ -79,6 +79,10 @@ export interface Settings {
badgeCountDMsOnly: boolean;
showPingCounts: boolean;
hideReads: boolean;
emojiSuggestThreshold: number;
// furry stuff
renderAnimals: boolean;
}
const defaultSettings: Settings = {
@@ -144,6 +148,10 @@ const defaultSettings: Settings = {
badgeCountDMsOnly: false,
showPingCounts: true,
hideReads: false,
emojiSuggestThreshold: 2,
// furry stuff
renderAnimals: true,
};
export const getSettings = () => {