Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

perf: cut desktop renderer and GPU memory (#3901)

Hampus7e84eb5735c4
diff --git a/fluxer_app/rspack.config.mjs b/fluxer_app/rspack.config.mjs
index 889c57187..505d0dc56 100644
--- a/fluxer_app/rspack.config.mjs
+++ b/fluxer_app/rspack.config.mjs
@@ -1013,9 +1013,11 @@ export default () => {
minimize: isProduction,
minimizer: [
new SwcJsMinimizerRspackPlugin({
- compress: true,
- mangle: true,
- format: {comments: false},
+ minimizerOptions: {
+ compress: true,
+ mangle: true,
+ format: {comments: false, asciiOnly: isDesktopRenderer},
+ },
exclude: /\.worklet\.js$/,
}),
new LightningCssMinimizerRspackPlugin(),
diff --git a/fluxer_app/src/app/App.tsx b/fluxer_app/src/app/App.tsx
index 8c53741cd..d4d11e1bd 100644
--- a/fluxer_app/src/app/App.tsx
+++ b/fluxer_app/src/app/App.tsx
@@ -145,7 +145,6 @@ export const AppWrapper = observer(({children}: AppWrapperProps) => {
const hasBlockingModal = Modal.hasModalOpen();
const room = MediaEngine.room;
const ringsContainerRef = useRef<HTMLDivElement>(null);
- const overlayScopeRef = useRef<HTMLDivElement>(null);
useElectronScreenSharePicker();
useTextInputContextMenu();
const handleSkipLinkFocus = useTabKeyFocusGuard();
@@ -262,7 +261,7 @@ export const AppWrapper = observer(({children}: AppWrapperProps) => {
{children}
</FocusRingScope>
</div>
- <div ref={overlayScopeRef} className={styles.overlayScope} data-flx="app.app.app-wrapper.overlay-scope">
+ <div className={styles.overlayScope} data-flx="app.app.app-wrapper.overlay-scope">
<NekoSprite data-flx="app.app.app-wrapper.neko-sprite" />
<div
id={QUICK_SWITCHER_PORTAL_ID}
diff --git a/fluxer_app/src/features/app/components/dialogs/Modal.module.css b/fluxer_app/src/features/app/components/dialogs/Modal.module.css
index 56c797156..a27365932 100644
--- a/fluxer_app/src/features/app/components/dialogs/Modal.module.css
+++ b/fluxer_app/src/features/app/components/dialogs/Modal.module.css
@@ -5,6 +5,7 @@
inset: 0;
pointer-events: none;
position: fixed;
+ will-change: opacity;
}
.layer {
diff --git a/fluxer_app/src/features/app/components/dialogs/shared/SettingsModalLayout.module.css b/fluxer_app/src/features/app/components/dialogs/shared/SettingsModalLayout.module.css
index f3d1b6ce9..f7a8685d1 100644
--- a/fluxer_app/src/features/app/components/dialogs/shared/SettingsModalLayout.module.css
+++ b/fluxer_app/src/features/app/components/dialogs/shared/SettingsModalLayout.module.css
@@ -54,6 +54,11 @@
background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}
+.modalRoot.modalRoot.modalRoot {
+ --settings-modal-inner-radius: calc(clamp(0.5rem, 1vw, 0.75rem) - 0.0625rem);
+ overflow: visible;
+}
+
.containerFullscreen {
--settings-edge-gutter: clamp(1rem, 3vw, 1.5rem);
max-width: 87.5rem;
@@ -95,8 +100,10 @@
flex: 0 0 clamp(15.75rem, 24svw, 20rem);
display: flex;
border-inline-end: 0.0625rem solid var(--settings-border-color);
+ border-start-start-radius: var(--settings-modal-inner-radius, 0);
+ border-end-start-radius: var(--settings-modal-inner-radius, 0);
background: var(--settings-surface-background);
- overflow: hidden;
+ min-width: 0;
position: relative;
}
@@ -108,6 +115,8 @@
height: 100%;
flex: 1 1 auto;
min-width: 0;
+ position: relative;
+ overflow: hidden;
}
.desktopSidebar,
@@ -124,10 +133,11 @@
flex: 1;
display: flex;
flex-direction: column;
+ border-start-end-radius: var(--settings-modal-inner-radius, 0);
+ border-end-end-radius: var(--settings-modal-inner-radius, 0);
background: var(--background-secondary);
min-width: 0;
min-height: 0;
- overflow: hidden;
}
.desktopContentPad {
@@ -161,6 +171,7 @@
justify-content: space-between;
padding: 0 1rem;
flex-shrink: 0;
+ border-start-end-radius: var(--settings-modal-inner-radius, 0);
background: var(--background-secondary);
border-bottom: 0.0625rem solid var(--settings-border-color);
contain: layout style paint;
@@ -173,6 +184,14 @@
scroll-padding-top: 0;
}
+.desktopScroll + [data-flx='ui.scroller.scroller-track.presentation.track-pointer-down'] {
+ clip-path: inset(-100vh 0 0 -100vw round var(--settings-modal-inner-radius, 0));
+}
+
+:global(html[dir='rtl']) .desktopScroll + [data-flx='ui.scroller.scroller-track.presentation.track-pointer-down'] {
+ clip-path: inset(-100vh -100vw 0 0 round var(--settings-modal-inner-radius, 0));
+}
+
.desktopScrollInner {
width: 100%;
margin: 0 auto;
diff --git a/fluxer_app/src/features/app/components/layout/GuildHeader.module.css b/fluxer_app/src/features/app/components/layout/GuildHeader.module.css
index 698b18187..38e67e958 100644
--- a/fluxer_app/src/features/app/components/layout/GuildHeader.module.css
+++ b/fluxer_app/src/features/app/components/layout/GuildHeader.module.css
@@ -66,9 +66,12 @@
box-sizing: border-box;
background-color: var(--background-secondary);
border-bottom: 0.0625rem solid var(--user-area-divider-color);
+ pointer-events: none;
+}
+
+:global(html.user-stylesheets) .headerGlass {
backdrop-filter: blur(1.25rem);
-webkit-backdrop-filter: blur(1.25rem);
- pointer-events: none;
}
.bannerGradient {
diff --git a/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css b/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css
index 569f7f76c..72209e542 100644
--- a/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css
+++ b/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css
@@ -521,6 +521,10 @@
--outline-radius: 0px;
}
+.outlineFrame.outlineFrameFullscreen {
+ --outline-frame-clip-radius: 0px;
+}
+
.outlineFrameFullscreen {
border: none;
border-radius: 0;
@@ -540,6 +544,7 @@
}
:global(html.platform-native) .outlineFrame {
+ --outline-frame-top-border-width: 0.0625rem;
border-top: 0.0625rem solid var(--user-area-divider-color);
--outline-radius: var(--outline-frame-radius-native);
}
diff --git a/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx b/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
index 8a083ea6d..bc3d5d085 100644
--- a/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
+++ b/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
@@ -2287,6 +2287,7 @@ export const GuildsLayout = observer(({children}: {children: React.ReactNode}) =
<TopNagbarContext.Provider value={activeNagbars.length}>
<OutlineFrame
className={clsx(styles.outlineFrame, isVoiceCallFullscreenActive && styles.outlineFrameFullscreen)}
+ cornerCap={!isVoiceCallFullscreenActive}
sidebarDivider={!isVoiceCallFullscreenActive && shouldShowSidebarDivider}
sidebarResizeHandle={!isVoiceCallFullscreenActive && shouldShowSidebarDivider}
nagbar={
diff --git a/fluxer_app/src/features/app/components/layout/OutlineFrame.module.css b/fluxer_app/src/features/app/components/layout/OutlineFrame.module.css
index 55ff620a1..9586892ba 100644
--- a/fluxer_app/src/features/app/components/layout/OutlineFrame.module.css
+++ b/fluxer_app/src/features/app/components/layout/OutlineFrame.module.css
@@ -1,28 +1,93 @@
/* SPDX-License-Identifier: AGPL-3.0-or-later */
+.bounds {
+ height: 100%;
+ width: 100%;
+ min-height: 0;
+ min-width: 0;
+ overflow: clip;
+}
+
.frame {
+ --outline-frame-clip-radius: max(0px, var(--outline-radius, 0px) - var(--outline-frame-border-width, 0.0625rem));
+ --outline-frame-start-border-width: var(--outline-frame-border-width, 0.0625rem);
position: relative;
height: 100%;
width: 100%;
border: var(--outline-frame-border-width, 0.0625rem) solid var(--user-area-divider-color);
border-top: none;
border-start-start-radius: var(--outline-radius, 0px);
- background: var(--background-secondary-lighter);
- overflow: hidden;
+ --outline-frame-background: var(--background-secondary-lighter);
+ background: var(--outline-frame-background);
+ display: flex;
+ flex-direction: column;
+}
+
+.clip {
+ position: relative;
+ flex: 1;
+ min-height: 0;
display: flex;
flex-direction: column;
+ overflow: clip;
+ border-radius: var(--outline-frame-clip-radius);
+ margin-inline-end: calc(-1 * var(--outline-frame-clip-radius));
+ margin-block-end: calc(-1 * var(--outline-frame-clip-radius));
+ padding-inline-end: var(--outline-frame-clip-radius);
+ padding-block-end: var(--outline-frame-clip-radius);
}
.frameShowTop {
+ --outline-frame-top-border-width: 0.0625rem;
border-top: 0.0625rem solid var(--user-area-divider-color);
}
.frameHideTop {
+ --outline-frame-top-border-width: 0px;
border-top: none;
}
-.frameHideTop {
- border-top: none;
+.frameCornerCap {
+ --outline-frame-clip-radius: 0px;
+}
+
+:global(html.user-stylesheets) .frameCornerCap {
+ --outline-frame-clip-radius: max(0px, var(--outline-radius, 0px) - var(--outline-frame-border-width, 0.0625rem));
+}
+
+:global(html.user-stylesheets) .cornerCap {
+ display: none;
+}
+
+.cornerCap {
+ position: absolute;
+ top: 0;
+ inset-inline-start: 0;
+ z-index: 4;
+ width: var(--outline-radius, 0px);
+ height: var(--outline-radius, 0px);
+ overflow: hidden;
+ pointer-events: none;
+}
+
+.cornerCap::before,
+.cornerCap::after {
+ content: '';
+ position: absolute;
+ top: calc(-1 * var(--outline-frame-top-border-width, 0px));
+ inset-inline-start: calc(-1 * var(--outline-frame-start-border-width));
+ box-sizing: border-box;
+ width: calc(2 * var(--outline-radius, 0px));
+ height: calc(2 * var(--outline-radius, 0px));
+ border: 0 solid var(--user-area-divider-color);
+ border-top-width: var(--outline-frame-top-border-width, 0px);
+ border-inline-start-width: var(--outline-frame-start-border-width);
+ border-start-start-radius: var(--outline-radius, 0px);
+}
+
+.cornerCap::before {
+ border-color: var(--outline-frame-background);
+ box-shadow: 0 0 0 var(--outline-radius, 0px) var(--background-secondary);
}
.contentWrapper {
diff --git a/fluxer_app/src/features/app/components/layout/OutlineFrame.tsx b/fluxer_app/src/features/app/components/layout/OutlineFrame.tsx
index eeadc851b..e5cc0adf0 100644
--- a/fluxer_app/src/features/app/components/layout/OutlineFrame.tsx
+++ b/fluxer_app/src/features/app/components/layout/OutlineFrame.tsx
@@ -11,6 +11,7 @@ interface OutlineFrameProps {
sidebarDivider?: boolean;
sidebarResizeHandle?: boolean;
hideTopBorder?: boolean;
+ cornerCap?: boolean;
sides?: FrameSides;
nagbar?: React.ReactNode;
children: React.ReactNode;
@@ -21,6 +22,7 @@ export const OutlineFrame: React.FC<OutlineFrameProps> = ({
sidebarDivider = false,
sidebarResizeHandle = false,
hideTopBorder = false,
+ cornerCap = false,
sides,
nagbar,
children,
@@ -36,34 +38,44 @@ export const OutlineFrame: React.FC<OutlineFrameProps> = ({
};
}, [hideTopBorder, sides]);
const showTopBorder = ctxSides.top !== false;
- const frameStyle = useMemo<React.CSSProperties>(() => {
+ const frameStyle = useMemo<
+ React.CSSProperties & {'--outline-frame-clip-radius'?: string; '--outline-frame-start-border-width'?: string}
+ >(() => {
return {
+ '--outline-frame-clip-radius': ctxSides.left === false ? 'var(--outline-radius, 0px)' : undefined,
+ '--outline-frame-start-border-width': ctxSides.left === false ? '0px' : undefined,
borderLeft: ctxSides.left === false ? 'none' : undefined,
borderRight: ctxSides.right === false ? 'none' : undefined,
borderBottom: ctxSides.bottom === false ? 'none' : undefined,
};
}, [ctxSides.bottom, ctxSides.left, ctxSides.right]);
return (
- <div
- className={clsx(
- styles.frame,
- showTopBorder && styles.frameShowTop,
- !showTopBorder && styles.frameHideTop,
- className,
- )}
- style={frameStyle}
- data-flx="app.outline-frame.frame"
- >
- <FrameContext.Provider value={ctxSides}>
- {nagbar}
- <div className={styles.contentWrapper} data-flx="app.outline-frame.content-wrapper">
- {sidebarDivider && <div className={styles.divider} aria-hidden data-flx="app.outline-frame.divider" />}
- {sidebarResizeHandle && <SidebarResizeHandle data-flx="app.outline-frame.sidebar-resize-handle" />}
- <div className={styles.body} data-flx="app.outline-frame.body">
- {children}
+ <div className={styles.bounds} data-flx="app.outline-frame.bounds">
+ <div
+ className={clsx(
+ styles.frame,
+ showTopBorder && styles.frameShowTop,
+ !showTopBorder && styles.frameHideTop,
+ cornerCap && styles.frameCornerCap,
+ className,
+ )}
+ style={frameStyle}
+ data-flx="app.outline-frame.frame"
+ >
+ <FrameContext.Provider value={ctxSides}>
+ <div className={styles.clip} data-flx="app.outline-frame.clip">
+ {nagbar}
+ <div className={styles.contentWrapper} data-flx="app.outline-frame.content-wrapper">
+ {sidebarDivider && <div className={styles.divider} aria-hidden data-flx="app.outline-frame.divider" />}
+ {sidebarResizeHandle && <SidebarResizeHandle data-flx="app.outline-frame.sidebar-resize-handle" />}
+ <div className={styles.body} data-flx="app.outline-frame.body">
+ {children}
+ </div>
+ </div>
</div>
- </div>
- </FrameContext.Provider>
+ {cornerCap && <div className={styles.cornerCap} aria-hidden data-flx="app.outline-frame.corner-cap" />}
+ </FrameContext.Provider>
+ </div>
</div>
);
};
diff --git a/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildFolderItem.tsx b/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildFolderItem.tsx
index 8efd2fdd8..298003aee 100644
--- a/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildFolderItem.tsx
+++ b/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildFolderItem.tsx
@@ -765,7 +765,7 @@ interface MiniGuildIconProps {
}
const MiniGuildIcon = observer(({guild}: MiniGuildIconProps) => {
- const iconURL = useRecoveringBackgroundImageURL(AvatarSourceUtils.getGuildIconURL(guild, false));
+ const iconURL = useRecoveringBackgroundImageURL(AvatarSourceUtils.getGuildRailIconURL(guild, false));
if (iconURL != null) {
return (
<flx-app-mini-guild-icon
diff --git a/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildListItemPresentation.tsx b/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildListItemPresentation.tsx
index 30b757020..6a4b66733 100644
--- a/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildListItemPresentation.tsx
+++ b/fluxer_app/src/features/app/components/layout/sidebar_nav/GuildListItemPresentation.tsx
@@ -149,7 +149,7 @@ function GuildListItemBadges({
}
function CombinePreviewIcon({guild}: {readonly guild: Guild}) {
- const url = AvatarSourceUtils.getGuildIconURL(guild, false);
+ const url = AvatarSourceUtils.getGuildRailIconURL(guild, false);
const backgroundStyle: React.CSSProperties = {};
if (url.length > 0) {
backgroundStyle.backgroundImage = `url(${url})`;
diff --git a/fluxer_app/src/features/app/components/layout/sidebar_nav/UseGuildListItemInteraction.tsx b/fluxer_app/src/features/app/components/layout/sidebar_nav/UseGuildListItemInteraction.tsx
index f62894d77..bdd805e1e 100644
--- a/fluxer_app/src/features/app/components/layout/sidebar_nav/UseGuildListItemInteraction.tsx
+++ b/fluxer_app/src/features/app/components/layout/sidebar_nav/UseGuildListItemInteraction.tsx
@@ -71,8 +71,8 @@ export function useGuildListItemInteraction({
isMobileExperience,
isSortingList,
});
- const iconURL = AvatarSourceUtils.getGuildIconURL(guild, false);
- const hoverIconURL = AvatarSourceUtils.getGuildIconURL(guild, true);
+ const iconURL = AvatarSourceUtils.getGuildRailIconURL(guild, false);
+ const hoverIconURL = AvatarSourceUtils.getGuildRailIconURL(guild, true);
const isAnimatableIcon = hoverIconURL !== iconURL;
const [loadedAnimatedURL, setLoadedAnimatedURL] = useState<string | null>(null);
const [bottomSheetOpen, setBottomSheetOpen] = useState(false);
diff --git a/fluxer_app/src/features/app/components/skeleton/ScrollFillerSkeleton.module.css b/fluxer_app/src/features/app/components/skeleton/ScrollFillerSkeleton.module.css
index 5f3f024a7..f64571d71 100644
--- a/fluxer_app/src/features/app/components/skeleton/ScrollFillerSkeleton.module.css
+++ b/fluxer_app/src/features/app/components/skeleton/ScrollFillerSkeleton.module.css
@@ -12,6 +12,7 @@
position: relative;
overflow: hidden;
contain: strict;
+ content-visibility: auto;
transition: none;
padding-top: 1rem;
padding-bottom: var(--message-filler-padding-bottom);
diff --git a/fluxer_app/src/features/channel/components/ChannelMembers.tsx b/fluxer_app/src/features/channel/components/ChannelMembers.tsx
index b538d8a6f..3b1f9db4c 100644
--- a/fluxer_app/src/features/channel/components/ChannelMembers.tsx
+++ b/fluxer_app/src/features/channel/components/ChannelMembers.tsx
@@ -61,7 +61,6 @@ import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
import {ChannelTypes, Permissions} from '@fluxer/constants/src/ChannelConstants';
import {MEMBER_LIST_RANGE_MAX_SPAN} from '@fluxer/constants/src/GatewayConstants';
import {GuildOperations} from '@fluxer/constants/src/GuildConstants';
-import {MEDIA_PROXY_AVATAR_SIZE_DEFAULT} from '@fluxer/constants/src/MediaProxyAssetSizes';
import {useLingui as useLinguiRuntime} from '@lingui/react';
import {useLingui} from '@lingui/react/macro';
import clsx from 'clsx';
@@ -497,7 +496,6 @@ const LazyMemberList = observer(function LazyMemberList({guild, channel}: LazyMe
roleColor={roleColor}
displayName={displayName}
disableBackdrop={true}
- avatarMediaSize={MEDIA_PROXY_AVATAR_SIZE_DEFAULT}
data-flx="channel.channel-members.lazy-member-list.virtual-row.member-list-item--2"
/>
</div>,
diff --git a/fluxer_app/src/features/channel/components/MemberListItem.tsx b/fluxer_app/src/features/channel/components/MemberListItem.tsx
index 649e4981b..fb587872d 100644
--- a/fluxer_app/src/features/channel/components/MemberListItem.tsx
+++ b/fluxer_app/src/features/channel/components/MemberListItem.tsx
@@ -18,12 +18,12 @@ import {FocusRingWrapper} from '@app/features/ui/components/FocusRingWrapper';
import {ListStatusAwareAvatar} from '@app/features/ui/components/StatusAwareAvatar';
import {useTextOverflow} from '@app/features/ui/hooks/useTextOverflow';
import {Tooltip} from '@app/features/ui/tooltip/Tooltip';
+import {getAppRemScale} from '@app/features/ui/utils/AppZoomUtils';
import type {User} from '@app/features/user/models/User';
import type {CustomStatus} from '@app/features/user/state/CustomStatus';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
import {GuildFeatures} from '@fluxer/constants/src/GuildConstants';
-import type {MediaProxyImageSize} from '@fluxer/constants/src/MediaProxyImageSizes';
import type {StatusType} from '@fluxer/constants/src/StatusConstants';
import {isOfflineStatus} from '@fluxer/constants/src/StatusConstants';
import {msg} from '@lingui/core/macro';
@@ -57,9 +57,10 @@ interface MemberListItemProps {
roleColor?: string;
displayName?: string;
disableBackdrop?: boolean;
- avatarMediaSize?: MediaProxyImageSize;
}
+const MEMBER_AVATAR_SIZE = 32;
+
export const MemberListItem: React.FC<MemberListItemProps> = observer((props) => {
const {i18n} = useLingui();
const {
@@ -74,7 +75,6 @@ export const MemberListItem: React.FC<MemberListItemProps> = observer((props) =>
roleColor,
displayName,
disableBackdrop = false,
- avatarMediaSize,
} = props;
const itemRef = useRef<HTMLButtonElement>(null);
const hookStatus = useMemberListPresence({
@@ -163,9 +163,9 @@ export const MemberListItem: React.FC<MemberListItemProps> = observer((props) =>
memberAvatar: guildMember.avatar,
avatarUnset: guildMember.isAvatarUnset(),
animated: false,
- size: avatarMediaSize,
+ size: MEMBER_AVATAR_SIZE * getAppRemScale(),
});
- }, [avatarMediaSize, guildId, guildMember, user]);
+ }, [guildId, guildMember, user]);
const memberHoverAvatarUrl = useMemo(() => {
if (!guildId || !guildMember) {
return undefined;
@@ -176,9 +176,9 @@ export const MemberListItem: React.FC<MemberListItemProps> = observer((props) =>
memberAvatar: guildMember.avatar,
avatarUnset: guildMember.isAvatarUnset(),
animated: true,
- size: avatarMediaSize,
+ size: MEMBER_AVATAR_SIZE * getAppRemScale(),
});
- }, [avatarMediaSize, guildId, guildMember, user]);
+ }, [guildId, guildMember, user]);
const nameContent = (
<span
ref={nameRef}
@@ -210,7 +210,7 @@ export const MemberListItem: React.FC<MemberListItemProps> = observer((props) =>
<div className={styles.avatarContainer} data-flx="channel.member-list-item.avatar-container">
<ListStatusAwareAvatar
user={user}
- size={32}
+ size={MEMBER_AVATAR_SIZE}
isTyping={isTyping}
showOffline={isCurrentUser || isTyping}
guildId={guildId}
@@ -218,7 +218,6 @@ export const MemberListItem: React.FC<MemberListItemProps> = observer((props) =>
isMobile={isMobile}
avatarUrl={memberAvatarUrl}
hoverAvatarUrl={memberHoverAvatarUrl}
- mediaSize={avatarMediaSize}
data-flx="channel.member-list-item.status-aware-avatar"
/>
</div>
diff --git a/fluxer_app/src/features/channel/components/direct_message/DMChannelView.module.css b/fluxer_app/src/features/channel/components/direct_message/DMChannelView.module.css
index fb282a292..8928c5232 100644
--- a/fluxer_app/src/features/channel/components/direct_message/DMChannelView.module.css
+++ b/fluxer_app/src/features/channel/components/direct_message/DMChannelView.module.css
@@ -78,7 +78,6 @@
z-index: 2;
border-radius: 624.9375rem;
transition: filter 220ms ease;
- will-change: transform, filter;
}
.callParticipantRinging .callParticipantAvatar {
diff --git a/fluxer_app/src/features/channel/components/modals/ChannelSettingsModal.tsx b/fluxer_app/src/features/channel/components/modals/ChannelSettingsModal.tsx
index 3b275a7c7..02b7b8603 100644
--- a/fluxer_app/src/features/channel/components/modals/ChannelSettingsModal.tsx
+++ b/fluxer_app/src/features/channel/components/modals/ChannelSettingsModal.tsx
@@ -4,6 +4,7 @@ import {DesktopChannelSettingsView} from '@app/features/app/components/dialogs/c
import {MobileChannelSettingsView} from '@app/features/app/components/dialogs/components/MobileChannelSettingsView';
import * as Modal from '@app/features/app/components/dialogs/Modal';
import {SettingsModalContainer} from '@app/features/app/components/dialogs/shared/SettingsModalLayout';
+import settingsModalStyles from '@app/features/app/components/dialogs/shared/SettingsModalLayout.module.css';
import Channels from '@app/features/channel/state/Channels';
import {
type ChannelSettingsModalProps,
@@ -93,7 +94,12 @@ export const ChannelSettingsModal: React.FC<ChannelSettingsModalProps> = observe
}
const isCategory = channel.type === ChannelTypes.GUILD_CATEGORY;
return (
- <Modal.Root size="fullscreen" onClose={handleClose} data-flx="channel.channel-settings-modal.modal-root">
+ <Modal.Root
+ size="fullscreen"
+ className={settingsModalStyles.modalRoot}
+ onClose={handleClose}
+ data-flx="channel.channel-settings-modal.modal-root"
+ >
<Modal.ScreenReaderLabel
text={i18n._(isCategory ? CATEGORY_SETTINGS_LABEL_DESCRIPTOR : CHANNEL_SETTINGS_LABEL_DESCRIPTOR)}
data-flx="channel.channel-settings-modal.modal-screen-reader-label"
diff --git a/fluxer_app/src/features/guild/components/modals/GuildSettingsModal.tsx b/fluxer_app/src/features/guild/components/modals/GuildSettingsModal.tsx
index fe4100866..0c853b36c 100644
--- a/fluxer_app/src/features/guild/components/modals/GuildSettingsModal.tsx
+++ b/fluxer_app/src/features/guild/components/modals/GuildSettingsModal.tsx
@@ -5,6 +5,7 @@ import {DesktopGuildSettingsView} from '@app/features/app/components/dialogs/com
import {MobileGuildSettingsView} from '@app/features/app/components/dialogs/components/MobileGuildSettingsView';
import * as Modal from '@app/features/app/components/dialogs/Modal';
import {SettingsModalContainer} from '@app/features/app/components/dialogs/shared/SettingsModalLayout';
+import settingsModalStyles from '@app/features/app/components/dialogs/shared/SettingsModalLayout.module.css';
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
import GatewaySessions from '@app/features/gateway/transport/GatewaySessionPool';
import GuildSettingsModalState from '@app/features/guild/state/GuildSettingsModal';
@@ -158,7 +159,12 @@ export const GuildSettingsModal: React.FC<GuildSettingsModalProps> = observer(
return null;
}
return (
- <Modal.Root size="fullscreen" onClose={handleClose} data-flx="guild.guild-settings-modal.modal-root">
+ <Modal.Root
+ size="fullscreen"
+ className={settingsModalStyles.modalRoot}
+ onClose={handleClose}
+ data-flx="guild.guild-settings-modal.modal-root"
+ >
<Modal.ScreenReaderLabel
text={i18n._(GUILD_SETTINGS_LABEL_DESCRIPTOR)}
data-flx="guild.guild-settings-modal.modal-screen-reader-label"
diff --git a/fluxer_app/src/features/messaging/components/markdown/renderers/TimestampRenderer.tsx b/fluxer_app/src/features/messaging/components/markdown/renderers/TimestampRenderer.tsx
index 271688fc9..da3ec6bb4 100644
--- a/fluxer_app/src/features/messaging/components/markdown/renderers/TimestampRenderer.tsx
+++ b/fluxer_app/src/features/messaging/components/markdown/renderers/TimestampRenderer.tsx
@@ -12,9 +12,23 @@ import {Tooltip} from '@app/features/ui/tooltip/Tooltip';
import {getCurrentLocale} from '@app/features/user/utils/LocaleUtils';
import {getFormattedDateTimeWithSeconds} from '@fluxer/date_utils/src/DateFormatting';
import {DateTime} from 'luxon';
+import {computed} from 'mobx';
import {observer} from 'mobx-react-lite';
import React, {type ReactElement, useMemo} from 'react';
+interface RelativeLabels {
+ readonly displayTime: string;
+ readonly relativeTime: string | null;
+}
+
+function areRelativeLabelsEqual(a: RelativeLabels, b: RelativeLabels): boolean {
+ return a.displayTime === b.displayTime && a.relativeTime === b.relativeTime;
+}
+
+function readTickSecond(): number {
+ return Tick.nowSecond;
+}
+
export const TimestampRenderer = observer(function TimestampRenderer({
node,
id,
@@ -23,15 +37,30 @@ export const TimestampRenderer = observer(function TimestampRenderer({
const {timestamp, style} = node;
const i18n = options.i18n;
const date = getDateFromUnixTimestampSeconds(timestamp);
- const isValidTimestamp = date !== null;
const locale = getCurrentLocale();
const fullDateTime = date !== null ? getFormattedDateTimeWithSeconds(date, locale) : null;
const isRelativeStyle = style === TimestampStyle.RelativeTime;
- const tick = isRelativeStyle ? Tick.nowSecond : 0;
- const relativeDisplayTime = useMemo(() => {
- return isValidTimestamp ? formatTimestamp(timestamp, style, i18n) : '';
- }, [tick, isValidTimestamp, timestamp, style, i18n.locale]);
- const relativeTime = date !== null ? DateTime.fromJSDate(date).setLocale(locale).toRelative() : null;
+ const relativeLabels = useMemo(
+ () =>
+ computed(
+ (): RelativeLabels => {
+ if (isRelativeStyle) {
+ readTickSecond();
+ }
+ const labelDate = getDateFromUnixTimestampSeconds(timestamp);
+ if (labelDate === null) {
+ return {displayTime: '', relativeTime: null};
+ }
+ return {
+ displayTime: formatTimestamp(timestamp, style, i18n),
+ relativeTime: DateTime.fromJSDate(labelDate).setLocale(locale).toRelative(),
+ };
+ },
+ {equals: areRelativeLabelsEqual},
+ ),
+ [isRelativeStyle, timestamp, style, i18n, i18n.locale, locale],
+ ).get();
+ const relativeTime = relativeLabels.relativeTime;
if (date === null || fullDateTime === null) {
return React.createElement('span', {className: markupStyles.timestamp}, String(timestamp));
}
@@ -54,7 +83,7 @@ export const TimestampRenderer = observer(function TimestampRenderer({
</div>
</div>
);
- const displayTime = isRelativeStyle ? relativeDisplayTime : formatTimestamp(timestamp, style, i18n);
+ const displayTime = relativeLabels.displayTime;
return (
<Tooltip
key={id}
diff --git a/fluxer_app/src/features/messaging/utils/ImageRetention.ts b/fluxer_app/src/features/messaging/utils/ImageRetention.ts
index d277b1965..cdd146b18 100644
--- a/fluxer_app/src/features/messaging/utils/ImageRetention.ts
+++ b/fluxer_app/src/features/messaging/utils/ImageRetention.ts
@@ -1,9 +1,12 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
+import {unwrapDesktopLocalResourceURL} from '@app/features/messaging/utils/DesktopLocalResourceTarget';
import {LRUCache} from 'lru-cache';
const RETAINED_IMAGE_BYTE_BUDGET = 192 * 1024 * 1024;
const RETAINED_IMAGE_MAX_ENTRIES = 2000;
+const RETAINED_VECTOR_IMAGE_MAX_ENTRIES = 48;
+const RETAINED_IMAGE_MAX_PIXELS = 2048 * 2048;
const RETAINED_IMAGE_MIN_BYTES = 1024;
const BYTES_PER_PIXEL = 4;
const MAX_RETAINED_SOURCE_LENGTH = 16 * 1024;
@@ -14,25 +17,47 @@ const retainedImages = new LRUCache<string, HTMLImageElement>({
sizeCalculation: (image) => estimateDecodedBytes(image.naturalWidth, image.naturalHeight),
});
+const retainedVectorImages = new LRUCache<string, HTMLImageElement>({max: RETAINED_VECTOR_IMAGE_MAX_ENTRIES});
+
+type RetentionKind = 'raster' | 'vector' | 'none';
+
function estimateDecodedBytes(width: number, height: number): number {
return Math.min(RETAINED_IMAGE_BYTE_BUDGET, Math.max(RETAINED_IMAGE_MIN_BYTES, width * height * BYTES_PER_PIXEL));
}
-function isRetainableSource(src: string): boolean {
- return (
- src.length > 0 && src.length <= MAX_RETAINED_SOURCE_LENGTH && !src.startsWith('data:') && !src.startsWith('blob:')
- );
+function classifySource(src: string): RetentionKind {
+ if (src.length === 0 || src.length > MAX_RETAINED_SOURCE_LENGTH) return 'none';
+ if (src.startsWith('data:') || src.startsWith('blob:')) return 'none';
+ let url: URL;
+ try {
+ url = new URL(unwrapDesktopLocalResourceURL(src));
+ } catch {
+ return 'none';
+ }
+ if (url.searchParams.get('animated') === 'true') return 'none';
+ const path = url.pathname.toLowerCase();
+ if (path.endsWith('.gif') && !url.searchParams.has('format')) return 'none';
+ return path.endsWith('.svg') ? 'vector' : 'raster';
+}
+
+function createHolder(src: string): HTMLImageElement {
+ const holder = new Image();
+ holder.decoding = 'async';
+ holder.src = src;
+ return holder;
}
export function retainImage(image: HTMLImageElement): void {
if (!image.complete || image.naturalWidth <= 0) return;
const src = image.currentSrc || image.src;
- if (!isRetainableSource(src)) return;
+ const kind = classifySource(src);
+ if (kind === 'vector') {
+ if (retainedVectorImages.get(src) == null) retainedVectorImages.set(src, createHolder(src));
+ return;
+ }
+ if (kind === 'none' || image.naturalWidth * image.naturalHeight > RETAINED_IMAGE_MAX_PIXELS) return;
if (retainedImages.get(src) != null) return;
- const holder = new Image();
- holder.decoding = 'async';
- holder.src = src;
- retainedImages.set(src, holder, {size: estimateDecodedBytes(image.naturalWidth, image.naturalHeight)});
+ retainedImages.set(src, createHolder(src), {size: estimateDecodedBytes(image.naturalWidth, image.naturalHeight)});
}
export function installImageRetention(target: Document): () => void {
diff --git a/fluxer_app/src/features/theme/hooks/useCustomThemeStyle.ts b/fluxer_app/src/features/theme/hooks/useCustomThemeStyle.ts
index 346ccfa8e..fa7a109e1 100644
--- a/fluxer_app/src/features/theme/hooks/useCustomThemeStyle.ts
+++ b/fluxer_app/src/features/theme/hooks/useCustomThemeStyle.ts
@@ -29,10 +29,17 @@ const USER_STYLE_ELEMENT_IDS: ReadonlySet<string> = new Set([
INSTANCE_CUSTOM_CSS_ELEMENT_ID,
]);
+const USER_STYLESHEETS_CLASS = 'user-stylesheets';
+
export function excludeUserStylesheets(node: Element): boolean {
return USER_STYLE_ELEMENT_IDS.has(node.id);
}
+function syncUserStylesheetsClass(): void {
+ const applied = [...USER_STYLE_ELEMENT_IDS].some((id) => document.getElementById(id) !== null);
+ document.documentElement.classList.toggle(USER_STYLESHEETS_CLASS, applied);
+}
+
interface CustomThemeStyleOptions {
enabledThemeCss: string | null | undefined;
customThemeCss: string | null | undefined;
@@ -54,6 +61,7 @@ export function useInstanceCustomCss(instanceCss: string | null, gatedOrigins: R
if (!css) {
if (existing) {
existing.remove();
+ syncUserStylesheetsClass();
clearRemScaleCache();
}
return;
@@ -64,6 +72,7 @@ export function useInstanceCustomCss(instanceCss: string | null, gatedOrigins: R
if (!existing) {
document.head.insertBefore(styleElement, document.getElementById(CUSTOM_THEME_STYLE_ELEMENT_ID));
}
+ syncUserStylesheetsClass();
clearRemScaleCache();
}, [instanceCss, gatedOriginsKey]);
}
@@ -137,6 +146,7 @@ function writeThemeStyle(applier: ThemeCssApplier, css: string, objectUrls: Arra
revokeObjectUrls(applier.objectUrls);
applier.objectUrls = objectUrls;
}
+ syncUserStylesheetsClass();
clearRemScaleCache();
}
diff --git a/fluxer_app/src/features/ui/avatars/AvatarWithPresence.tsx b/fluxer_app/src/features/ui/avatars/AvatarWithPresence.tsx
index 8293b390d..d35063c43 100644
--- a/fluxer_app/src/features/ui/avatars/AvatarWithPresence.tsx
+++ b/fluxer_app/src/features/ui/avatars/AvatarWithPresence.tsx
@@ -6,6 +6,7 @@ import GuildMembers from '@app/features/member/state/GuildMembers';
import * as ImageCacheUtils from '@app/features/messaging/utils/ImageCacheUtils';
import styles from '@app/features/ui/avatars/AvatarWithPresence.module.css';
import {BaseAvatar} from '@app/features/ui/components/BaseAvatar';
+import {getAppRemScale} from '@app/features/ui/utils/AppZoomUtils';
import type {User} from '@app/features/user/models/User';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
import {parseAvatarHash} from '@app/features/user/utils/AvatarUtils';
@@ -51,6 +52,7 @@ export const AvatarWithPresence: React.FC<Props> = observer(function AvatarWithP
}) {
const {i18n} = useLingui();
const guildMember = GuildMembers.getMember(guildId || '', user.id);
+ const requestSize = size * getAppRemScale();
const resolveSrc = (animation: 'static' | 'animated') =>
guildId && guildMember
? AvatarUtils.getGuildMemberDisplayAvatarURL({
@@ -59,8 +61,9 @@ export const AvatarWithPresence: React.FC<Props> = observer(function AvatarWithP
memberAvatar: guildMember.avatar,
avatarUnset: guildMember.isAvatarUnset(),
animated: animation === 'animated',
+ size: requestSize,
})
- : AvatarUtils.getUserAvatarURL({id: user.id, avatar: user.avatar}, animation === 'animated');
+ : AvatarUtils.getUserAvatarURL({id: user.id, avatar: user.avatar}, animation === 'animated', requestSize);
let displayAvatarHash: string | null;
if (guildId && guildMember) {
displayAvatarHash = guildMember.isAvatarUnset() ? null : (guildMember.avatar ?? user.avatar);
diff --git a/fluxer_app/src/features/ui/components/Avatar.tsx b/fluxer_app/src/features/ui/components/Avatar.tsx
index c998422b8..ed2a59a05 100644
--- a/fluxer_app/src/features/ui/components/Avatar.tsx
+++ b/fluxer_app/src/features/ui/components/Avatar.tsx
@@ -7,6 +7,7 @@ import {useShouldAnimate} from '@app/features/app/hooks/useShouldAnimate';
import GuildMembers from '@app/features/member/state/GuildMembers';
import * as ImageCacheUtils from '@app/features/messaging/utils/ImageCacheUtils';
import {BaseAvatar} from '@app/features/ui/components/BaseAvatar';
+import {getAppRemScale} from '@app/features/ui/utils/AppZoomUtils';
import type {User} from '@app/features/user/models/User';
import Users from '@app/features/user/state/Users';
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
@@ -69,6 +70,7 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
const hasGuildMemberAvatarSource = Boolean(guildId) && guildMember != null;
const memberAvatar = guildMember?.avatar ?? null;
const memberAvatarUnset = guildMember?.isAvatarUnset() ?? false;
+ const requestSize = mediaSize ?? size * getAppRemScale();
const avatarUrl = useMemo(() => {
if (customAvatarUrl !== undefined) return customAvatarUrl;
if (systemAvatarUrl !== null) return systemAvatarUrl;
@@ -79,17 +81,17 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
memberAvatar,
avatarUnset: memberAvatarUnset,
animated: false,
- size: mediaSize,
+ size: requestSize,
});
}
- return AvatarUtils.getUserAvatarURL({id: userId, avatar: userAvatar}, false, mediaSize);
+ return AvatarUtils.getUserAvatarURL({id: userId, avatar: userAvatar}, false, requestSize);
}, [
customAvatarUrl,
guildId,
hasGuildMemberAvatarSource,
memberAvatar,
memberAvatarUnset,
- mediaSize,
+ requestSize,
systemAvatarUrl,
userAvatar,
userId,
@@ -104,17 +106,17 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
memberAvatar,
avatarUnset: memberAvatarUnset,
animated: true,
- size: mediaSize,
+ size: requestSize,
});
}
- return AvatarUtils.getUserAvatarURL({id: userId, avatar: userAvatar}, true, mediaSize);
+ return AvatarUtils.getUserAvatarURL({id: userId, avatar: userAvatar}, true, requestSize);
}, [
customHoverAvatarUrl,
guildId,
hasGuildMemberAvatarSource,
memberAvatar,
memberAvatarUnset,
- mediaSize,
+ requestSize,
systemAvatarUrl,
userAvatar,
userId,
diff --git a/fluxer_app/src/features/ui/components/form/FormSwitch.module.css b/fluxer_app/src/features/ui/components/form/FormSwitch.module.css
index 97713f499..3ed53427c 100644
--- a/fluxer_app/src/features/ui/components/form/FormSwitch.module.css
+++ b/fluxer_app/src/features/ui/components/form/FormSwitch.module.css
@@ -102,7 +102,6 @@
transition-property: transform, box-shadow;
transition-duration: 150ms;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
- will-change: transform;
transform: translateX(calc(0.125rem * var(--switch-travel-sign, 1)));
}
diff --git a/fluxer_app/src/features/ui/tooltip/Tooltip.tsx b/fluxer_app/src/features/ui/tooltip/Tooltip.tsx
index 11e80b9ca..f9f0c1ecd 100644
--- a/fluxer_app/src/features/ui/tooltip/Tooltip.tsx
+++ b/fluxer_app/src/features/ui/tooltip/Tooltip.tsx
@@ -46,6 +46,8 @@ const logger = new Logger('Tooltip');
export type TooltipPosition = 'top' | 'left' | 'right' | 'bottom';
type TooltipType = 'normal' | 'error';
+const HOVER_VERIFY_INTERVAL_MS = 100;
+
const TOOLTIP_AUTO_UPDATE_OPTIONS = {
ancestorScroll: false,
ancestorResize: true,
@@ -679,21 +681,13 @@ export const Tooltip = observer(
useEffect(() => {
if (!tooltipModel.hovered || tooltipModel.dismissed || mobileLayout.enabled) return;
const ownerWindow = getTooltipOwnerWindow();
- let frameId: number | null = null;
- const verifyTargetHover = () => {
- const target = targetRef.current;
- if (!target?.matches(':hover')) {
+ const intervalId = ownerWindow.setInterval(() => {
+ if (!targetRef.current?.matches(':hover')) {
endVisibilityDriver('hover');
- frameId = null;
- return;
}
- frameId = ownerWindow.requestAnimationFrame(verifyTargetHover);
- };
- frameId = ownerWindow.requestAnimationFrame(verifyTargetHover);
+ }, HOVER_VERIFY_INTERVAL_MS);
return () => {
- if (frameId != null) {
- ownerWindow.cancelAnimationFrame(frameId);
- }
+ ownerWindow.clearInterval(intervalId);
};
}, [
endVisibilityDriver,
diff --git a/fluxer_app/src/features/user/components/modals/UserProfileModal.module.css b/fluxer_app/src/features/user/components/modals/UserProfileModal.module.css
index ed6131ac6..f85c2bceb 100644
--- a/fluxer_app/src/features/user/components/modals/UserProfileModal.module.css
+++ b/fluxer_app/src/features/user/components/modals/UserProfileModal.module.css
@@ -19,7 +19,7 @@
width: min(40rem, calc(100vw - 3rem), calc(76.923svh - 2.307688rem));
height: auto;
aspect-ratio: 10 / 13;
- overflow: hidden;
+ overflow: visible;
}
.userInfo {
@@ -269,15 +269,13 @@
}
.profileContentWrapper {
- --profile-modal-scroller-radius: var(--profile-modal-content-radius);
flex: 1;
min-height: 0;
min-width: 0;
overflow: hidden;
display: flex;
flex-direction: column;
- border-radius: var(--profile-modal-scroller-radius);
- clip-path: inset(0 round var(--profile-modal-scroller-radius));
+ border-radius: var(--profile-modal-content-radius);
background-color: var(--background-primary);
}
@@ -285,8 +283,6 @@
height: 100%;
min-height: 0;
min-width: 0;
- border-radius: var(--profile-modal-scroller-radius);
- clip-path: inset(0 round var(--profile-modal-scroller-radius));
}
.modalContainer {
@@ -297,9 +293,7 @@
min-width: 0;
width: 100%;
flex-direction: column;
- overflow: hidden;
border-radius: var(--profile-modal-radius);
- clip-path: inset(0 round var(--profile-modal-radius));
border-width: var(--profile-modal-border-width);
border-style: solid;
box-sizing: border-box;
diff --git a/fluxer_app/src/features/user/components/modals/UserSettingsModal.tsx b/fluxer_app/src/features/user/components/modals/UserSettingsModal.tsx
index b228e2d4f..572662e50 100644
--- a/fluxer_app/src/features/user/components/modals/UserSettingsModal.tsx
+++ b/fluxer_app/src/features/user/components/modals/UserSettingsModal.tsx
@@ -4,6 +4,7 @@ import {DesktopSettingsView} from '@app/features/app/components/dialogs/componen
import {MobileSettingsView} from '@app/features/app/components/dialogs/components/MobileSettingsView';
import * as Modal from '@app/features/app/components/dialogs/Modal';
import {SettingsModalContainer} from '@app/features/app/components/dialogs/shared/SettingsModalLayout';
+import settingsModalStyles from '@app/features/app/components/dialogs/shared/SettingsModalLayout.module.css';
import {ComponentBus} from '@app/features/platform/utils/ComponentBus';
import * as PlutoniumPageCommands from '@app/features/premium/commands/PlutoniumPageCommands';
import * as ModalCommands from '@app/features/ui/commands/ModalCommands';
@@ -175,7 +176,12 @@ export const UserSettingsModal: React.FC<UserSettingsModalProps> = observer(
}, [isMobile, mobileNav, resolveVisibleTab, visibleSettingsTabs]);
return (
<SettingsContentKeyProvider data-flx="user.user-settings-modal.settings-content-key-provider">
- <Modal.Root size="fullscreen" onClose={handleModalClose} data-flx="user.user-settings-modal.modal-root">
+ <Modal.Root
+ size="fullscreen"
+ className={settingsModalStyles.modalRoot}
+ onClose={handleModalClose}
+ data-flx="user.user-settings-modal.modal-root"
+ >
<Modal.ScreenReaderLabel
text={i18n._(USER_SETTINGS_LABEL_DESCRIPTOR)}
data-flx="user.user-settings-modal.modal-screen-reader-label"
diff --git a/fluxer_app/src/features/user/components/profile/UserProfileLoadingSkeleton.module.css b/fluxer_app/src/features/user/components/profile/UserProfileLoadingSkeleton.module.css
index d94b27279..785065d4a 100644
--- a/fluxer_app/src/features/user/components/profile/UserProfileLoadingSkeleton.module.css
+++ b/fluxer_app/src/features/user/components/profile/UserProfileLoadingSkeleton.module.css
@@ -29,7 +29,6 @@
min-height: 0;
flex: 1 1 auto;
flex-direction: column;
- will-change: opacity;
}
.popout {
diff --git a/fluxer_app/src/features/user/utils/AvatarUtils.ts b/fluxer_app/src/features/user/utils/AvatarUtils.ts
index c818837e2..6fcf12a23 100644
--- a/fluxer_app/src/features/user/utils/AvatarUtils.ts
+++ b/fluxer_app/src/features/user/utils/AvatarUtils.ts
@@ -85,6 +85,7 @@ export function getDefaultAvatarURLForInstance(id: string, instance: RuntimeConf
export {snapMediaProxyImageSize};
const GUILD_BANNER_CSS_WIDTH = 360;
+const GUILD_RAIL_ICON_CSS_SIZE = 44;
const GUILD_EMBED_SPLASH_CSS_WIDTH = 360;
const GUILD_SPLASH_FALLBACK_CSS_WIDTH = 1024;
@@ -219,7 +220,7 @@ const buildGuildMemberPngUrl = (params: Omit<GuildMemberMediaURLParams, 'format'
export function getUserAvatarURL(
{id, avatar}: AvatarOptions,
animated = false,
- size: MediaProxyImageSize = MEDIA_PROXY_AVATAR_SIZE_DEFAULT,
+ size: number = MEDIA_PROXY_AVATAR_SIZE_DEFAULT,
) {
if (!avatar) {
return getDefaultAvatarURLForIndex(getDefaultAvatarIndex(id));
@@ -317,7 +318,11 @@ export function getUserBannerURL({id, banner}: BannerOptions, animated = false,
const mediaURLCacheScope = (): string => `${RuntimeConfig.apiEndpoint} ${RuntimeConfig.mediaEndpoint}`;
-export function getGuildIconURL({id, icon}: IconOptions, animated = false) {
+export function getGuildIconURL(
+ {id, icon}: IconOptions,
+ animated = false,
+ size: number = MEDIA_PROXY_ICON_SIZE_DEFAULT,
+) {
if (!icon) {
return '';
}
@@ -326,11 +331,15 @@ export function getGuildIconURL({id, icon}: IconOptions, animated = false) {
path: 'icons',
id,
hash,
- size: snapIconImageSize(MEDIA_PROXY_ICON_SIZE_DEFAULT),
+ size: snapIconImageSize(size),
animated: shouldAnimate,
});
}
+export function getGuildRailIconURL(guild: IconOptions, animated = false) {
+ return getGuildIconURL(guild, animated, GUILD_RAIL_ICON_CSS_SIZE * getAppRemScale());
+}
+
export function getRoleIconURL({id, icon}: {id: string; icon: string | null}, cssSize: number): string {
if (!icon) {
return '';
@@ -398,7 +407,7 @@ export function getGuildMemberAvatarURL({
avatar: string | null;
memberAvatar?: string | null;
animated?: boolean;
- size?: MediaProxyImageSize;
+ size?: number;
}) {
if (memberAvatar) {
const {hash, animated: shouldAnimate} = parseMediaHashForRequest(memberAvatar, animated);
@@ -437,7 +446,7 @@ export function getGuildMemberDisplayAvatarURL({
memberAvatar?: string | null;
avatarUnset?: boolean;
animated?: boolean;
- size?: MediaProxyImageSize;
+ size?: number;
}) {
if (avatarUnset) {
return getUserAvatarURL({id: user.id, avatar: null}, animated, size);
diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.module.css b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.module.css
index 8d48f9658..56666b36e 100644
--- a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.module.css
+++ b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.module.css
@@ -41,20 +41,12 @@
transform-origin: center;
}
-.wrapAvatarSlotAnimated {
- will-change: width, flex-basis;
-}
-
.wrapAvatar {
width: var(--voice-participant-avatar-size);
height: var(--voice-participant-avatar-size);
flex: 0 0 var(--voice-participant-avatar-size);
}
-.wrapAvatarAnimated {
- will-change: opacity, transform;
-}
-
.remainingCount {
display: flex;
align-items: center;
diff --git a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
index b9173d1e6..43aa3d9c3 100644
--- a/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
+++ b/fluxer_app/src/features/voice/components/VoiceParticipantAvatarList.tsx
@@ -596,7 +596,7 @@ export const VoiceParticipantWrappedAvatarList: React.FC<VoiceParticipantWrapped
return (
<motion.div
key={shouldAnimateAvatarChanges ? `${slot.key}:motion` : `${slot.key}:static`}
- className={clsx(styles.wrapAvatarSlot, shouldAnimateAvatarChanges && styles.wrapAvatarSlotAnimated)}
+ className={styles.wrapAvatarSlot}
onContextMenu={(event) => handleContextMenu(event, slot.entry)}
initial={shouldAnimateAvatarChanges && isEntering ? {width: 0, flexBasis: 0} : false}
animate={
@@ -609,7 +609,7 @@ export const VoiceParticipantWrappedAvatarList: React.FC<VoiceParticipantWrapped
data-flx="voice.voice-participant-avatar-list.voice-participant-wrapped-avatar-list.wrap-avatar-slot"
>
<motion.div
- className={clsx(styles.wrapAvatar, shouldAnimateAvatarChanges && styles.wrapAvatarAnimated)}
+ className={styles.wrapAvatar}
initial={shouldAnimateAvatarChanges && isEntering ? {opacity: 0, scale: 0.92} : false}
animate={
shouldAnimateAvatarChanges ? {opacity: isCollapsed ? 0 : 1, scale: isCollapsed ? 0.9 : 1} : undefined
diff --git a/fluxer_desktop/src/common/Constants.ts b/fluxer_desktop/src/common/Constants.ts
index c36edf46d..28be2980d 100644
--- a/fluxer_desktop/src/common/Constants.ts
+++ b/fluxer_desktop/src/common/Constants.ts
@@ -36,6 +36,7 @@ export const DESKTOP_APP_ORIGIN = DESKTOP_LOCAL_APP_ORIGIN;
export const DESKTOP_APP_URL = DESKTOP_LOCAL_APP_URL;
export const DESKTOP_APP_LANDING_URL = `${DESKTOP_LOCAL_APP_URL}channels/@me`;
export const DESKTOP_PREBOOT_THEME_CHANNEL = 'desktop-preboot-theme:report';
+export const RELEASE_RENDERER_MEMORY_CHANNEL = 'desktop-renderer-memory:release';
export const DESKTOP_FIRST_CONTENT_PAINTED_CHANNEL = 'desktop-window:first-content-painted';
export const STATIC_CDN_URL = 'https://fluxerstatic.com';
export const DEFAULT_WINDOW_WIDTH = 1280;
diff --git a/fluxer_desktop/src/main/Bootstrap.ts b/fluxer_desktop/src/main/Bootstrap.ts
index d6048a126..2e624d15d 100644
--- a/fluxer_desktop/src/main/Bootstrap.ts
+++ b/fluxer_desktop/src/main/Bootstrap.ts
@@ -188,6 +188,7 @@ async function runModuleBootstrap(): Promise<void> {
const {buildSplashDiagnosticsText} = await import('@electron/main/SplashDiagnostics');
const {
closeSplashWindow,
+ discardPreloadedSplashWindow,
focusSplashWindow,
markSplashLaunching,
onSplashCopyDiagnostics,
@@ -637,16 +638,28 @@ async function runModuleBootstrap(): Promise<void> {
let takeoverSplash: BrowserWindow | null = null;
let takeoverHidden: ReadonlyArray<BrowserWindow> = [];
let takeoverActive = false;
- const preloadUpdateSplash = (): void => {
+ let launchSettled = false;
+ let shellUpdatePending = false;
+ const syncUpdateSplashPreload = (): void => {
+ if (takeoverActive) return;
+ if (!shellUpdatePending) {
+ discardPreloadedSplashWindow();
+ return;
+ }
+ if (!launchSettled) return;
const timer = setTimeout(() => {
- if (takeoverActive) return;
+ if (takeoverActive || !shellUpdatePending) return;
void import('@electron/main/Window').then((windows) => {
takeoverWindows = windows;
- if (!takeoverActive) preloadSplashWindow();
+ if (!takeoverActive && shellUpdatePending) preloadSplashWindow();
});
}, UPDATE_SPLASH_PRELOAD_DELAY_MS);
timer.unref();
};
+ const trackShellUpdate = (check: {readonly shellNewer: boolean}): void => {
+ shellUpdatePending = check.shellNewer;
+ syncUpdateSplashPreload();
+ };
const updateTakeover: DesktopUpdateTakeover = {
begin: async () => {
takeoverActive = true;
@@ -687,7 +700,7 @@ async function runModuleBootstrap(): Promise<void> {
takeoverHidden = [];
closeSplashWindow();
takeoverActive = false;
- preloadUpdateSplash();
+ syncUpdateSplashPreload();
},
closeApp: async () => {
if (takeoverSplash != null) {
@@ -699,7 +712,7 @@ async function runModuleBootstrap(): Promise<void> {
takeoverWindows?.endMainWindowTakeover();
takeoverActive = false;
reopenMainWindow(launchAttempt);
- preloadUpdateSplash();
+ syncUpdateSplashPreload();
},
reloadInPlace: async (launchAttempt) => {
const windows = takeoverWindows ?? (await import('@electron/main/Window'));
@@ -762,6 +775,7 @@ async function runModuleBootstrap(): Promise<void> {
takeover: updateTakeover,
publish: (check) => {
recordPendingUpdate(check);
+ trackShellUpdate(check);
publishDesktopUpdateCheck(check);
},
reportFailure: (failure) => {
@@ -800,6 +814,7 @@ async function runModuleBootstrap(): Promise<void> {
check: async (manual) => {
const check = await desktopUpdate.check({manual});
recordPendingUpdate(check);
+ trackShellUpdate(check);
return check;
},
start: () => desktopUpdate.start(),
@@ -810,7 +825,8 @@ async function runModuleBootstrap(): Promise<void> {
return;
}
desktopUpdate.markLaunchSettled();
- preloadUpdateSplash();
+ launchSettled = true;
+ syncUpdateSplashPreload();
armDesktopUpdatePoll(
{
plan: resolveModulePollPlan(readDevModulePollInterval()),
diff --git a/fluxer_desktop/src/main/HiddenWindowMemory.ts b/fluxer_desktop/src/main/HiddenWindowMemory.ts
new file mode 100644
index 000000000..c3fc6473e
--- /dev/null
+++ b/fluxer_desktop/src/main/HiddenWindowMemory.ts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+import {RELEASE_RENDERER_MEMORY_CHANNEL} from '@electron/common/Constants';
+import type {BrowserWindow} from 'electron';
+
+const HIDDEN_MEMORY_RELEASE_DELAY_MS = 30_000;
+
+function isOutOfSight(window: BrowserWindow): boolean {
+ return !window.isVisible() || window.isMinimized();
+}
+
+export function armHiddenWindowMemoryRelease(window: BrowserWindow): void {
+ let timer: NodeJS.Timeout | null = null;
+ const cancel = (): void => {
+ if (timer == null) return;
+ clearTimeout(timer);
+ timer = null;
+ };
+ const schedule = (): void => {
+ cancel();
+ timer = setTimeout(() => {
+ timer = null;
+ if (window.isDestroyed() || window.webContents.isDestroyed() || !isOutOfSight(window)) return;
+ window.webContents.send(RELEASE_RENDERER_MEMORY_CHANNEL);
+ }, HIDDEN_MEMORY_RELEASE_DELAY_MS);
+ timer.unref();
+ };
+ window.on('hide', schedule);
+ window.on('minimize', schedule);
+ window.on('show', cancel);
+ window.on('restore', cancel);
+ window.on('closed', cancel);
+}
diff --git a/fluxer_desktop/src/main/SplashWindow.ts b/fluxer_desktop/src/main/SplashWindow.ts
index 3c80466f3..9adfa096c 100644
--- a/fluxer_desktop/src/main/SplashWindow.ts
+++ b/fluxer_desktop/src/main/SplashWindow.ts
@@ -267,6 +267,11 @@ export function preloadSplashWindow(): void {
createSplashWindow(true, true);
}
+export function discardPreloadedSplashWindow(): void {
+ if (!splashHeldHidden) return;
+ closeSplashWindow();
+}
+
export function revealPreloadedSplashWindow(): BrowserWindow | null {
const window = splashWindow;
if (!splashHeldHidden || !splashDocumentReady || window == null || window.isDestroyed()) return null;
diff --git a/fluxer_desktop/src/main/Window.ts b/fluxer_desktop/src/main/Window.ts
index 08135953b..6525f7c35 100644
--- a/fluxer_desktop/src/main/Window.ts
+++ b/fluxer_desktop/src/main/Window.ts
@@ -26,6 +26,7 @@ import {hasActiveDesktopTray, refreshDesktopTrayMenu} from '@electron/main/Deskt
import {wakeDesktopUpdatePoll} from '@electron/main/DesktopUpdatePoll';
import {drainPendingDisplayMediaRequests, registerDisplayMediaRequestHandler} from '@electron/main/DisplayMedia';
import {isNativeGatewayAvailable} from '@electron/main/GatewaySocketNativeBoundary';
+import {armHiddenWindowMemoryRelease} from '@electron/main/HiddenWindowMemory';
import {shouldDisableV8CodeCache} from '@electron/main/LaunchOptions';
import {getDesktopLocalAppAuthorization} from '@electron/main/LocalAppProtocolAuthorization';
import {isLocalAppRendererDocumentURL, isLocalAppURL} from '@electron/main/LocalAppURL';
@@ -736,6 +737,7 @@ export function createWindow(options: CreateWindowOptions = {}): BrowserWindow {
windowOptions.center = true;
}
mainWindow = new BrowserWindow(windowOptions);
+ armHiddenWindowMemoryRelease(mainWindow);
signalMainWindowCreated(mainWindow);
mainWindowRendererGone = false;
installHtmlFullscreenChromeGuard(mainWindow);
diff --git a/fluxer_desktop/src/preload/index.ts b/fluxer_desktop/src/preload/index.ts
index b0667933f..bd53dc41d 100644
--- a/fluxer_desktop/src/preload/index.ts
+++ b/fluxer_desktop/src/preload/index.ts
@@ -2,7 +2,11 @@ import {isRecord} from '@fluxer/record_utils/src/RecordGuards';
// SPDX-License-Identifier: AGPL-3.0-or-later
import {BUILD_CHANNEL} from '@electron/common/BuildChannel';
-import {DESKTOP_PREBOOT_THEME_CHANNEL, LOCAL_DEVELOPMENT_INSTANCE_URL} from '@electron/common/Constants';
+import {
+ DESKTOP_PREBOOT_THEME_CHANNEL,
+ LOCAL_DEVELOPMENT_INSTANCE_URL,
+ RELEASE_RENDERER_MEMORY_CHANNEL,
+} from '@electron/common/Constants';
import {IS_OFFLINE_BUILD} from '@electron/common/OfflineBuild';
import {readExactPlainRecord} from '@electron/common/PlainRecord';
import type {
@@ -939,4 +943,8 @@ ipcRenderer.on('spellcheck-engine-resolved', (_event, info: SpellcheckResolvedEn
}
});
+ipcRenderer.on(RELEASE_RENDERER_MEMORY_CHANNEL, () => {
+ webFrame.clearCache();
+});
+
contextBridge.exposeInMainWorld('electron', api);