nicolium: moar

Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
This commit is contained in:
nicole mikołajczyk
2026-02-27 17:01:47 +01:00
parent d26afd8769
commit a8a0cb27ef
13 changed files with 41 additions and 34 deletions

View File

@ -91,7 +91,7 @@ interface TimelineDequeueAction {
}
const dequeueTimeline =
(timelineId: string, expandFunc?: (lastStatusId: string) => void) =>
(timelineId: string, expandFunc?: () => void) =>
(dispatch: AppDispatch, getState: () => RootState) => {
const state = getState();
const queuedCount = state.timelines[timelineId]?.totalQueuedItemsCount || 0;
@ -105,7 +105,6 @@ const dequeueTimeline =
if (typeof expandFunc === 'function') {
dispatch(clearTimeline(timelineId));
// @ts-expect-error
expandFunc();
} else if (timelineId === 'home') {
dispatch(clearTimeline(timelineId));

View File

@ -3,7 +3,7 @@ import React from 'react';
interface IForm {
/** Form submission event handler. */
onSubmit?: (event: React.FormEvent) => void;
onSubmit?: (event: React.SubmitEvent<HTMLFormElement>) => void;
/** Class name override for the <form> element. */
className?: string;
/** Elements to display within the Form. */
@ -12,7 +12,7 @@ interface IForm {
/** Form element with custom styles. */
const Form: React.FC<IForm> = ({ onSubmit, children, className, ...filteredProps }) => {
const handleSubmit: React.FormEventHandler = React.useCallback(
const handleSubmit: React.SubmitEventHandler<HTMLFormElement> = React.useCallback(
(event) => {
event.preventDefault();

View File

@ -45,7 +45,7 @@ const Timeline: React.FC<ITimeline> = ({ timelineId, onLoadMore, prefix, ...rest
);
const handleDequeueTimeline = useCallback(() => {
dispatch(dequeueTimeline(timelineId, onLoadMore));
dispatch(dequeueTimeline(timelineId, onLoadMore ? () => onLoadMore(lastStatusId!) : undefined));
}, []);
const handleScroll = useCallback(

View File

@ -1,4 +1,14 @@
(window as any).__PL_API_FALLBACK_ACCOUNT = { id: '', acct: 'undefined', url: location.origin };
window.__PL_API_FALLBACK_ACCOUNT = { id: '', acct: 'undefined', url: location.origin };
declare global {
interface Window {
__PL_API_FALLBACK_ACCOUNT: {
id: string;
acct: string;
url: string;
};
}
}
import './polyfills';
import React from 'react';

View File

@ -33,8 +33,8 @@ const PasswordResetPage = () => {
const [isLoading, setIsLoading] = useState(false);
const [success, setSuccess] = useState(false);
const handleSubmit = (e: React.FormEvent) => {
const nicknameOrEmail = (e.target as any).nickname_or_email.value;
const handleSubmit = (e: React.SubmitEvent<HTMLFormElement>) => {
const nicknameOrEmail = (e.target as HTMLFormElement).nickname_or_email.value;
setIsLoading(true);
dispatch(resetPassword(nicknameOrEmail))
.then(() => {

View File

@ -85,7 +85,7 @@ const ThemeEditorPage: React.FC = () => {
});
};
const setTheme = (theme: any) => {
const setTheme = (theme: Record<string, Record<string, string> | string>) => {
setResetKey(crypto.randomUUID());
setIsDefault(false);
setTimeout(() => {
@ -130,7 +130,7 @@ const ThemeEditorPage: React.FC = () => {
const json = JSON.parse(text);
const colors = v.parse(frontendConfigSchema, { colors: json }).colors;
setTheme(colors);
if (colors) setTheme(colors);
toast.success(intl.formatMessage(messages.importSuccess));
}
};

View File

@ -127,7 +127,7 @@ const normalizeStatus = (
}
});
const accountId = (account || (window as any).__PL_API_FALLBACK_ACCOUNT)?.id;
const accountId = (account || window.__PL_API_FALLBACK_ACCOUNT).id;
// Add self to mentions if it's a reply to self
const isSelfReply = accountId === status.in_reply_to_account_id;

View File

@ -149,21 +149,19 @@ const makeGetNotification = () =>
[
(_state: RootState, notification: NotificationGroup) => notification,
(_state: RootState, notification: NotificationGroup) =>
// @ts-expect-error types will be fine valibot ensures that
selectAccount(notification.target_id),
// @ts-expect-error types will be fine valibot ensures that
(state: RootState, notification: NotificationGroup) => state.statuses[notification.status_id],
selectAccount(('target_id' in notification ? notification.target_id : undefined)!),
(state: RootState, notification: NotificationGroup) =>
state.statuses[('status_id' in notification ? notification.status_id : undefined)!],
(_state: RootState, notification: NotificationGroup) =>
selectAccounts(notification.sample_account_ids),
],
(notification, target, status, accounts): SelectedNotification => ({
...notification,
// @ts-expect-error types will be fine valibot ensures that
target,
// @ts-expect-error types will be fine valibot ensures that
status,
accounts,
}),
(notification, target, status, accounts): SelectedNotification =>
({
...notification,
target: target!,
status: status!,
accounts,
}) as unknown as SelectedNotification,
);
type SelectedNotification = NotificationGroup & {
@ -293,7 +291,7 @@ const makeGetStatusIds = () =>
(state: RootState, { type }: ColumnQuery) => state.timelines[type]?.items || [],
(state: RootState) => state.statuses,
],
(columnSettings: any, statusIds: Array<string>, statuses) =>
(columnSettings, statusIds: Array<string>, statuses) =>
statusIds.filter((id: string) => {
const status = statuses[id];
if (!status) return true;

View File

@ -140,7 +140,7 @@ const cloneNotification = (notification: Notification): ClonedNotification => {
// Object.assign() does not work with notifications
for (k in notification) {
clone[k] = (notification as any)[k];
clone[k] = notification[k as keyof Notification];
}
return clone as ClonedNotification;

View File

@ -806,8 +806,7 @@ const useSubmitCompose = (composeId: string) => {
};
if (compose.editedId) {
// @ts-expect-error
params.media_attributes = media.map((item) => {
(params as EditStatusParams).media_attributes = media.map((item) => {
const focalPoint = (item.type === 'image' || item.type === 'gifv') && item.meta?.focus;
const focus = focalPoint
? `${focalPoint.x.toFixed(2)},${focalPoint.y.toFixed(2)}`

View File

@ -5,7 +5,7 @@ const LAYOUT_BREAKPOINT = 581;
const isMobile = (width: number) => width <= LAYOUT_BREAKPOINT;
/** Whether the device is iOS (best guess). */
const iOS: boolean = /iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream;
const iOS: boolean = /iPad|iPhone|iPod/.test(navigator.userAgent) && !('MSStream' in window);
const userTouching = window.matchMedia('(pointer: coarse)');

View File

@ -83,7 +83,7 @@ const removePageItem = <T>(
};
const paginateQueryData = <T>(array: T[] | undefined) =>
array?.reduce((resultArray: any, item: any, index: any) => {
array?.reduce<T[][]>((resultArray, item, index) => {
const chunkIndex = Math.floor(index / 20);
resultArray[chunkIndex] ??= [];
@ -103,10 +103,11 @@ const sortQueryData = <T>(
const flattenedQueryData = flattenPages(nextResult);
const sortedQueryData = flattenedQueryData?.toSorted(comparator);
const paginatedPages = paginateQueryData(sortedQueryData);
const newPages = paginatedPages.map((page: T, idx: number) => ({
...prevResult.pages[idx],
result: page,
}));
const newPages =
paginatedPages?.map((page, idx) => ({
...prevResult.pages[idx],
result: page,
})) ?? [];
nextResult.pages = newPages;
return nextResult;

View File

@ -27,7 +27,7 @@ const isStandalone = (state: RootState): boolean => {
return isURL(BuildConfig.BACKEND_URL) ? false : !isPrerendered && instanceFetchFailed;
};
const getHost = (url: any): string => {
const getHost = (url: string = ''): string => {
try {
return new URL(url).origin;
} catch {