Skip to content

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

TypeScript fluxerfluxerapp

feat(app): add community visits and drop the claim account popup

Hampus41ad190d1052
diff --git a/fluxer_app/src/features/app/components/layout/GuildLayout.tsx b/fluxer_app/src/features/app/components/layout/GuildLayout.tsx
index ee16a4899..d86d46339 100644
--- a/fluxer_app/src/features/app/components/layout/GuildLayout.tsx
+++ b/fluxer_app/src/features/app/components/layout/GuildLayout.tsx
@@ -14,6 +14,7 @@ import Accounts from '@app/features/auth/state/Accounts';
import {MatureContentChannelGate} from '@app/features/channel/components/MatureContentChannelGate';
import Channels from '@app/features/channel/state/Channels';
import * as GuildCommands from '@app/features/guild/commands/GuildCommands';
+import {GuildPreviewNagbar} from '@app/features/guild/components/visits/GuildPreviewNagbar';
import GuildAvailability from '@app/features/guild/state/GuildAvailability';
import GuildMatureContentAgree, {MatureContentGateReason} from '@app/features/guild/state/GuildMatureContentAgree';
import Guilds from '@app/features/guild/state/Guilds';
@@ -422,7 +423,8 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
const showGuildLevelGate = guildLevelGateReason !== MatureContentGateReason.NONE;
const topNagbarCount = useContext(TopNagbarContext);
const maxVisibleNagbars = 2;
- const availableGuildNagbarSlots = Math.max(0, maxVisibleNagbars - topNagbarCount);
+ const showGuildPreviewNagbar = guild?.visiting === true;
+ const availableGuildNagbarSlots = Math.max(0, maxVisibleNagbars - topNagbarCount - (showGuildPreviewNagbar ? 1 : 0));
const showStaffOnlyGuildNagbar = shouldShowStaffOnlyGuild && availableGuildNagbarSlots > 0;
const showGuildMfaRequirementNagbar =
shouldShowGuildMfaRequirement && availableGuildNagbarSlots > (showStaffOnlyGuildNagbar ? 1 : 0);
@@ -430,7 +432,10 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
shouldShowInvitesDisabled &&
availableGuildNagbarSlots > (showStaffOnlyGuildNagbar ? 1 : 0) + (showGuildMfaRequirementNagbar ? 1 : 0);
const guildNagbarCount =
- (showStaffOnlyGuildNagbar ? 1 : 0) + (showGuildMfaRequirementNagbar ? 1 : 0) + (showInvitesDisabledNagbar ? 1 : 0);
+ (showGuildPreviewNagbar ? 1 : 0) +
+ (showStaffOnlyGuildNagbar ? 1 : 0) +
+ (showGuildMfaRequirementNagbar ? 1 : 0) +
+ (showInvitesDisabledNagbar ? 1 : 0);
const hasGuildNagbars = guildNagbarCount > 0;
const nagbarCount = topNagbarCount + guildNagbarCount;
const prevNagbarCount = useRef<number>(nagbarCount);
@@ -454,6 +459,13 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
}, [viewLive, guild, guildId, channelId, firstAccessibleTextChannel, guildUnavailable]);
const guildNagbars = (
<>
+ {showGuildPreviewNagbar && guild && (
+ <GuildPreviewNagbar
+ guild={guild}
+ isMobile={mobileLayout.enabled}
+ data-flx="app.guild-layout.guild-preview-nagbar"
+ />
+ )}
{showStaffOnlyGuildNagbar && guildId && (
<StaffOnlyGuildNagbar
isMobile={mobileLayout.enabled}
@@ -563,6 +575,13 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
className={channelId ? styles.mobileNavbarHidden : styles.mobileNavbarSlot}
data-flx="app.guild-layout.mobile-navbar"
>
+ {!channelId && showGuildPreviewNagbar && (
+ <GuildPreviewNagbar
+ guild={guild}
+ isMobile={true}
+ data-flx="app.guild-layout.mobile-navbar.guild-preview-nagbar"
+ />
+ )}
<GuildNavbar guild={guild} data-flx="app.guild-layout.guild-navbar" />
</div>
)}
@@ -612,7 +631,6 @@ export const GuildLayout = observer(({children}: {children: React.ReactNode}) =>
>
{guildNagbars}
<div className={styles.guildLayoutContent} data-flx="app.guild-layout.guild-layout-content--3">
- <GuildSidebarSkeleton guildId={guildId} data-flx="app.guild-layout.guild-sidebar-skeleton--3" />
<div className={styles.guildMainContent} data-flx="app.guild-layout.guild-main-content--5">
<GuildUnavailable
icon={SmileySadIcon}
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 ccb49d76c..569f7f76c 100644
--- a/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css
+++ b/fluxer_app/src/features/app/components/layout/GuildsLayout.module.css
@@ -148,7 +148,7 @@
.userAreaWrapper {
position: absolute;
bottom: 0;
- left: 0;
+ inset-inline-start: 0;
width: calc(var(--layout-guild-list-width) + var(--layout-sidebar-width) + 0.0625rem);
display: flex;
align-items: flex-end;
@@ -237,7 +237,7 @@
.guildIndicator {
position: absolute;
- left: var(--guild-list-indicator-inset);
+ inset-inline-start: var(--guild-list-indicator-inset);
display: flex;
align-items: center;
justify-content: center;
@@ -257,7 +257,7 @@
.guildBadge {
position: absolute;
- right: -0.25rem;
+ inset-inline-end: -0.25rem;
bottom: -0.25rem;
pointer-events: none;
border-radius: var(--radius-md);
@@ -271,7 +271,7 @@
.guildVoiceBadge {
position: absolute;
- right: -0.25rem;
+ inset-inline-end: -0.25rem;
top: -0.25rem;
pointer-events: none;
z-index: 2;
@@ -294,7 +294,7 @@
.guildErrorBadge {
position: absolute;
top: 0;
- right: 0;
+ inset-inline-end: 0;
pointer-events: none;
}
@@ -587,7 +587,7 @@
}
.guildTooltipStatDot {
- margin-right: 0.3rem;
+ margin-inline-end: 0.3rem;
height: 0.5rem;
width: 0.5rem;
border-radius: 624.9375rem;
@@ -619,7 +619,7 @@
align-items: center;
gap: 0.375rem;
min-height: 1.875rem;
- padding-right: 0.25rem;
+ padding-inline-end: 0.25rem;
}
.guildVoiceIcon {
@@ -647,7 +647,7 @@
.guildInvitesPausedBadge {
position: absolute;
- right: calc(-0.25rem - 0.1875rem);
+ inset-inline-end: calc(-0.25rem - 0.1875rem);
bottom: calc(-0.25rem - 0.1875rem);
pointer-events: none;
background-color: var(--guild-badge-surface);
@@ -747,17 +747,23 @@
background-color: transparent;
}
+.guildListDropZoneSlot {
+ position: relative;
+ display: block;
+ height: 0;
+}
+
.guildListDropZone {
position: absolute;
- left: 0;
- right: 0;
+ inset-inline-start: 0;
+ inset-inline-end: 0;
height: 1.5rem;
z-index: 10;
pointer-events: none;
}
.guildListDropZoneBottom {
- bottom: 0;
+ top: calc(-1 * var(--guild-list-item-gap));
}
.guildListDropZoneEnabled {
@@ -776,7 +782,7 @@
}
.guildListDropZoneBottom.guildListDropZoneActive::after {
- bottom: 0;
+ top: calc(var(--guild-list-item-gap) / 2 - 0.0625rem);
}
:global(.theme-light) .dropIndicatorTop::before,
diff --git a/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx b/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
index 09ba176a6..1df530551 100644
--- a/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
+++ b/fluxer_app/src/features/app/components/layout/GuildsLayout.tsx
@@ -73,11 +73,10 @@ import {
useNavigationList,
} from '@app/features/app/hooks/useNavigationList';
import {useRovingFocusList} from '@app/features/app/hooks/useRovingFocusList';
-import Initialization from '@app/features/app/state/Initialization';
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
-import {openClaimAccountModal} from '@app/features/auth/components/modals/ClaimAccountModal';
import type {Channel} from '@app/features/channel/models/Channel';
import Channels from '@app/features/channel/state/Channels';
+import type {Guild} from '@app/features/guild/models/Guild';
import GuildAvailability from '@app/features/guild/state/GuildAvailability';
import GuildFolderExpanded from '@app/features/guild/state/GuildFolderExpanded';
import GuildListState, {type OrganizedItem} from '@app/features/guild/state/GuildList';
@@ -99,7 +98,6 @@ import {RelativePosition} from '@app/features/ui/RelativePosition';
import Dimension from '@app/features/ui/state/Dimension';
import KeyboardMode from '@app/features/ui/state/KeyboardMode';
import MobileLayout from '@app/features/ui/state/MobileLayout';
-import Nagbar from '@app/features/ui/state/Nagbar';
import SidebarPreferences from '@app/features/ui/state/SidebarPreferences';
import SidebarWidth from '@app/features/ui/state/SidebarWidth';
import {Tooltip} from '@app/features/ui/tooltip/Tooltip';
@@ -118,7 +116,6 @@ import {
GuildFolderFlags,
UNCATEGORIZED_FOLDER_ID,
} from '@fluxer/constants/src/UserConstants';
-import * as SnowflakeUtils from '@fluxer/snowflake/src/SnowflakeUtils';
import {msg, plural} from '@lingui/core/macro';
import {useLingui} from '@lingui/react/macro';
import {ExclamationMarkIcon} from '@phosphor-icons/react';
@@ -145,7 +142,6 @@ const DOM_DELTA_PAGE = 2;
const getChannelId = (channel: Channel): string => channel.id;
const EMPTY_CHANNELS: ReadonlyArray<Channel> = Object.freeze([]);
const ESTIMATED_GUILD_ROW_HEIGHT = 54;
-const GUILD_BOTTOM_DROP_ZONE_HEIGHT = 24;
const GUILD_LIST_SCROLLER_IDENTITY = 'guild-list-scroller';
const GUILD_LIST_SCROLL_PERSIST_IDLE_MS = 150;
const GUILD_ROW_STYLE: React.CSSProperties = Object.freeze({width: '100%', paddingBottom: 0});
@@ -167,12 +163,6 @@ function resolveGuildsLayoutSidebarStyle(
return style;
}
-function getResizeObserverEntryBlockSize(entry: ResizeObserverEntry): number {
- const borderBoxSize = entry.borderBoxSize;
- const firstBorderBoxSize = Array.isArray(borderBoxSize) ? borderBoxSize[0] : borderBoxSize;
- return firstBorderBoxSize?.blockSize ?? entry.contentRect.height;
-}
-
function resolveGuildFolderId(folderId: number | null): number {
if (folderId != null) return folderId;
return UNCATEGORIZED_FOLDER_ID;
@@ -191,13 +181,14 @@ type GuildNavigationRow =
| (NavigationRow & {readonly kind: 'outage'})
| (NavigationRow & {readonly kind: 'organized-item'; readonly item: OrganizedItem})
| (NavigationRow & {readonly kind: 'bottom-drop-zone'})
+ | (NavigationRow & {readonly kind: 'visiting-divider'})
+ | (NavigationRow & {readonly kind: 'visiting-guild'; readonly guild: Guild})
| (NavigationRow & {readonly kind: 'discovery'})
| (NavigationRow & {readonly kind: 'add-guild'})
| (NavigationRow & {readonly kind: 'download'})
| (NavigationRow & {readonly kind: 'help'});
interface GuildNavigationVisibility {
- readonly fluxerVisible: boolean;
readonly favoritesVisible: boolean;
readonly discoveryVisible: boolean;
readonly addGuildVisible: boolean;
@@ -208,21 +199,19 @@ interface GuildNavigationVisibility {
function useGuildNavigationVisibility(): GuildNavigationVisibility {
const communityActionsVisible = !RuntimeConfig.singleCommunityEnabled;
const discoveryVisible = RuntimeConfig.discoveryAvailable;
- const fluxerVisible = !RuntimeConfig.directMessagesDisabled;
const favoritesVisible = Accessibility.showFavorites;
const downloadVisible = !Platform.isElectron && !Platform.isPWA && !HiddenGuildListButtons.downloadButtonHidden;
const helpVisible = !HiddenGuildListButtons.helpButtonHidden && Routes.help() != null;
return useMemo(
() =>
Object.freeze({
- fluxerVisible,
favoritesVisible,
discoveryVisible,
addGuildVisible: communityActionsVisible,
downloadVisible,
helpVisible,
}),
- [communityActionsVisible, discoveryVisible, downloadVisible, favoritesVisible, fluxerVisible, helpVisible],
+ [communityActionsVisible, discoveryVisible, downloadVisible, favoritesVisible, helpVisible],
);
}
@@ -233,6 +222,7 @@ interface CreateGuildNavigationRowsRequest {
readonly shouldRenderGuildListItems: boolean;
readonly visibleDMListRows: ReadonlyArray<DMListRow>;
readonly visibility: GuildNavigationVisibility;
+ readonly visitingGuilds: ReadonlyArray<Guild>;
}
interface ResolveSelectedGuildNavigationKeyRequest {
@@ -249,16 +239,16 @@ function createGuildNavigationRows({
shouldRenderGuildListItems,
visibleDMListRows,
visibility,
+ visitingGuilds,
}: CreateGuildNavigationRowsRequest): Array<GuildNavigationRow> {
- const rows: Array<GuildNavigationRow> = [];
- if (visibility.fluxerVisible) {
- rows.push({
+ const rows: Array<GuildNavigationRow> = [
+ {
kind: 'fluxer',
key: 'fluxer',
focusable: true,
focusTargetIdentity: 'fluxer',
- });
- }
+ },
+ ];
if (visibility.favoritesVisible) {
rows.push({
kind: 'favorites',
@@ -311,6 +301,23 @@ function createGuildNavigationRows({
});
}
}
+ if (visitingGuilds.length > 0) {
+ rows.push({
+ kind: 'visiting-divider',
+ key: 'visiting-divider',
+ focusable: false,
+ focusTargetIdentity: 'visiting-divider',
+ });
+ for (const guild of visitingGuilds) {
+ rows.push({
+ kind: 'visiting-guild',
+ key: `visiting:${guild.id}`,
+ focusable: true,
+ focusTargetIdentity: guild,
+ guild,
+ });
+ }
+ }
if (visibility.discoveryVisible) {
rows.push({
kind: 'discovery',
@@ -363,6 +370,8 @@ function hasGapAfterGuildNavigationRow(row: GuildNavigationRow, nextRow: GuildNa
return true;
}
return nextRow.kind !== 'organized-item';
+ case 'visiting-guild':
+ return nextRow == null || nextRow.kind !== 'visiting-guild';
default:
return false;
}
@@ -394,7 +403,7 @@ function resolveSelectedGuildNavigationKey({
}
if (visibility.favoritesVisible && pathname === Routes.FAVORITES) return 'favorites';
if (visibility.discoveryVisible && Routes.isDiscoverRoute(pathname)) return 'discovery';
- if (visibility.fluxerVisible && pathname === Routes.ME) return 'fluxer';
+ if (pathname === Routes.ME) return 'fluxer';
return null;
}
@@ -1266,8 +1275,9 @@ const SKELETON_NAGBAR_ROW_SHAPES: Record<NagbarType, SkeletonNagbarRowShape> = {
[NagbarType.CONNECTION]: {tone: SkeletonNagbarTone.NEUTRAL, hasActions: false},
[NagbarType.CORRUPTED_INSTALLATION]: {tone: SkeletonNagbarTone.CRITICAL, hasActions: true},
[NagbarType.SCHEDULED_MAINTENANCE]: {tone: SkeletonNagbarTone.MAINTENANCE_SCHEDULED, hasActions: true},
- [NagbarType.UNCLAIMED_ACCOUNT]: {tone: SkeletonNagbarTone.ALERT, hasActions: true},
- [NagbarType.EMAIL_VERIFICATION]: {tone: SkeletonNagbarTone.ALERT, hasActions: true},
+ [NagbarType.INSTANCE_NOTICE]: {tone: SkeletonNagbarTone.MAINTENANCE, hasActions: true},
+ [NagbarType.UNCLAIMED_ACCOUNT]: {tone: SkeletonNagbarTone.NEUTRAL, hasActions: true},
+ [NagbarType.EMAIL_VERIFICATION]: {tone: SkeletonNagbarTone.NEUTRAL, hasActions: true},
[NagbarType.ACCOUNT_LIMITED]: {tone: SkeletonNagbarTone.NEUTRAL, hasActions: false},
[NagbarType.DESKTOP_NOTIFICATION]: {tone: SkeletonNagbarTone.BRAND, hasActions: true},
[NagbarType.PREMIUM_GRACE_PERIOD]: {tone: SkeletonNagbarTone.PREMIUM, hasActions: true},
@@ -1486,7 +1496,7 @@ function createGuildRailSkeletonLayout({
isSelectedPath(pathname, Routes.dmChannel(channelId)),
),
outageVisible: hasUnavailableGuilds,
- fluxerVisible: visibility.fluxerVisible,
+ fluxerVisible: true,
favoritesVisible: visibility.favoritesVisible,
discoveryVisible: visibility.discoveryVisible,
addGuildVisible: visibility.addGuildVisible,
@@ -1503,6 +1513,7 @@ const GuildList = observer(() => {
const isDragging = activeDragItem != null;
const guildNavigationVisibility = useGuildNavigationVisibility();
const organizedItems = GuildListState.getOrganizedGuildList();
+ const visitingGuilds = GuildListState.visitingGuilds;
const guildNavigationIndexes = useMemo(() => buildGuildNavigationIndexMap(organizedItems), [organizedItems]);
const unavailableCount = GuildAvailability.totalUnavailableGuilds;
const privateReadStateVersion = ReadStates.privateChannelVersion;
@@ -1718,6 +1729,7 @@ const GuildList = observer(() => {
shouldRenderGuildListItems,
visibleDMListRows,
visibility: guildNavigationVisibility,
+ visitingGuilds,
}),
[
hasUnavailableGuilds,
@@ -1726,6 +1738,7 @@ const GuildList = observer(() => {
shouldRenderGuildListItems,
visibleDMListRows,
guildNavigationVisibility,
+ visitingGuilds,
],
);
const selectedGuildNavigationKey = useMemo(
@@ -2029,7 +2042,7 @@ const GuildList = observer(() => {
case 'bottom-drop-zone':
return (
<flx-app-guild-list-drop-zone
- style={{position: 'relative', display: 'block', height: GUILD_BOTTOM_DROP_ZONE_HEIGHT}}
+ className={flxElementClassName(styles.guildListDropZoneSlot)}
data-flx="app.guilds-layout.render-guild-navigation-row.flx-app-guild-list-drop-zone"
>
<BottomDropZone
@@ -2041,6 +2054,35 @@ const GuildList = observer(() => {
/>
</flx-app-guild-list-drop-zone>
);
+ case 'visiting-divider':
+ return (
+ <GuildListDivider
+ nextRowExtended={true}
+ data-flx="app.guilds-layout.render-guild-navigation-row.visiting-divider"
+ />
+ );
+ case 'visiting-guild':
+ return (
+ <flx-app-guild-list-item-slot
+ className={flxElementClassName(styles.guildListItemSlot)}
+ data-flx="app.guilds-layout.render-guild-navigation-row.visiting-guild-slot"
+ >
+ <GuildListItem
+ isSortingList={false}
+ guild={row.guild}
+ isSelected={isSelectedPath(location.pathname, Routes.guildChannel(row.guild.id))}
+ guildIndex={null}
+ selectedGuildIndex={selectedGuildIndex}
+ onGuildDrop={null}
+ onDragStateChange={null}
+ disableDrag={true}
+ insideFolderId={null}
+ isLastInsideFolder={false}
+ scrollTargetRef={scrollTargetRegistry.register(`guild-${row.guild.id}`)}
+ data-flx="app.guilds-layout.render-guild-navigation-row.visiting-guild"
+ />
+ </flx-app-guild-list-item-slot>
+ );
case 'discovery':
return <DiscoveryButton data-flx="app.guilds-layout.render-guild-navigation-row.discovery-button" />;
case 'add-guild':
@@ -2161,7 +2203,6 @@ export const GuildsLayout = observer(({children}: {children: React.ReactNode}) =
[skeletonNagbarRows],
);
const prevNagbarCount = useRef(activeNagbars.length);
- const isReady = Initialization.isReady;
useEffect(() => {
if (prevNagbarCount.current !== activeNagbars.length) {
prevNagbarCount.current = activeNagbars.length;
@@ -2213,17 +2254,6 @@ export const GuildsLayout = observer(({children}: {children: React.ReactNode}) =
clearOverlayHeight();
};
}, [shouldReserveUserAreaSpace]);
- const THIRTY_MINUTES_MS = 30 * 60 * 1000;
- useEffect(() => {
- if (!isReady) return;
- if (!user) return;
- if (Nagbar.claimAccountModalShownThisSession) return;
- if (user.isClaimed()) return;
- const accountAgeMs = SnowflakeUtils.age(user.id);
- if (accountAgeMs < THIRTY_MINUTES_MS) return;
- Nagbar.markClaimAccountModalShown();
- openClaimAccountModal();
- }, [isReady, user, location.pathname]);
useEffect(() => {
preloadMacPermissionsModal();
}, []);
diff --git a/fluxer_app/src/features/gateway/types/GatewayGuildTypes.ts b/fluxer_app/src/features/gateway/types/GatewayGuildTypes.ts
index b50df68d4..9a38fa83f 100644
--- a/fluxer_app/src/features/gateway/types/GatewayGuildTypes.ts
+++ b/fluxer_app/src/features/gateway/types/GatewayGuildTypes.ts
@@ -22,8 +22,9 @@ export type GuildReadyData = Readonly<{
presences?: ReadonlyArray<PresenceRecord>;
voice_states?: ReadonlyArray<VoiceState>;
roles: ReadonlyArray<GuildRole>;
- joined_at: string;
+ joined_at: string | null;
unavailable?: boolean;
+ visiting?: boolean;
unavailable_hidden?: boolean;
degraded?: boolean;
}>;
diff --git a/fluxer_app/src/features/platform/transport/RestTransport.ts b/fluxer_app/src/features/platform/transport/RestTransport.ts
index c8ff2490a..733e8d318 100644
--- a/fluxer_app/src/features/platform/transport/RestTransport.ts
+++ b/fluxer_app/src/features/platform/transport/RestTransport.ts
@@ -26,6 +26,8 @@ import {Logger} from '@app/features/platform/utils/AppLogger';
import {getElectronAPI} from '@app/features/ui/utils/NativeUtils';
import {APIErrorCodes} from '@fluxer/constants/src/ApiErrorCodes';
import {Headers} from '@fluxer/constants/src/Headers';
+import {HttpStatus} from '@fluxer/constants/src/HttpConstants';
+import {MS_PER_SECOND} from '@fluxer/date_utils/src/DateConstants';
import type {DesktopLocalAppUploadProgress} from '@fluxer/desktop_ipc/src/LocalAppRouteContract';
import {
DESKTOP_LOCAL_APP_HOST,
@@ -90,7 +92,7 @@ interface RestRuntimeRouting {
readonly apiVersion: number;
}
-export class RestRuntimeUnavailableError extends Error {
+class RestRuntimeUnavailableError extends Error {
constructor() {
super('A relative REST request requires an active instance runtime');
this.name = 'RestRuntimeUnavailableError';
@@ -377,20 +379,25 @@ async function runWithSudoEscalation<T>(
}
function isSudoRequiredFailure(err: unknown): boolean {
- if (!(err instanceof HttpError) || err.status !== 403) return false;
+ if (!(err instanceof HttpError) || err.status !== HttpStatus.FORBIDDEN) return false;
const body = err.body;
- return typeof body === 'object' && body !== null && (body as Record<string, unknown>).code === 'SUDO_MODE_REQUIRED';
+ return isRecord(body) && body.code === APIErrorCodes.SUDO_MODE_REQUIRED;
}
function isSudoVerificationFailure(err: unknown): boolean {
- if (!(err instanceof HttpError) || err.status !== 400) return false;
+ if (!(err instanceof HttpError) || err.status !== HttpStatus.BAD_REQUEST) return false;
const body = err.body;
if (!isRecord(body) || body.code !== APIErrorCodes.INVALID_FORM_BODY) return false;
const errors = body.errors;
if (!Array.isArray(errors)) return false;
return errors.some((error) => {
if (!isRecord(error)) return false;
- const path = typeof error.path === 'string' ? error.path : typeof error.field === 'string' ? error.field : null;
+ let path: string | null = null;
+ if (typeof error.path === 'string') {
+ path = error.path;
+ } else if (typeof error.field === 'string') {
+ path = error.field;
+ }
return path !== null && SUDO_VERIFICATION_ERROR_FIELDS.has(path);
});
}
@@ -606,6 +613,7 @@ function assembleHeaders(input: AssembleHeadersInput): Record<string, string> {
const accumulator: Record<string, string> = {};
if (input.sameOrigin) {
accumulator[Headers.X_FLUXER_FEATURES] = 'view_channel_members_permission,channel_threads';
+ accumulator[Headers.X_FLUXER_CAPABILITIES] = 'guild_visits';
accumulator[Headers.X_FLUXER_CLIENT_INSTALLATION_ID] = ClientInstallationId.get();
}
const contentType = inferContentType(input.body);
@@ -656,13 +664,12 @@ function recordPacing(
note?: string,
code?: string,
): void {
- const fallbackMs = 1000;
- const ms =
- headerMs !== null && headerMs > 0
- ? headerMs
- : retryAfterSeconds !== null && retryAfterSeconds > 0
- ? retryAfterSeconds * 1000
- : fallbackMs;
+ let ms = MS_PER_SECOND;
+ if (headerMs !== null && headerMs > 0) {
+ ms = headerMs;
+ } else if (retryAfterSeconds !== null && retryAfterSeconds > 0) {
+ ms = retryAfterSeconds * MS_PER_SECOND;
+ }
pacing.set(key, {until: Date.now() + ms, note, code});
}
@@ -744,7 +751,12 @@ function performTransport(plan: Plan, handle: RestRequestHandle): Promise<Transp
const headers = parseHeaderBlock(xhr.getAllResponseHeaders());
const reply = decodeReply(xhr, plan.parse, headers);
const sudoToken = headers[SUDO_HEADER];
- const receivedSudoToken = sudoToken !== undefined ? sudoToken : plan.sudoApplied ? null : undefined;
+ let receivedSudoToken: string | null | undefined;
+ if (sudoToken !== undefined) {
+ receivedSudoToken = sudoToken;
+ } else if (plan.sudoApplied) {
+ receivedSudoToken = null;
+ }
resolve({status: 'reply', reply, receivedSudoToken});
};
xhr.open(plan.method, plan.url);
diff --git a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntry.ts b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntry.ts
index e25da0119..4786d5566 100644
--- a/fluxer_app/src/features/read_state/state/read_states/ReadStateEntry.ts
+++ b/fluxer_app/src/features/read_state/state/read_states/ReadStateEntry.ts
@@ -138,7 +138,10 @@ export class ReadStateEntry {
}
supportsUnreadTracking(): boolean {
- return Channels.getChannel(this.channelId) != null || this.storedGuildId != null;
+ const channel = Channels.getChannel(this.channelId);
+ const guildId = channel?.guildId ?? this.storedGuildId;
+ if (guildId != null && Guilds.getGuild(guildId)?.visiting === true) return false;
+ return channel != null || this.storedGuildId != null;
}
private get statusModel() {