mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-21 01:21:18 -08:00
added resetting space room status and setting for home
This commit is contained in:
1 parent
b81d2901fc
commit
ac922e1ee4
4 files changed
+55
-22
No files matched your search
@@ -19,26 +19,27 @@ import { SettingTile } from '$components/setting-tile';
|
||||
import { useRoom } from '$hooks/useRoom';
|
||||
|
||||
import { SequenceCardStyle } from '$features/common-settings/styles.css';
|
||||
import { useShowRoomIcon } from '$hooks/useShowRoomIcon';
|
||||
import { useShowPerRoomRoomIcon } from '$hooks/useShowRoomIcon';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import type { ShowRoomIcon } from '$state/settings';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { stopPropagation } from '$utils/keyboard';
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
|
||||
function SelectShowRoomIcon({roomId}: {roomId: string}) {
|
||||
export function SelectShowPerRoomRoomIcon({roomId}: {roomId: string}) {
|
||||
const [menuCords, setMenuCords] = useState<RectCords>();
|
||||
const showRoomIconItems = useShowRoomIcon();
|
||||
const showRoomIconItems = useShowPerRoomRoomIcon();
|
||||
const [showRoomIconArray, setShowRoomIconArray] = useSetting(settingsAtom, 'perRoomShowRoomIcon');
|
||||
const showRoomIcon = showRoomIconArray.find(item => item.roomId === roomId )?.display;
|
||||
|
||||
|
||||
const handleMenu: MouseEventHandler<HTMLButtonElement> = (evt) => {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (position: ShowRoomIcon) => {
|
||||
const CleanedShowRoomIconArray = showRoomIconArray.filter(item => item.roomId !== roomId );
|
||||
const newShowRoomIconArray = [...CleanedShowRoomIconArray, {roomId, display: position}]
|
||||
const handleSelect = (position?: ShowRoomIcon) => {
|
||||
let newShowRoomIconArray = showRoomIconArray.filter(item => item.roomId !== roomId );
|
||||
if(position)
|
||||
newShowRoomIconArray = [...newShowRoomIconArray, {roomId, display: position}]
|
||||
setShowRoomIconArray(newShowRoomIconArray);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
@@ -134,7 +135,7 @@ export function Appearance({ requestClose }: AppearanceProps) {
|
||||
<SettingTile
|
||||
title="Show Room Icons In Sidebar"
|
||||
description="When do you want to show the specific room icons in the sidebar within this space?"
|
||||
after={<SelectShowRoomIcon roomId={room.roomId}/>}
|
||||
after={<SelectShowPerRoomRoomIcon roomId={room.roomId}/>}
|
||||
/>
|
||||
</SequenceCard>
|
||||
</Box>
|
||||
|
||||
@@ -38,6 +38,7 @@ import FocusTrap from 'focus-trap-react';
|
||||
import { useShowRoomIcon } from '$hooks/useShowRoomIcon';
|
||||
import type { PanelSizetItem } from '$hooks/usePanelSizes';
|
||||
import { usePanelSizeItems } from '$hooks/usePanelSizes';
|
||||
import { SelectShowPerRoomRoomIcon } from '$features/common-settings/appearance/Appearance';
|
||||
|
||||
const clampIncomingInlineImageHeight = (n: number) => Math.max(1, Math.min(4096, n));
|
||||
|
||||
@@ -717,7 +718,8 @@ function SelectShowRoomIcon() {
|
||||
setMenuCords(evt.currentTarget.getBoundingClientRect());
|
||||
};
|
||||
|
||||
const handleSelect = (position: ShowRoomIcon) => {
|
||||
const handleSelect = (position?: ShowRoomIcon) => {
|
||||
if(!position) return;
|
||||
setShowRoomIcon(position);
|
||||
setMenuCords(undefined);
|
||||
};
|
||||
@@ -874,6 +876,16 @@ export function Appearance({
|
||||
after={<SelectShowRoomIcon />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
{/*THIS SHOULD BE MOVED TO A NEW SETTINGS MENU INSIDE OF THE HOME SETTINGS AS SOON AS THERE IS A REASON TO CREATE A HOME MENU SETTINGS PANEL
|
||||
it is currently here because it would be eerie to have an entire home settings menu for just one single setting*/}
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
title="Show Room Icons In Home menu sidebar"
|
||||
focusId="show-room-home-icons"
|
||||
description="Show Room icons in the home menu? (overrides setting above if set)"
|
||||
after={<SelectShowPerRoomRoomIcon roomId={'Home'} />}
|
||||
/>
|
||||
</SequenceCard>
|
||||
|
||||
<SequenceCard className={SequenceCardStyle} variant="SurfaceVariant" direction="Column">
|
||||
<SettingTile
|
||||
|
||||
@@ -2,8 +2,8 @@ import { useMemo } from 'react';
|
||||
import { ShowRoomIcon } from '$state/settings';
|
||||
|
||||
export type MessageLayoutItem = {
|
||||
layout?: ShowRoomIcon;
|
||||
name: string;
|
||||
layout: ShowRoomIcon;
|
||||
};
|
||||
|
||||
export const useShowRoomIcon = (): MessageLayoutItem[] =>
|
||||
@@ -24,3 +24,26 @@ export const useShowRoomIcon = (): MessageLayoutItem[] =>
|
||||
],
|
||||
[]
|
||||
);
|
||||
|
||||
export const useShowPerRoomRoomIcon = (): MessageLayoutItem[] =>
|
||||
useMemo(
|
||||
() => [
|
||||
{
|
||||
layout: undefined,
|
||||
name: 'Default',
|
||||
},
|
||||
{
|
||||
layout: ShowRoomIcon.Always,
|
||||
name: 'Always',
|
||||
},
|
||||
{
|
||||
layout: ShowRoomIcon.Smart,
|
||||
name: 'Smart',
|
||||
},
|
||||
{
|
||||
layout: ShowRoomIcon.Never,
|
||||
name: 'Never',
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -520,21 +520,18 @@ export function Space() {
|
||||
|
||||
const [roomSidebarWidth, setRoomSidebarWidth] = useSetting(settingsAtom, 'roomSidebarWidth');
|
||||
const [curWidth, setCurWidth] = useState(roomSidebarWidth);
|
||||
|
||||
const [showRoomIconGeneral] = useSetting(settingsAtom, 'showRoomIcon');
|
||||
|
||||
const [showRoomIconArray] = useSetting(settingsAtom, 'perRoomShowRoomIcon');
|
||||
// oxlint-disable-next-line no-console
|
||||
console.log(showRoomIconArray, space.roomId);
|
||||
|
||||
const showIcons = () => {
|
||||
if (showRoomIconGeneral === ShowRoomIcon.Always) return true;
|
||||
if (showRoomIconGeneral === ShowRoomIcon.Never) return false;
|
||||
return curWidth < 144;
|
||||
};
|
||||
useEffect(() => {
|
||||
setCurWidth(roomSidebarWidth);
|
||||
}, [roomSidebarWidth]);
|
||||
|
||||
const [showRoomIconGeneral] = useSetting(settingsAtom, 'showRoomIcon');
|
||||
const [showRoomIconArray] = useSetting(settingsAtom, 'perRoomShowRoomIcon');
|
||||
const showRoomIcon = showRoomIconArray.find(item => item.roomId === space.roomId )?.display ?? showRoomIconGeneral;
|
||||
const showIcons = () => {
|
||||
if (showRoomIcon === ShowRoomIcon.Always) return true;
|
||||
if (showRoomIcon === ShowRoomIcon.Never) return false;
|
||||
return curWidth < 144;
|
||||
};
|
||||
const [joinCallOnSingleClick] = useSetting(settingsAtom, 'joinCallOnSingleClick');
|
||||
|
||||
const tombstoneEvent = useStateEvent(space, EventType.RoomTombstone);
|
||||
|
||||
Reference in new issue
Block a user