Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

# Add Account-wide persona toggle in Persona Picker
22 changes: 18 additions & 4 deletions src/app/features/room/RoomInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ import { useRoomPermissions } from '$hooks/useRoomPermissions';
import { AutocompleteNotice } from '$components/editor/autocomplete/AutocompleteNotice';
import {
convertPerMessageProfileToBeeperFormat,
getCurrentlyUsedPerMessageProfileForAccount,
getCurrentlyUsedPerMessageProfileForRoom,
} from '$hooks/usePerMessageProfile';
import {
Expand Down Expand Up @@ -206,7 +207,7 @@ import { AudioMessageRecorder } from './AudioMessageRecorder';
import * as prefix from '$unstable/prefixes';
import { PollDialog } from './poll-modals';
import { useClientConfig } from '$hooks/useClientConfig';
import { PersonaPicker } from './persona-picker/PersonaPicker.tsx';
import { PersonaPicker, type PersonaPickerTab } from './persona-picker/PersonaPicker.tsx';

const LocationDialog = lazy(() =>
import('./location-modal').then((module) => ({ default: module.LocationDialog }))
Expand Down Expand Up @@ -517,6 +518,10 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
const [emojiBoardTab, setEmojiBoardTab] = useState<EmojiBoardTab | undefined>(undefined);
// Android back closes the mobile emoji board instead of navigating away.
useDismissOnBack(() => setEmojiBoardTab(undefined), emojiBoardTab !== undefined);
const [personaPickerTab, setPersonaPickerTab] = useState<PersonaPickerTab | undefined>(
undefined
);

const [enableMediaGalleries] = useSetting(settingsAtom, 'enableMediaGalleries');
const [sendIndividualAttachmentAsCaption] = useSetting(
settingsAtom,
Expand Down Expand Up @@ -665,7 +670,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
* This allows the server to apply the correct profile-based transformations (e.g. font size adjustments) when processing the message,
* and also allows clients to display an accurate preview of how the message will look with the profile applied while it's being composed.
*/
const perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
const globalPerMessageProfile = await getCurrentlyUsedPerMessageProfileForAccount(mx);
const roomPerMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
const perMessageProfile = roomPerMessageProfile ?? globalPerMessageProfile;

if (perMessageProfile) {
contents.forEach((c) => {
Expand Down Expand Up @@ -1102,7 +1109,10 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
* This allows the server to apply the correct profile-based transformations (e.g. font size adjustments) when processing the message,
* and also allows clients to display an accurate preview of how the message will look with the profile applied while it's being composed.
*/
let perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
const globalPerMessageProfile = await getCurrentlyUsedPerMessageProfileForAccount(mx);
const roomPerMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
let perMessageProfile = roomPerMessageProfile ?? globalPerMessageProfile;

if (pmpProxyingEnable) {
if (proxiedPerMessageProfile) perMessageProfile = proxiedPerMessageProfile;
}
Expand Down Expand Up @@ -1452,7 +1462,9 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
* This allows the server to apply the correct profile-based transformations (e.g. font size adjustments) when processing the message,
* and also allows clients to display an accurate preview of how the message will look with the profile applied while it's being composed.
*/
const perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
const globalPerMessageProfile = await getCurrentlyUsedPerMessageProfileForAccount(mx);
const roomPerMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
const perMessageProfile = roomPerMessageProfile ?? globalPerMessageProfile;

if (perMessageProfile) {
content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] =
Expand Down Expand Up @@ -1867,9 +1879,11 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
)}
{pmpPickerEnable && (
<PersonaPicker
tab={personaPickerTab}
mx={mx}
roomId={roomId}
suppressEditorRefocus={suppressEditorRefocus}
onTabChange={setPersonaPickerTab}
/>
)}
</>
Expand Down
1 change: 1 addition & 0 deletions src/app/features/room/persona-picker/PersonaPicker.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { color, config, toRem } from 'folds';
export const PersonaPickerMenuItem = style({
backgroundColor: color.Surface.Container,
minWidth: toRem(200),
padding: '0',
selectors: {
'&:hover': {
backgroundColor: color.Surface.ContainerHover,
Expand Down
Loading
Loading