pl-hooks: Work on making this an actual library

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-10-17 23:55:52 +02:00
parent a4b520a13a
commit fb34a8bf4a
59 changed files with 82 additions and 76 deletions

View File

@ -0,0 +1,12 @@
export * from './contexts/api-client';
export * from './contexts/query-client';
export * from './hooks/accounts/useAccount';
export * from './hooks/accounts/useAccountRelationship';
export * from './hooks/markers/useMarkers';
export * from './hooks/markers/useUpdateMarkerMutation';
export * from './hooks/notifications/useNotification';
export * from './hooks/notifications/useNotificationList';
export * from './hooks/statuses/useStatus';
export * from './importer';

View File

@ -1,9 +1,5 @@
/**
* Status normalizer:
* Converts API statuses into our internal format.
* @see {@link https://docs.joinmastodon.org/entities/status/}
*/
import { type Account as BaseAccount, type Status as BaseStatus, type MediaAttachment, mentionSchema } from 'pl-api';
import * as v from 'valibot';
type StatusApprovalStatus = Exclude<BaseStatus['approval_status'], null>;
type StatusVisibility = 'public' | 'unlisted' | 'private' | 'direct' | 'group' | 'mutuals_only' | 'local';
@ -23,7 +19,7 @@ const normalizeStatus = ({ account, accounts, reblog, poll, group, quote, ...sta
const hasSelfMention = status.mentions.some(mention => account.id === mention.id);
if (isSelfReply && !hasSelfMention) {
const selfMention = mentionSchema.parse(account);
const selfMention = v.parse(mentionSchema, account);
mentions = [selfMention, ...mentions];
}