diff --git a/.vscode/settings.json b/.vscode/settings.json index 8272ea1e4..5723fa3f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,11 @@ { "editor.formatOnSave": true, "editor.defaultFormatter": "esbenp.prettier-vscode", - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } } diff --git a/config.json b/config.json index 644f0eb61..ce9af001e 100644 --- a/config.json +++ b/config.json @@ -1,8 +1,9 @@ { "defaultHomeserver": 1, "homeserverList": [ - "converser.eu", + "sable.moe", "matrix.org", + "converser.eu", "mozilla.org", "unredacted.org", "xmr.se" @@ -12,6 +13,7 @@ "featuredCommunities": { "openAsDefault": false, "spaces": [ + "#bdsystem:sable.moe", "#cinny-space:matrix.org", "#community:matrix.org", "#space:unredacted.org", @@ -27,7 +29,7 @@ "#PrivSec.dev:arcticfoxes.net", "#disroot:aria-net.org" ], - "servers": [ "matrix.org", "mozilla.org", "unredacted.org" ] + "servers": [ "sable.moe", "matrix.org", "mozilla.org", "unredacted.org" ] }, "hashRouter": { diff --git a/index.html b/index.html index 2eefeee2c..4a2788709 100644 --- a/index.html +++ b/index.html @@ -1,96 +1,42 @@ - - - - - Cinny - - - - - - - - - + + + + + Sable Client + + + + - + + + + + - - - - - - + - - - - - - - - - - - - - -
-
- - - + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/package.json b/package.json index 601323adf..29ad4bbf6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cinny", "version": "4.10.3", - "description": "Yet another matrix client", + "description": "Yet another matrix client fork", "main": "index.js", "type": "module", "engines": { diff --git a/public/favicon.ico b/public/favicon.ico deleted file mode 100644 index 916713065..000000000 Binary files a/public/favicon.ico and /dev/null differ diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 000000000..d33a0186b Binary files /dev/null and b/public/favicon.png differ diff --git a/public/manifest.json b/public/manifest.json index acdcd0042..a4fda1116 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,7 +1,7 @@ { - "name": "Cinny", - "short_name": "Cinny", - "description": "Yet another matrix client", + "name": "Sable", + "short_name": "Sable", + "description": "Yet another matrix client fork", "dir": "auto", "lang": "en-US", "display": "standalone", diff --git a/src/app/components/splash-screen/SplashScreen.tsx b/src/app/components/splash-screen/SplashScreen.tsx index 27adadbad..7ef878ec5 100644 --- a/src/app/components/splash-screen/SplashScreen.tsx +++ b/src/app/components/splash-screen/SplashScreen.tsx @@ -21,7 +21,7 @@ export function SplashScreen({ children }: SplashScreenProps) { justifyContent="Center" > - Cinny + Sable diff --git a/src/app/features/common-settings/cosmetics/Cosmetics.tsx b/src/app/features/common-settings/cosmetics/Cosmetics.tsx new file mode 100644 index 000000000..b68c11129 --- /dev/null +++ b/src/app/features/common-settings/cosmetics/Cosmetics.tsx @@ -0,0 +1,108 @@ +import React, { useCallback } from 'react'; +import { + Box, + Text, + IconButton, + Icon, + Icons, + Scroll, + Switch, +} from 'folds'; +import { Page, PageContent, PageHeader } from '../../../components/page'; +import { SequenceCard } from '../../../components/sequence-card'; +import { SequenceCardStyle } from '../styles.css'; +import { SettingTile } from '../../../components/setting-tile'; +import { useRoom } from '../../../hooks/useRoom'; +import { usePowerLevels } from '../../../hooks/usePowerLevels'; +import { useMatrixClient } from '../../../hooks/useMatrixClient'; +import { StateEvent } from '../../../../types/matrix/room'; +import { useRoomCreators } from '../../../hooks/useRoomCreators'; +import { useRoomPermissions } from '../../../hooks/useRoomPermissions'; + +type CosmeticsProps = { + requestClose: () => void; +}; + +export function Cosmetics({ requestClose }: CosmeticsProps) { + const mx = useMatrixClient(); + const room = useRoom(); + const creators = useRoomCreators(room); + const powerLevels = usePowerLevels(room); + const isSpace = room.isSpaceRoom(); + + const permissions = useRoomPermissions(creators, powerLevels); + const canEditPermissions = permissions.stateEvent(StateEvent.RoomPowerLevels, mx.getSafeUserId()); + + const currentLevel = (powerLevels as any).events?.[StateEvent.RoomCosmeticsColor] ?? 50; + + const handleToggle = useCallback(async (enabled: boolean) => { + const newLevel = enabled ? 0 : 50; + + const newContent = { + ...powerLevels, + events: { + ...((powerLevels as any).events || {}), + [StateEvent.RoomCosmeticsColor]: newLevel, + }, + }; + + try { + await mx.sendStateEvent(room.roomId, StateEvent.RoomPowerLevels as any, newContent, ""); + } catch (e) { + console.error("Failed to update cosmetic permissions:", e); + } + }, [mx, room.roomId, powerLevels]); + + return ( + + + + + + Cosmetics + + + + + + + + + + + + + + + Settings + + + } + /> + + + + + + + + ); +} \ No newline at end of file diff --git a/src/app/features/room-settings/RoomSettings.tsx b/src/app/features/room-settings/RoomSettings.tsx index 32b5df9c6..1cdd67164 100644 --- a/src/app/features/room-settings/RoomSettings.tsx +++ b/src/app/features/room-settings/RoomSettings.tsx @@ -17,6 +17,7 @@ import { Permissions } from './permissions'; import { RoomSettingsPage } from '../../state/roomSettings'; import { useRoom } from '../../hooks/useRoom'; import { DeveloperTools } from '../common-settings/developer-tools'; +import { Cosmetics } from '../common-settings/cosmetics/Cosmetics'; type RoomSettingsMenuItem = { page: RoomSettingsPage; @@ -42,6 +43,11 @@ const useRoomSettingsMenuItems = (): RoomSettingsMenuItem[] => name: 'Permissions', icon: Icons.Lock, }, + { + page: RoomSettingsPage.CosmeticsPage, + name: 'Cosmetics', + icon: Icons.Alphabet, + }, { page: RoomSettingsPage.EmojisStickersPage, name: 'Emojis & Stickers', @@ -161,6 +167,9 @@ export function RoomSettings({ initialPage, requestClose }: RoomSettingsProps) { {activePage === RoomSettingsPage.PermissionsPage && ( )} + {activePage === RoomSettingsPage.CosmeticsPage && ( + + )} {activePage === RoomSettingsPage.EmojisStickersPage && ( )} diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 9324e1c29..303941968 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -32,7 +32,7 @@ import React, { } from 'react'; import FocusTrap from 'focus-trap-react'; import { useHover, useFocusWithin } from 'react-aria'; -import { MatrixEvent, Room } from 'matrix-js-sdk'; +import { EventTimeline, MatrixEvent, Room } from 'matrix-js-sdk'; import { Relations } from 'matrix-js-sdk/lib/models/relations'; import classNames from 'classnames'; import { RoomPinnedEventsEventContent } from 'matrix-js-sdk/lib/types'; @@ -79,6 +79,7 @@ import { MemberPowerTag, StateEvent } from '../../../../types/matrix/room'; import { PowerIcon } from '../../../components/power'; import colorMXID from '../../../../util/colorMXID'; import { getPowerTagIconSrc } from '../../../hooks/useMemberPowerTag'; +import { AccountDataEvent } from '../../../../types/matrix/accountData'; export type ReactionHandler = (keyOrMxc: string, shortcode: string) => void; @@ -741,7 +742,27 @@ export const Message = as<'div', MessageProps>( ? getPowerTagIconSrc(mx, useAuthentication, memberPowerTag.icon) : undefined; - const usernameColor = legacyUsernameColor ? colorMXID(senderId) : tagColor; + // Sable cosmetic username colors + const localColor = room?.getLiveTimeline() + .getState(EventTimeline.FORWARDS) + ?.getStateEvents(StateEvent.RoomCosmeticsColor, senderId) + ?.getContent()?.color; + + const parents = room?.getLiveTimeline() + .getState(EventTimeline.FORWARDS) + ?.getStateEvents(StateEvent.SpaceParent); + + let spaceColor; + if (parents && parents.length > 0) { + const parentSpaceId = parents[0].getStateKey(); + const parentSpace = mx.getRoom(parentSpaceId); + spaceColor = parentSpace?.getLiveTimeline() + .getState(EventTimeline.FORWARDS) + ?.getStateEvents(StateEvent.RoomCosmeticsColor, senderId) + ?.getContent()?.color; + } + + const usernameColor = localColor || spaceColor || (legacyUsernameColor ? colorMXID(senderId) : tagColor); const headerJSX = !collapse && ( - Cinny + Sable v4.10.3 - Yet another matrix client. + Yet another matrix client fork. diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx index e0df06df9..b83fe1d36 100644 --- a/src/app/features/settings/notifications/SystemNotification.tsx +++ b/src/app/features/settings/notifications/SystemNotification.tsx @@ -27,7 +27,7 @@ function EmailNotification() { device_display_name: email, lang: 'en', data: { - brand: 'Cinny', + brand: 'Sable', }, append: true, }); diff --git a/src/app/features/space-settings/SpaceSettings.tsx b/src/app/features/space-settings/SpaceSettings.tsx index e565fb92c..6343e49f9 100644 --- a/src/app/features/space-settings/SpaceSettings.tsx +++ b/src/app/features/space-settings/SpaceSettings.tsx @@ -17,6 +17,7 @@ import { Members } from '../common-settings/members'; import { DeveloperTools } from '../common-settings/developer-tools'; import { General } from './general'; import { Permissions } from './permissions'; +import { Cosmetics } from '../common-settings/cosmetics/Cosmetics'; type SpaceSettingsMenuItem = { page: SpaceSettingsPage; @@ -42,6 +43,11 @@ const useSpaceSettingsMenuItems = (): SpaceSettingsMenuItem[] => name: 'Permissions', icon: Icons.Lock, }, + { + page: SpaceSettingsPage.CosmeticsPage, + name: 'Cosmetics', + icon: Icons.Alphabet, + }, { page: SpaceSettingsPage.EmojisStickersPage, name: 'Emojis & Stickers', @@ -162,6 +168,9 @@ export function SpaceSettings({ initialPage, requestClose }: SpaceSettingsProps) {activePage === SpaceSettingsPage.PermissionsPage && ( )} + {activePage === SpaceSettingsPage.CosmeticsPage && ( + + )} {activePage === SpaceSettingsPage.EmojisStickersPage && ( )} diff --git a/src/app/hooks/useCommands.ts b/src/app/hooks/useCommands.ts index c02b0e94e..1c5e56f14 100644 --- a/src/app/hooks/useCommands.ts +++ b/src/app/hooks/useCommands.ts @@ -3,6 +3,7 @@ import { EventTimeline, IContextResponse, MatrixClient, + MatrixEvent, Method, Preset, Room, @@ -27,6 +28,7 @@ import { Membership, StateEvent } from '../../types/matrix/room'; import { getStateEvent } from '../utils/room'; import { splitWithSpace } from '../utils/common'; import { createRoomEncryptionState } from '../components/create-room'; +import { AccountDataEvent } from '../../types/matrix/accountData'; export const SHRUG = '¯\\_(ツ)_/¯'; export const TABLEFLIP = '(╯°□°)╯︵ ┻━┻'; @@ -138,6 +140,7 @@ export const parseTimestampFlag = (input: string): number | undefined => { export type CommandExe = (payload: string) => Promise; export enum Command { + // Cinny commands Me = 'me', Notice = 'notice', Shrug = 'shrug', @@ -159,6 +162,9 @@ export enum Command { UnFlip = 'unflip', Delete = 'delete', Acl = 'acl', + // Sable commands + Color = 'color', + GColor = 'gcolor' } export type CommandContent = { @@ -174,6 +180,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { const commands: CommandRecord = useMemo( () => ({ + // Cinny commands [Command.Me]: { name: Command.Me, description: 'Send action message', @@ -483,7 +490,7 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { [Command.Acl]: { name: Command.Acl, description: - 'Manage server access control list. Example /acl [-a servername1] [-d servername2] [-ra servername1] [-rd servername2]', + 'Manage server access control list. Example: /acl [-a servername1] [-d servername2] [-ra servername1] [-rd servername2]', exe: async (payload) => { const [, flags] = splitPayloadContentAndFlags(payload); @@ -531,6 +538,91 @@ export const useCommands = (mx: MatrixClient, room: Room): CommandRecord => { await mx.sendStateEvent(room.roomId, StateEvent.RoomServerAcl as any, aclContent); }, }, + // Sable commands + [Command.Color]: { + name: Command.Color, + description: 'Set a room-specific color. Example: /color #ff00ff | /color reset', + exe: async (payload) => { + const input = payload.trim().toLowerCase(); + const userId = mx.getSafeUserId(); + + const sendFeedback = (msg: string) => { + const localNotice = new (window as any).matrixcs.MatrixEvent({ + type: 'm.room.message', + content: { msgtype: 'm.notice', body: msg }, + event_id: `~sable-${Date.now()}`, + room_id: room.roomId, + sender: userId, + }); + (room as any).addLiveEvents([localNotice], { duplicateStrategy: 'ignore' } as any); + }; + + try { + if (input === 'reset' || input === 'clear') { + await mx.sendStateEvent(room.roomId, StateEvent.RoomCosmeticsColor as any, {}, userId); + sendFeedback('Room color has been reset.'); + return; + } + + if (/^#[0-9A-F]{6}$/i.test(input)) { + await mx.sendStateEvent(room.roomId, StateEvent.RoomCosmeticsColor as any, { color: input }, userId); + sendFeedback(`Room color set to ${input}.`); + } else { + sendFeedback('Invalid format. Use #RRGGBB.'); + } + } catch (e: any) { + if (e.errcode === 'M_FORBIDDEN') { + sendFeedback('Permission Denied. An admin must enable "Room Colors" in Settings > Cosmetics in app.sable.moe or another supported client.'); + } + } + } + }, + [Command.GColor]: { + name: Command.GColor, + description: 'Set your global color for the current Space. Example: /gcolor #ff00ff | /gcolor reset', + exe: async (payload) => { + const input = payload.trim().toLowerCase(); + const userId = mx.getSafeUserId(); + + const sendFeedback = (msg: string) => { + const localNotice = new (window as any).matrixcs.MatrixEvent({ + type: 'm.room.message', + content: { msgtype: 'm.notice', body: msg }, + event_id: `~sable-g-${Date.now()}`, + room_id: room.roomId, + sender: userId, + }); + (room as any).addLiveEvents([localNotice], { duplicateStrategy: 'ignore' } as any); + }; + + const parents = room.getLiveTimeline() + .getState(EventTimeline.FORWARDS) + ?.getStateEvents(StateEvent.SpaceParent); + + const targetSpaceId = parents && parents.length > 0 + ? parents[0].getStateKey() + : room.roomId; + + try { + if (input === 'reset' || input === 'clear') { + await mx.sendStateEvent(targetSpaceId as any, StateEvent.RoomCosmeticsColor as any, {}, userId); + sendFeedback('Global Space color reset.'); + return; + } + + if (/^#[0-9A-F]{6}$/i.test(input)) { + await mx.sendStateEvent(targetSpaceId as any, StateEvent.RoomCosmeticsColor as any, { color: input }, userId); + sendFeedback(`Global Space color set to ${input}.`); + } else { + sendFeedback('Invalid format. Use #RRGGBB.'); + } + } catch (e: any) { + if (e.errcode === 'M_FORBIDDEN') { + sendFeedback('Permission Denied. An admin must enable "Space-Wide Colors" in Settings > Cosmetics in app.sable.moe or another supported client.'); + } + } + }, + }, }), [mx, room, navigateRoom] ); diff --git a/src/app/pages/auth/AuthFooter.tsx b/src/app/pages/auth/AuthFooter.tsx index 124b0384c..1bba9adc3 100644 --- a/src/app/pages/auth/AuthFooter.tsx +++ b/src/app/pages/auth/AuthFooter.tsx @@ -5,13 +5,13 @@ import * as css from './styles.css'; export function AuthFooter() { return ( - + About diff --git a/src/app/pages/auth/AuthLayout.tsx b/src/app/pages/auth/AuthLayout.tsx index 3943f42d1..d4000cc39 100644 --- a/src/app/pages/auth/AuthLayout.tsx +++ b/src/app/pages/auth/AuthLayout.tsx @@ -20,7 +20,7 @@ import { } from '../../hooks/useClientConfig'; import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback'; import { LOGIN_PATH, REGISTER_PATH, RESET_PASSWORD_PATH } from '../paths'; -import CinnySVG from '../../../../public/res/svg/cinny.svg'; +import CinnySVG from '../../../../public/favicon.png'; import { ServerPicker } from './ServerPicker'; import { AutoDiscoveryAction, autoDiscovery } from '../../cs-api'; import { SpecVersionsLoader } from '../../components/SpecVersionsLoader'; @@ -135,7 +135,7 @@ export function AuthLayout() {
Cinny Logo - Cinny + Sable
diff --git a/src/app/pages/auth/login/PasswordLoginForm.tsx b/src/app/pages/auth/login/PasswordLoginForm.tsx index 62f46dd2c..8d015b9d3 100644 --- a/src/app/pages/auth/login/PasswordLoginForm.tsx +++ b/src/app/pages/auth/login/PasswordLoginForm.tsx @@ -133,7 +133,7 @@ export function PasswordLoginForm({ defaultUsername, defaultEmail }: PasswordLog user: username, }, password, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }; @@ -151,7 +151,7 @@ export function PasswordLoginForm({ defaultUsername, defaultEmail }: PasswordLog user: mxIdUsername, }, password, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }; const handleEmailLogin = (email: string, password: string) => { @@ -163,7 +163,7 @@ export function PasswordLoginForm({ defaultUsername, defaultEmail }: PasswordLog address: email, }, password, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }; diff --git a/src/app/pages/auth/login/TokenLogin.tsx b/src/app/pages/auth/login/TokenLogin.tsx index 761d5dc53..f0a08f105 100644 --- a/src/app/pages/auth/login/TokenLogin.tsx +++ b/src/app/pages/auth/login/TokenLogin.tsx @@ -57,7 +57,7 @@ export function TokenLogin({ token }: TokenLoginProps) { startLogin(baseUrl, { type: 'm.login.token', token, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }, [baseUrl, token, startLogin]); diff --git a/src/app/pages/auth/register/PasswordRegisterForm.tsx b/src/app/pages/auth/register/PasswordRegisterForm.tsx index 9f1734229..464b95613 100644 --- a/src/app/pages/auth/register/PasswordRegisterForm.tsx +++ b/src/app/pages/auth/register/PasswordRegisterForm.tsx @@ -109,7 +109,7 @@ function RegisterUIAFlow({ auth: authDict, password, username, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }, [onRegister, formData] @@ -250,7 +250,7 @@ export function PasswordRegisterForm({ auth: { session: authData.session, }, - initial_device_display_name: 'Cinny Web', + initial_device_display_name: 'Sable Web', }); }; diff --git a/src/app/pages/client/WelcomePage.tsx b/src/app/pages/client/WelcomePage.tsx index 969a5cd4f..559a2d356 100644 --- a/src/app/pages/client/WelcomePage.tsx +++ b/src/app/pages/client/WelcomePage.tsx @@ -15,12 +15,12 @@ export function WelcomePage() { } - title="Welcome to Cinny" + title="Welcome to Sable" subTitle={ - Yet another matrix client.{' '} + Yet another matrix client fork.{' '} @@ -33,7 +33,7 @@ export function WelcomePage() {