1 Commits
Author SHA1 Message Date
litruv 1e3d630b1a Fix the ref, upload, keyframes, and implicit-any type errors. [skip build]
Checks / checks (push) Successful in 2m6s
Trigger cinny-mobile / dispatch (push) Successful in 1s
2026-11-02 00:51:31 +11:00
30 changed files with 134 additions and 98 deletions
+2 -2
View File
@@ -6,8 +6,8 @@ type ConfirmPasswordMatchProps = {
children: (
match: boolean,
doMatch: () => void,
passRef: RefObject<HTMLInputElement>,
confPassRef: RefObject<HTMLInputElement>,
passRef: RefObject<HTMLInputElement | null>,
confPassRef: RefObject<HTMLInputElement | null>,
) => ReactNode;
};
export function ConfirmPasswordMatch({ initialValue, children }: ConfirmPasswordMatchProps) {
+24 -26
View File
@@ -1,6 +1,6 @@
import React, { useEffect, useRef, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { style } from '@vanilla-extract/css';
import { keyframes, style } from '@vanilla-extract/css';
const transitionContainer = style({
position: 'relative',
@@ -14,36 +14,34 @@ const transitionContent = style({
height: '100%',
});
const routeFadeSlideIn = keyframes({
from: {
opacity: 0,
transform: 'translateX(12px)',
},
to: {
opacity: 1,
transform: 'translateX(0)',
},
});
const animateIn = style({
animation: 'routeFadeSlideIn 0.25s cubic-bezier(0.4, 0, 0.2, 1)',
'@keyframes': {
routeFadeSlideIn: {
from: {
opacity: 0,
transform: 'translateX(12px)',
},
to: {
opacity: 1,
transform: 'translateX(0)',
},
},
animation: `${routeFadeSlideIn} 0.25s cubic-bezier(0.4, 0, 0.2, 1)`,
});
const routeFadeSlideOut = keyframes({
from: {
opacity: 1,
transform: 'translateX(0)',
},
to: {
opacity: 0,
transform: 'translateX(-12px)',
},
});
const animateOut = style({
animation: 'routeFadeSlideOut 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards',
'@keyframes': {
routeFadeSlideOut: {
from: {
opacity: 1,
transform: 'translateX(0)',
},
to: {
opacity: 0,
transform: 'translateX(-12px)',
},
},
},
animation: `${routeFadeSlideOut} 0.2s cubic-bezier(0.4, 0, 0.2, 1) forwards`,
});
interface RouteTransitionProps {
@@ -192,7 +192,7 @@ const DEFAULT_CATEGORY_ID = makeNavCategoryId('direct', 'direct');
* Props for the DirectList component
*/
export type DirectListProps = {
scrollRef: React.RefObject<HTMLDivElement>;
scrollRef: React.RefObject<HTMLDivElement | null>;
showCreateButton?: boolean;
showCategoryHeader?: boolean;
};
@@ -296,7 +296,7 @@ function StickerSidebar({ activeGroupAtom, packs, onScrollToGroup }: StickerSide
}
type EmojiGroupHolderProps = {
contentScrollRef: RefObject<HTMLDivElement>;
contentScrollRef: RefObject<HTMLDivElement | null>;
previewAtom: PrimitiveAtom<PreviewData | undefined>;
children?: ReactNode;
onGroupItemClick: MouseEventHandler;
@@ -121,6 +121,7 @@ export const ImagePackContent = as<'div', ImagePackContentProps>(
url: data.mxc,
info: getImageInfo(imgEl, data.file),
};
if (!data.file.name) return;
const image = PackImageReader.fromPackImage(
getFileNameWithoutExt(data.file.name),
packImage,
@@ -10,8 +10,8 @@ import {
export const ScrollTopContainer = as<
'div',
{
scrollRef?: RefObject<HTMLElement>;
anchorRef: RefObject<HTMLElement>;
scrollRef?: RefObject<HTMLElement | null>;
anchorRef: RefObject<HTMLElement | null>;
onVisibilityChange?: (onTop: boolean) => void;
}
>(({ className, scrollRef, anchorRef, onVisibilityChange, ...props }, ref) => {
+17 -8
View File
@@ -1,5 +1,6 @@
import { style, keyframes } from '@vanilla-extract/css';
import { color, config } from 'folds';
import { AppRegionStyleRule } from '../../../types/utils';
const wipeIn = keyframes({
'0%': {
@@ -23,7 +24,7 @@ const wipeOut = keyframes({
},
});
export const NewMessagePill = style({
const newMessagePill: AppRegionStyleRule = {
display: 'flex',
alignItems: 'center',
gap: config.space.S100,
@@ -45,7 +46,9 @@ export const NewMessagePill = style({
backgroundColor: '#388E3C',
},
},
});
};
export const NewMessagePill = style(newMessagePill);
export const NewMessagePillExiting = style({
animation: `${wipeOut} 0.2s ease-in forwards`,
@@ -65,7 +68,7 @@ export const TitleBar = style({
WebkitUserSelect: 'none',
});
export const TitleBarDragRegion = style({
const titleBarDragRegion: AppRegionStyleRule = {
display: 'flex',
alignItems: 'center',
height: '100%',
@@ -74,14 +77,18 @@ export const TitleBarDragRegion = style({
cursor: 'default',
WebkitAppRegion: 'drag',
color: color.Surface.OnContainer,
});
};
export const TitleBarBackButton = style({
export const TitleBarDragRegion = style(titleBarDragRegion);
const titleBarBackButton: AppRegionStyleRule = {
WebkitAppRegion: 'no-drag',
flexShrink: 0,
});
};
export const SyncStatusBadge = style({
export const TitleBarBackButton = style(titleBarBackButton);
const syncStatusBadge: AppRegionStyleRule = {
position: 'absolute',
left: '50%',
top: '50%',
@@ -94,7 +101,9 @@ export const SyncStatusBadge = style({
zIndex: 1001,
pointerEvents: 'none',
WebkitAppRegion: 'no-drag',
});
};
export const SyncStatusBadge = style(syncStatusBadge);
export const SyncStatusSuccess = style({
backgroundColor: color.Success.Container,
+1 -1
View File
@@ -49,7 +49,7 @@ export function TitleBar({ mx, children }: TitleBarProps) {
const roomId = useAtomValue(activeRoomIdAtom);
const [notifications, setNotifications] = useState<NewMessageNotification[]>([]);
const dismissTimersRef = useRef<Map<string, ReturnType<typeof setTimeout>>>(new Map());
const lastMxRef = useRef<MatrixClient | undefined>();
const lastMxRef = useRef<MatrixClient | undefined>(undefined);
const navigate = useNavigate();
const roomToParents = useAtomValue(roomToParentsAtom);
const mDirects = useAtomValue(mDirectAtom);
@@ -1,19 +1,22 @@
import { keyframes, style } from '@vanilla-extract/css';
import { color, config, toRem } from 'folds';
import { AppRegionStyleRule } from '../../../types/utils';
const indeterminate = keyframes({
'0%': { transform: 'translateX(-100%)' },
'100%': { transform: 'translateX(250%)' },
});
export const IdleSlot = style({
const idleSlot: AppRegionStyleRule = {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
WebkitAppRegion: 'no-drag',
flexShrink: 0,
});
};
export const IdleSlot = style(idleSlot);
export const GhostCheck = style({
all: 'unset',
@@ -38,7 +41,7 @@ export const GhostCheck = style({
},
});
export const Bar = style({
const bar: AppRegionStyleRule = {
display: 'flex',
alignItems: 'center',
gap: config.space.S200,
@@ -52,7 +55,9 @@ export const Bar = style({
WebkitAppRegion: 'no-drag',
flexShrink: 0,
boxSizing: 'border-box',
});
};
export const Bar = style(bar);
export const BarTrack = style({
position: 'relative',
@@ -92,7 +97,7 @@ export const BarLabel = style({
textAlign: 'right',
});
export const Chip = style({
const chip: AppRegionStyleRule = {
height: toRem(22),
maxWidth: toRem(260),
padding: `0 ${config.space.S100} 0 ${config.space.S200}`,
@@ -102,7 +107,9 @@ export const Chip = style({
WebkitAppRegion: 'no-drag',
flexShrink: 0,
boxSizing: 'border-box',
});
};
export const Chip = style(chip);
export const ChipText = style({
maxWidth: toRem(140),
@@ -7,8 +7,8 @@ import { useMatrixClient } from '../../hooks/useMatrixClient';
import { useFilePicker } from '../../hooks/useFilePicker';
import { safeFile } from '../../utils/mimeTypes';
import { fulfilledPromiseSettledResult } from '../../utils/common';
import { TUploadContent } from '../../utils/matrix';
import {
TUploadContent,
TUploadItem,
TUploadMetadata,
roomIdToUploadItemsAtomFamily,
@@ -199,7 +199,7 @@ export function ForumPostUploadField({
export function useForumPostUploads(roomId: string) {
const mx = useMatrixClient();
const [selectedFiles, setSelectedFiles] = useAtom(roomIdToUploadItemsAtomFamily(roomId));
const uploadBoardHandlers = useRef<UploadBoardImperativeHandlers>();
const uploadBoardHandlers = useRef<UploadBoardImperativeHandlers | undefined>(undefined);
const uploadResolverRef = useRef<{
resolve: (contents: IContent[]) => void;
reject: (err: unknown) => void;
@@ -13,7 +13,7 @@ type ForumReplyComposerProps = {
roomId: string;
threadRootId: string;
replyToEventId: string;
fileDropContainerRef: RefObject<HTMLElement>;
fileDropContainerRef: RefObject<HTMLElement | null>;
onSent?: () => void;
onCancel?: () => void;
};
+2 -2
View File
@@ -124,7 +124,7 @@ type ForumThreadMessageProps = {
room: Room;
roomId: string;
threadRootId: string;
fileDropContainerRef: RefObject<HTMLElement>;
fileDropContainerRef: RefObject<HTMLElement | null>;
editEventId?: string;
onEditEventId: (eventId?: string) => void;
onComposerSent: () => void;
@@ -303,7 +303,7 @@ type ForumThreadDetailProps = {
rootEventId: string;
titleHint?: string;
initialPost?: ForumPost | null;
fileDropContainerRef?: RefObject<HTMLElement>;
fileDropContainerRef?: RefObject<HTMLElement | null>;
onReplySent?: (reply: ForumPost) => void;
};
+3 -3
View File
@@ -20,9 +20,9 @@ export type CanDropCallback = (item: HierarchyItem, container: DropContainerData
export const useDraggableItem = (
item: HierarchyItem,
targetRef: RefObject<HTMLElement>,
targetRef: RefObject<HTMLElement | null>,
onDragging: (item?: HierarchyItem) => void,
dragHandleRef?: RefObject<HTMLElement>,
dragHandleRef?: RefObject<HTMLElement | null>,
): boolean => {
const [dragging, setDragging] = useState(false);
@@ -120,7 +120,7 @@ export function AfterItemDropTarget({
}
export const useDnDMonitor = (
scrollRef: RefObject<HTMLElement>,
scrollRef: RefObject<HTMLElement | null>,
onDragging: (item?: HierarchyItem) => void,
onReorder: (item: HierarchyItem, container: DropContainerData) => void,
) => {
@@ -42,7 +42,7 @@ type MessageSearchProps = {
allowGlobal?: boolean;
rooms: string[];
senders?: string[];
scrollRef: RefObject<HTMLDivElement>;
scrollRef: RefObject<HTMLDivElement | null>;
};
export function MessageSearch({
defaultRoomsFilterName,
@@ -6,7 +6,7 @@ import { Icon, Icons } from '../../components/icons';
type SearchProps = {
active?: boolean;
loading?: boolean;
searchInputRef: RefObject<HTMLInputElement>;
searchInputRef: RefObject<HTMLInputElement | null>;
onSearch: (term: string) => void;
onReset: () => void;
};
+2 -2
View File
@@ -130,7 +130,7 @@ const createCarouselUuid = (): string => {
interface RoomInputProps {
editor: Editor;
fileDropContainerRef: RefObject<HTMLElement>;
fileDropContainerRef: RefObject<HTMLElement | null>;
roomId: string;
room: Room;
/** When provided, all messages are sent as replies in this thread. */
@@ -207,7 +207,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
roomUploadAtomFamily,
selectedFiles.map((f) => f.file),
);
const uploadBoardHandlers = useRef<UploadBoardImperativeHandlers>();
const uploadBoardHandlers = useRef<UploadBoardImperativeHandlers | undefined>(undefined);
const editorRef = useRef<HTMLDivElement>(null);
const imagePackRooms: Room[] = useImagePackRooms(roomId, roomToParents);
+2 -2
View File
@@ -373,7 +373,7 @@ export const getEventIdAbsoluteIndex = (
type RoomTimelineProps = {
room: Room;
eventId?: string;
roomInputRef: RefObject<HTMLElement>;
roomInputRef: RefObject<HTMLElement | null>;
editor: Editor;
};
@@ -665,7 +665,7 @@ export function RoomTimeline({ room, eventId, roomInputRef, editor }: RoomTimeli
const [unreadInfo, setUnreadInfo] = useState(() =>
getRoomUnreadInfo(room, scrollToLatestBehavior !== ScrollToLatestBehavior.Always),
);
const readUptoEventIdRef = useRef<string>();
const readUptoEventIdRef = useRef<string | undefined>(undefined);
if (unreadInfo) {
readUptoEventIdRef.current = unreadInfo.readUptoEventId;
}
+1 -1
View File
@@ -262,7 +262,7 @@ export function Search({ requestClose }: SearchProps) {
allowOutsideClick: true,
clickOutsideDeactivates: true,
onDeactivate: requestClose,
escapeDeactivates: (evt) => {
escapeDeactivates: (evt: KeyboardEvent) => {
evt.stopPropagation();
return true;
},
+1 -1
View File
@@ -10,7 +10,7 @@ export function useDebounce<T extends unknown[]>(
callback: DebounceCallback<T>,
options?: DebounceOptions,
): DebounceCallback<T> {
const timeoutIdRef = useRef<number>();
const timeoutIdRef = useRef<number | undefined>(undefined);
const { wait, immediate } = options ?? {};
const debounceCallback = useCallback(
+2 -2
View File
@@ -11,10 +11,10 @@ export const useFileDropHandler = (onDrop: (file: File[]) => void): DragEventHan
);
export const useFileDropZone = (
zoneRef: RefObject<HTMLElement> | undefined,
zoneRef: RefObject<HTMLElement | null> | undefined,
onDrop: (file: File[]) => void,
): boolean => {
const dragStateRef = useRef<'start' | 'leave' | 'over'>();
const dragStateRef = useRef<'start' | 'leave' | 'over' | undefined>(undefined);
const [active, setActive] = useState(false);
useEffect(() => {
+1 -1
View File
@@ -14,7 +14,7 @@ export type UseInertialHorizontalScrollOptions = {
};
export type UseInertialHorizontalScrollResult = {
scrollRef: RefObject<HTMLDivElement>;
scrollRef: RefObject<HTMLDivElement | null>;
isDragging: boolean;
canScrollBack: boolean;
canScrollForward: boolean;
+2 -2
View File
@@ -11,8 +11,8 @@ export function useThrottle<T extends unknown[]>(
callback: ThrottleCallback<T>,
options?: ThrottleOptions,
): ThrottleCallback<T> {
const timeoutIdRef = useRef<number>();
const argsRef = useRef<T>();
const timeoutIdRef = useRef<number | undefined>(undefined);
const argsRef = useRef<T | undefined>(undefined);
const { wait, immediate } = options ?? {};
const debounceCallback = useCallback(
+15 -9
View File
@@ -167,16 +167,22 @@ export const useVirtualPaginator = <TScrollElement extends HTMLElement>(
const initialRenderRef = useRef(true);
const restoreScrollRef = useRef<{
scrollTop: number;
anchorOffsetTop: number;
anchorItem: number;
}>();
const restoreScrollRef = useRef<
| {
scrollTop: number;
anchorOffsetTop: number;
anchorItem: number;
}
| undefined
>(undefined);
const scrollToItemRef = useRef<{
index: number;
opts?: ScrollToOptions;
}>();
const scrollToItemRef = useRef<
| {
index: number;
opts?: ScrollToOptions;
}
| undefined
>(undefined);
const propRef = useRef({
range,
+1 -1
View File
@@ -216,7 +216,7 @@ function InviteNotifications() {
}
function MessageNotifications() {
const notifRef = useRef<Notification>();
const notifRef = useRef<Notification | undefined>(undefined);
const unreadCacheRef = useRef<Map<string, UnreadInfo>>(new Map());
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
+1 -1
View File
@@ -85,7 +85,7 @@ const FALLBACK_ROOMS_LIMIT = 24;
type SearchProps = {
active?: boolean;
loading?: boolean;
searchInputRef: RefObject<HTMLInputElement>;
searchInputRef: RefObject<HTMLInputElement | null>;
onSearch: (term: string) => void;
onReset: () => void;
};
+6 -6
View File
@@ -299,9 +299,9 @@ type SidebarDraggable = string | FolderDraggable;
const useDraggableItem = (
item: SidebarDraggable,
targetRef: RefObject<HTMLElement>,
targetRef: RefObject<HTMLElement | null>,
onDragging: (item?: SidebarDraggable) => void,
dragHandleRef?: RefObject<HTMLElement>,
dragHandleRef?: RefObject<HTMLElement | null>,
): boolean => {
const [dragging, setDragging] = useState(false);
@@ -331,7 +331,7 @@ const useDraggableItem = (
const useDropTarget = (
item: SidebarDraggable,
targetRef: RefObject<HTMLElement>,
targetRef: RefObject<HTMLElement | null>,
): Instruction | undefined => {
const [dropState, setDropState] = useState<Instruction>();
@@ -379,7 +379,7 @@ const useDropTarget = (
function useDropTargetInstruction<T extends InstructionType>(
item: SidebarDraggable,
targetRef: RefObject<HTMLElement>,
targetRef: RefObject<HTMLElement | null>,
instructionType: T,
): T | undefined {
const [dropState, setDropState] = useState<T>();
@@ -411,7 +411,7 @@ function useDropTargetInstruction<T extends InstructionType>(
}
const useDnDMonitor = (
scrollRef: RefObject<HTMLElement>,
scrollRef: RefObject<HTMLElement | null>,
onDragging: (dragItem?: SidebarDraggable) => void,
onReorder: (
draggable: SidebarDraggable,
@@ -911,7 +911,7 @@ function HiddenSpacesFolder({
}
type SpaceTabsProps = {
scrollRef: RefObject<HTMLDivElement>;
scrollRef: RefObject<HTMLDivElement | null>;
};
export function SpaceTabs({ scrollRef }: SpaceTabsProps) {
const navigate = useNavigateWithTransition();
+20 -11
View File
@@ -382,17 +382,26 @@ class AndroidUnifiedPushManager {
const MatrixBackgroundSync = registerPlugin<MatrixBackgroundSyncPlugin>('MatrixBackgroundSync');
this.listenerHandles = [
await MatrixBackgroundSync.addListener('unifiedPushNewEndpoint', (event) => {
this.handleNewEndpoint(event).catch((err) => {
console.error('[BackgroundSync] handleNewEndpoint failed:', err);
});
}),
await MatrixBackgroundSync.addListener('unifiedPushUnregistered', (event) => {
this.handleUnregistered(event);
}),
await MatrixBackgroundSync.addListener('unifiedPushRegistrationFailed', (event) => {
this.handleRegistrationFailed(event);
}),
await MatrixBackgroundSync.addListener(
'unifiedPushNewEndpoint',
(event: UnifiedPushEndpointEvent) => {
this.handleNewEndpoint(event).catch((err) => {
console.error('[BackgroundSync] handleNewEndpoint failed:', err);
});
},
),
await MatrixBackgroundSync.addListener(
'unifiedPushUnregistered',
(event: UnifiedPushUnregisteredEvent) => {
this.handleUnregistered(event);
},
),
await MatrixBackgroundSync.addListener(
'unifiedPushRegistrationFailed',
(event: UnifiedPushRegistrationFailedEvent) => {
this.handleRegistrationFailed(event);
},
),
];
this.listenersReady = true;
}
+1 -1
View File
@@ -7,7 +7,7 @@ import { timeHourMinute } from './time';
* This intercepts the copy event on the timeline and reformats the copied text.
*/
export const setupCopyHandler = (
containerRef: React.RefObject<HTMLElement>,
containerRef: React.RefObject<HTMLElement | null>,
getMessageData: (eventId: string) => { sender: string; ts: number; content: string } | null,
hour24Clock: boolean,
): (() => void) => {
+2 -1
View File
@@ -133,7 +133,8 @@ export const decryptFile = async (
return blob;
};
export type TUploadContent = File | Blob;
// Producers can pass a plain Blob (decryptFile), so name is not always present.
export type TUploadContent = File | (Blob & { name?: string });
export type ContentUploadOptions = {
name?: string;
+5
View File
@@ -1,3 +1,8 @@
import { ComplexStyleRule } from '@vanilla-extract/css';
export type WithRequiredProp<Type extends object, Key extends keyof Type> = Type & {
[Property in Key]-?: Type[Property];
};
// csstype has no WebkitAppRegion, and ComplexStyleRule is a type alias, so it can only be intersected.
export type AppRegionStyleRule = ComplexStyleRule & { WebkitAppRegion?: 'drag' | 'no-drag' };