Merge branch 'ajbura:dev' into voicemail
This commit is contained in:
commit
e3c9f4320f
12 changed files with 96 additions and 26 deletions
|
@ -153,6 +153,7 @@ function RoomProfile({ roomId }) {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
<Text variant="b3">{room.getCanonicalAlias() || room.roomId}</Text>
|
||||||
{roomTopic && <Text variant="b2">{twemojify(roomTopic, undefined, true)}</Text>}
|
{roomTopic && <Text variant="b2">{twemojify(roomTopic, undefined, true)}</Text>}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& > *:last-child {
|
& > *:not(:first-child) {
|
||||||
margin-top: var(--sp-ultra-tight);
|
margin-top: var(--sp-ultra-tight);
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
|
|
|
@ -21,7 +21,7 @@ function RoomSelectorWrapper({
|
||||||
className="room-selector__content"
|
className="room-selector__content"
|
||||||
type="button"
|
type="button"
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onMouseUp={(e) => blurOnBubbling(e, '.room-selector')}
|
onMouseUp={(e) => blurOnBubbling(e, '.room-selector__content')}
|
||||||
>
|
>
|
||||||
{content}
|
{content}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -49,11 +49,11 @@ function Selector({
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const joinRuleToIconSrc = {
|
const joinRuleToIconSrc = (joinRule) => ({
|
||||||
restricted: () => (room.isSpaceRoom() ? SpaceIC : HashIC),
|
restricted: () => (room.isSpaceRoom() ? SpaceIC : HashIC),
|
||||||
invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC),
|
invite: () => (room.isSpaceRoom() ? SpaceLockIC : HashLockIC),
|
||||||
public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC),
|
public: () => (room.isSpaceRoom() ? SpaceGlobeIC : HashGlobeIC),
|
||||||
};
|
}[joinRule]?.() || null);
|
||||||
|
|
||||||
if (room.isSpaceRoom()) {
|
if (room.isSpaceRoom()) {
|
||||||
return (
|
return (
|
||||||
|
@ -61,7 +61,7 @@ function Selector({
|
||||||
key={roomId}
|
key={roomId}
|
||||||
name={room.name}
|
name={room.name}
|
||||||
roomId={roomId}
|
roomId={roomId}
|
||||||
iconSrc={joinRuleToIconSrc[room.getJoinRule()]?.() || null}
|
iconSrc={joinRuleToIconSrc(room.getJoinRule())}
|
||||||
isUnread={noti.hasNoti(roomId)}
|
isUnread={noti.hasNoti(roomId)}
|
||||||
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
|
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
|
||||||
isAlert={noti.getHighlightNoti(roomId) !== 0}
|
isAlert={noti.getHighlightNoti(roomId) !== 0}
|
||||||
|
@ -90,7 +90,7 @@ function Selector({
|
||||||
name={room.name}
|
name={room.name}
|
||||||
roomId={roomId}
|
roomId={roomId}
|
||||||
imageSrc={isDM ? imageSrc : null}
|
imageSrc={isDM ? imageSrc : null}
|
||||||
iconSrc={isDM ? null : joinRuleToIconSrc[room.getJoinRule()]?.() || null}
|
iconSrc={isDM ? null : joinRuleToIconSrc(room.getJoinRule())}
|
||||||
isSelected={isSelected}
|
isSelected={isSelected}
|
||||||
isUnread={noti.hasNoti(roomId)}
|
isUnread={noti.hasNoti(roomId)}
|
||||||
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
|
notificationCount={abbreviateNumber(noti.getTotalNoti(roomId))}
|
||||||
|
|
|
@ -261,6 +261,7 @@ function ProfileViewer() {
|
||||||
function renderProfile() {
|
function renderProfile() {
|
||||||
const member = room.getMember(userId) || mx.getUser(userId) || {};
|
const member = room.getMember(userId) || mx.getUser(userId) || {};
|
||||||
const avatarMxc = member.getMxcAvatarUrl?.() || member.avatarUrl;
|
const avatarMxc = member.getMxcAvatarUrl?.() || member.avatarUrl;
|
||||||
|
const canChangeRole = room.currentState.maySendEvent('m.room.power_levels', mx.getUserId());
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="profile-viewer">
|
<div className="profile-viewer">
|
||||||
|
@ -277,7 +278,7 @@ function ProfileViewer() {
|
||||||
</div>
|
</div>
|
||||||
<div className="profile-viewer__user__role">
|
<div className="profile-viewer__user__role">
|
||||||
<Text variant="b3">Role</Text>
|
<Text variant="b3">Role</Text>
|
||||||
<Button iconSrc={ChevronBottomIC}>{getPowerLabel(member.powerLevel) || 'Member'}</Button>
|
<Button iconSrc={canChangeRole ? ChevronBottomIC : null}>{getPowerLabel(member.powerLevel) || 'Member'}</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SessionInfo userId={userId} />
|
<SessionInfo userId={userId} />
|
||||||
|
|
|
@ -56,7 +56,7 @@ function RoomViewHeader({ roomId }) {
|
||||||
|
|
||||||
roomList.on(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
roomList.on(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
||||||
return () => {
|
return () => {
|
||||||
roomList.on(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
roomList.removeListener(cons.events.roomList.ROOM_PROFILE_UPDATED, handleProfileUpdate);
|
||||||
};
|
};
|
||||||
}, [roomId]);
|
}, [roomId]);
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,10 @@ import RoomSelector from '../../molecules/room-selector/RoomSelector';
|
||||||
|
|
||||||
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
|
import SearchIC from '../../../../public/res/ic/outlined/search.svg';
|
||||||
import HashIC from '../../../../public/res/ic/outlined/hash.svg';
|
import HashIC from '../../../../public/res/ic/outlined/hash.svg';
|
||||||
|
import HashGlobeIC from '../../../../public/res/ic/outlined/hash-globe.svg';
|
||||||
import HashLockIC from '../../../../public/res/ic/outlined/hash-lock.svg';
|
import HashLockIC from '../../../../public/res/ic/outlined/hash-lock.svg';
|
||||||
import SpaceIC from '../../../../public/res/ic/outlined/space.svg';
|
import SpaceIC from '../../../../public/res/ic/outlined/space.svg';
|
||||||
|
import SpaceGlobeIC from '../../../../public/res/ic/outlined/space-globe.svg';
|
||||||
import SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg';
|
import SpaceLockIC from '../../../../public/res/ic/outlined/space-lock.svg';
|
||||||
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
import CrossIC from '../../../../public/res/ic/outlined/cross.svg';
|
||||||
|
|
||||||
|
@ -176,12 +178,18 @@ function Search() {
|
||||||
|
|
||||||
const notifs = initMatrix.notifications;
|
const notifs = initMatrix.notifications;
|
||||||
const renderRoomSelector = (item) => {
|
const renderRoomSelector = (item) => {
|
||||||
const isPrivate = item.room.getJoinRule() === 'invite';
|
|
||||||
let imageSrc = null;
|
let imageSrc = null;
|
||||||
let iconSrc = null;
|
let iconSrc = null;
|
||||||
if (item.type === 'room') iconSrc = isPrivate ? HashLockIC : HashIC;
|
if (item.type === 'direct') {
|
||||||
if (item.type === 'space') iconSrc = isPrivate ? SpaceLockIC : SpaceIC;
|
imageSrc = item.room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
|
||||||
if (item.type === 'direct') imageSrc = item.room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 24, 24, 'crop') || null;
|
} else {
|
||||||
|
const joinRuleToIconSrc = (joinRule) => ({
|
||||||
|
restricted: () => (item.type === 'space' ? SpaceIC : HashIC),
|
||||||
|
invite: () => (item.type === 'space' ? SpaceLockIC : HashLockIC),
|
||||||
|
public: () => (item.type === 'space' ? SpaceGlobeIC : HashGlobeIC),
|
||||||
|
}[joinRule]?.() || null);
|
||||||
|
iconSrc = joinRuleToIconSrc(item.room.getJoinRule());
|
||||||
|
}
|
||||||
|
|
||||||
const isUnread = notifs.hasNoti(item.roomId);
|
const isUnread = notifs.hasNoti(item.roomId);
|
||||||
const noti = notifs.getNoti(item.roomId);
|
const noti = notifs.getNoti(item.roomId);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import './Settings.scss';
|
||||||
import initMatrix from '../../../client/initMatrix';
|
import initMatrix from '../../../client/initMatrix';
|
||||||
import cons from '../../../client/state/cons';
|
import cons from '../../../client/state/cons';
|
||||||
import settings from '../../../client/state/settings';
|
import settings from '../../../client/state/settings';
|
||||||
import { toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents } from '../../../client/action/settings';
|
import { toggleSystemTheme, toggleMarkdown, toggleMembershipEvents, toggleNickAvatarEvents } from '../../../client/action/settings';
|
||||||
import logout from '../../../client/action/logout';
|
import logout from '../../../client/action/logout';
|
||||||
|
|
||||||
import Text from '../../atoms/text/Text';
|
import Text from '../../atoms/text/Text';
|
||||||
|
@ -49,20 +49,34 @@ function AppearanceSection() {
|
||||||
return (
|
return (
|
||||||
<div className="settings-content">
|
<div className="settings-content">
|
||||||
<SettingTile
|
<SettingTile
|
||||||
title="Theme"
|
title="Follow system theme"
|
||||||
content={(
|
options={(
|
||||||
<SegmentedControls
|
<Toggle
|
||||||
selected={settings.getThemeIndex()}
|
isActive={settings.useSystemTheme}
|
||||||
segments={[
|
onToggle={() => { toggleSystemTheme(); updateState({}); }}
|
||||||
{ text: 'Light' },
|
|
||||||
{ text: 'Silver' },
|
|
||||||
{ text: 'Dark' },
|
|
||||||
{ text: 'Butter' },
|
|
||||||
]}
|
|
||||||
onSelect={(index) => settings.setTheme(index)}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
content={<Text variant="b3">Use light or dark mode based on the system's settings.</Text>}
|
||||||
/>
|
/>
|
||||||
|
{(() => {
|
||||||
|
if (!settings.useSystemTheme) {
|
||||||
|
return <SettingTile
|
||||||
|
title="Theme"
|
||||||
|
content={(
|
||||||
|
<SegmentedControls
|
||||||
|
selected={settings.getThemeIndex()}
|
||||||
|
segments={[
|
||||||
|
{ text: 'Light' },
|
||||||
|
{ text: 'Silver' },
|
||||||
|
{ text: 'Dark' },
|
||||||
|
{ text: 'Butter' },
|
||||||
|
]}
|
||||||
|
onSelect={(index) => settings.setTheme(index)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
<SettingTile
|
<SettingTile
|
||||||
title="Markdown formatting"
|
title="Markdown formatting"
|
||||||
options={(
|
options={(
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import appDispatcher from '../dispatcher';
|
import appDispatcher from '../dispatcher';
|
||||||
import cons from '../state/cons';
|
import cons from '../state/cons';
|
||||||
|
|
||||||
|
export function toggleSystemTheme() {
|
||||||
|
appDispatcher.dispatch({
|
||||||
|
type: cons.actions.settings.TOGGLE_SYSTEM_THEME,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function toggleMarkdown() {
|
export function toggleMarkdown() {
|
||||||
appDispatcher.dispatch({
|
appDispatcher.dispatch({
|
||||||
type: cons.actions.settings.TOGGLE_MARKDOWN,
|
type: cons.actions.settings.TOGGLE_MARKDOWN,
|
||||||
|
|
|
@ -55,6 +55,7 @@ const cons = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
|
TOGGLE_SYSTEM_THEME: 'TOGGLE_SYSTEM_THEME',
|
||||||
TOGGLE_MARKDOWN: 'TOGGLE_MARKDOWN',
|
TOGGLE_MARKDOWN: 'TOGGLE_MARKDOWN',
|
||||||
TOGGLE_PEOPLE_DRAWER: 'TOGGLE_PEOPLE_DRAWER',
|
TOGGLE_PEOPLE_DRAWER: 'TOGGLE_PEOPLE_DRAWER',
|
||||||
TOGGLE_MEMBERSHIP_EVENT: 'TOGGLE_MEMBERSHIP_EVENT',
|
TOGGLE_MEMBERSHIP_EVENT: 'TOGGLE_MEMBERSHIP_EVENT',
|
||||||
|
@ -112,6 +113,7 @@ const cons = {
|
||||||
ATTACHMENT_CANCELED: 'ATTACHMENT_CANCELED',
|
ATTACHMENT_CANCELED: 'ATTACHMENT_CANCELED',
|
||||||
},
|
},
|
||||||
settings: {
|
settings: {
|
||||||
|
SYSTEM_THEME_TOGGLED: 'SYSTEM_THEME_TOGGLED',
|
||||||
MARKDOWN_TOGGLED: 'MARKDOWN_TOGGLED',
|
MARKDOWN_TOGGLED: 'MARKDOWN_TOGGLED',
|
||||||
PEOPLE_DRAWER_TOGGLED: 'PEOPLE_DRAWER_TOGGLED',
|
PEOPLE_DRAWER_TOGGLED: 'PEOPLE_DRAWER_TOGGLED',
|
||||||
MEMBERSHIP_EVENTS_TOGGLED: 'MEMBERSHIP_EVENTS_TOGGLED',
|
MEMBERSHIP_EVENTS_TOGGLED: 'MEMBERSHIP_EVENTS_TOGGLED',
|
||||||
|
|
|
@ -23,6 +23,7 @@ class Settings extends EventEmitter {
|
||||||
this.themes = ['', 'silver-theme', 'dark-theme', 'butter-theme'];
|
this.themes = ['', 'silver-theme', 'dark-theme', 'butter-theme'];
|
||||||
this.themeIndex = this.getThemeIndex();
|
this.themeIndex = this.getThemeIndex();
|
||||||
|
|
||||||
|
this.useSystemTheme = this.getUseSystemTheme();
|
||||||
this.isMarkdown = this.getIsMarkdown();
|
this.isMarkdown = this.getIsMarkdown();
|
||||||
this.isPeopleDrawer = this.getIsPeopleDrawer();
|
this.isPeopleDrawer = this.getIsPeopleDrawer();
|
||||||
this.hideMembershipEvents = this.getHideMembershipEvents();
|
this.hideMembershipEvents = this.getHideMembershipEvents();
|
||||||
|
@ -56,6 +57,15 @@ class Settings extends EventEmitter {
|
||||||
this.themeIndex = themeIndex;
|
this.themeIndex = themeIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getUseSystemTheme() {
|
||||||
|
if (typeof this.useSystemTheme === 'boolean') return this.useSystemTheme;
|
||||||
|
|
||||||
|
const settings = getSettings();
|
||||||
|
if (settings === null) return false;
|
||||||
|
if (typeof settings.useSystemTheme === 'undefined') return false;
|
||||||
|
return settings.useSystemTheme;
|
||||||
|
}
|
||||||
|
|
||||||
getIsMarkdown() {
|
getIsMarkdown() {
|
||||||
if (typeof this.isMarkdown === 'boolean') return this.isMarkdown;
|
if (typeof this.isMarkdown === 'boolean') return this.isMarkdown;
|
||||||
|
|
||||||
|
@ -94,6 +104,24 @@ class Settings extends EventEmitter {
|
||||||
|
|
||||||
setter(action) {
|
setter(action) {
|
||||||
const actions = {
|
const actions = {
|
||||||
|
[cons.actions.settings.TOGGLE_SYSTEM_THEME]: () => {
|
||||||
|
this.useSystemTheme = !this.useSystemTheme;
|
||||||
|
setSettings('useSystemTheme', this.useSystemTheme);
|
||||||
|
const appBody = document.getElementById('appBody');
|
||||||
|
|
||||||
|
if (this.useSystemTheme) {
|
||||||
|
appBody.classList.add('system-theme');
|
||||||
|
this.themes.forEach((themeName) => {
|
||||||
|
if (themeName === '') return;
|
||||||
|
appBody.classList.remove(themeName);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
appBody.classList.remove('system-theme');
|
||||||
|
this.setTheme(this.themeIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.emit(cons.events.settings.SYSTEM_THEME_TOGGLED, this.useSystemTheme);
|
||||||
|
},
|
||||||
[cons.actions.settings.TOGGLE_MARKDOWN]: () => {
|
[cons.actions.settings.TOGGLE_MARKDOWN]: () => {
|
||||||
this.isMarkdown = !this.isMarkdown;
|
this.isMarkdown = !this.isMarkdown;
|
||||||
setSettings('isMarkdown', this.isMarkdown);
|
setSettings('isMarkdown', this.isMarkdown);
|
||||||
|
|
|
@ -202,8 +202,7 @@
|
||||||
--bg-surface-extra-low-transparent: hsla(0, 0%, 91%, 0);
|
--bg-surface-extra-low-transparent: hsla(0, 0%, 91%, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-theme,
|
@mixin dark-mode() {
|
||||||
.butter-theme {
|
|
||||||
/* background color | --bg-[background type]: value */
|
/* background color | --bg-[background type]: value */
|
||||||
--bg-surface: hsl(208, 8%, 20%);
|
--bg-surface: hsl(208, 8%, 20%);
|
||||||
--bg-surface-transparent: hsla(208, 8%, 20%, 0);
|
--bg-surface-transparent: hsla(208, 8%, 20%, 0);
|
||||||
|
@ -290,6 +289,17 @@
|
||||||
--font-secondary: 'Inter', 'Roboto', sans-serif;
|
--font-secondary: 'Inter', 'Roboto', sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark-theme,
|
||||||
|
.butter-theme {
|
||||||
|
@include dark-mode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
.system-theme {
|
||||||
|
@include dark-mode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.butter-theme {
|
.butter-theme {
|
||||||
/* background color | --bg-[background type]: value */
|
/* background color | --bg-[background type]: value */
|
||||||
--bg-surface: hsl(64, 6%, 14%);
|
--bg-surface: hsl(64, 6%, 14%);
|
||||||
|
|
Loading…
Reference in a new issue