From 859149230e53cca34743d63000c10ae8f1414ab3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Sun, 1 Sep 2024 15:36:24 +0200 Subject: [PATCH] pl-fe: cleanup, avoid parsing schemas more than once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- packages/pl-fe/package.json | 2 +- packages/pl-fe/src/actions/admin.ts | 1 - packages/pl-fe/src/api/hooks/accounts/useAccount.ts | 3 ++- packages/pl-fe/src/api/hooks/accounts/useAccountLookup.ts | 5 +++-- packages/pl-fe/src/api/hooks/accounts/useRelationship.ts | 5 +++-- packages/pl-fe/src/api/hooks/accounts/useRelationships.ts | 6 +++--- packages/pl-fe/src/api/hooks/groups/useCreateGroup.ts | 6 +++--- .../pl-fe/src/api/hooks/groups/useDemoteGroupMember.ts | 5 +++-- packages/pl-fe/src/api/hooks/groups/useGroup.ts | 4 ++-- packages/pl-fe/src/api/hooks/groups/useGroupMedia.ts | 4 +--- packages/pl-fe/src/api/hooks/groups/useGroupMembers.ts | 6 +++--- .../src/api/hooks/groups/useGroupMembershipRequests.ts | 3 +-- .../pl-fe/src/api/hooks/groups/useGroupRelationship.ts | 5 +++-- .../pl-fe/src/api/hooks/groups/useGroupRelationships.ts | 6 +++--- packages/pl-fe/src/api/hooks/groups/useGroups.ts | 6 +++--- .../pl-fe/src/api/hooks/groups/usePromoteGroupMember.ts | 3 +-- packages/pl-fe/src/api/hooks/groups/useUpdateGroup.ts | 4 +--- packages/pl-fe/src/api/hooks/index.ts | 1 - .../pl-fe/src/api/hooks/statuses/useBookmarkFolders.ts | 6 +++--- .../src/api/hooks/statuses/useCreateBookmarkFolder.ts | 3 --- .../src/api/hooks/statuses/useUpdateBookmarkFolder.ts | 3 --- packages/pl-fe/src/api/hooks/streaming/useUserStream.ts | 7 +++---- packages/pl-fe/src/api/hooks/trends/useTrendingLinks.ts | 8 ++++---- packages/pl-fe/src/components/polls/poll-footer.test.tsx | 3 ++- packages/pl-fe/src/middleware/sounds.ts | 1 - packages/pl-fe/src/utils/scopes.ts | 1 - packages/pl-fe/src/utils/status.test.ts | 1 - packages/pl-fe/yarn.lock | 8 ++++---- 28 files changed, 52 insertions(+), 64 deletions(-) diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index 5c96f94b6..f9141205f 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -133,7 +133,7 @@ "multiselect-react-dropdown": "^2.0.25", "object-to-formdata": "^4.5.1", "path-browserify": "^1.0.1", - "pl-api": "^0.0.25", + "pl-api": "^0.0.26", "postcss": "^8.4.29", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/actions/admin.ts b/packages/pl-fe/src/actions/admin.ts index 6173bba3e..8718128f4 100644 --- a/packages/pl-fe/src/actions/admin.ts +++ b/packages/pl-fe/src/actions/admin.ts @@ -1,4 +1,3 @@ - import { fetchRelationships } from 'pl-fe/actions/accounts'; import { importFetchedAccount, importFetchedAccounts, importFetchedStatuses } from 'pl-fe/actions/importer'; import { filterBadges, getTagDiff } from 'pl-fe/utils/badges'; diff --git a/packages/pl-fe/src/api/hooks/accounts/useAccount.ts b/packages/pl-fe/src/api/hooks/accounts/useAccount.ts index 179709474..783632a6b 100644 --- a/packages/pl-fe/src/api/hooks/accounts/useAccount.ts +++ b/packages/pl-fe/src/api/hooks/accounts/useAccount.ts @@ -1,4 +1,3 @@ -import { type Account as BaseAccount } from 'pl-api'; import { useEffect, useMemo } from 'react'; import { useHistory } from 'react-router-dom'; @@ -10,6 +9,8 @@ import { type Account, normalizeAccount } from 'pl-fe/normalizers'; import { useAccountScrobble } from './useAccountScrobble'; import { useRelationship } from './useRelationship'; +import type { Account as BaseAccount } from 'pl-api'; + interface UseAccountOpts { withRelationship?: boolean; withScrobble?: boolean; diff --git a/packages/pl-fe/src/api/hooks/accounts/useAccountLookup.ts b/packages/pl-fe/src/api/hooks/accounts/useAccountLookup.ts index e59353fc2..444e03faa 100644 --- a/packages/pl-fe/src/api/hooks/accounts/useAccountLookup.ts +++ b/packages/pl-fe/src/api/hooks/accounts/useAccountLookup.ts @@ -1,4 +1,3 @@ -import { accountSchema, type Account as BaseAccount } from 'pl-api'; import { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; @@ -10,6 +9,8 @@ import { type Account, normalizeAccount } from 'pl-fe/normalizers'; import { useAccountScrobble } from './useAccountScrobble'; import { useRelationship } from './useRelationship'; +import type { Account as BaseAccount } from 'pl-api'; + interface UseAccountLookupOpts { withRelationship?: boolean; withScrobble?: boolean; @@ -26,7 +27,7 @@ const useAccountLookup = (acct: string | undefined, opts: UseAccountLookupOpts = Entities.ACCOUNTS, (account) => account.acct.toLowerCase() === acct?.toLowerCase(), () => client.accounts.lookupAccount(acct!), - { schema: accountSchema, enabled: !!acct, transform: normalizeAccount }, + { enabled: !!acct, transform: normalizeAccount }, ); const { diff --git a/packages/pl-fe/src/api/hooks/accounts/useRelationship.ts b/packages/pl-fe/src/api/hooks/accounts/useRelationship.ts index 21cafc382..d47f3e68e 100644 --- a/packages/pl-fe/src/api/hooks/accounts/useRelationship.ts +++ b/packages/pl-fe/src/api/hooks/accounts/useRelationship.ts @@ -1,10 +1,11 @@ -import { type Relationship, relationshipSchema } from 'pl-api'; import { z } from 'zod'; import { Entities } from 'pl-fe/entity-store/entities'; import { useEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; +import type { Relationship } from 'pl-api'; + interface UseRelationshipOpts { enabled?: boolean; } @@ -18,7 +19,7 @@ const useRelationship = (accountId: string | undefined, opts: UseRelationshipOpt () => client.accounts.getRelationships([accountId!]), { enabled: enabled && !!accountId, - schema: z.array(relationshipSchema).nonempty().transform(arr => arr[0]), + schema: z.any().transform(arr => arr[0]), }, ); diff --git a/packages/pl-fe/src/api/hooks/accounts/useRelationships.ts b/packages/pl-fe/src/api/hooks/accounts/useRelationships.ts index 81925637b..c14ca9844 100644 --- a/packages/pl-fe/src/api/hooks/accounts/useRelationships.ts +++ b/packages/pl-fe/src/api/hooks/accounts/useRelationships.ts @@ -1,9 +1,9 @@ -import { type Relationship, relationshipSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useBatchedEntities } from 'pl-fe/entity-store/hooks/useBatchedEntities'; import { useClient, useLoggedIn } from 'pl-fe/hooks'; +import type { Relationship } from 'pl-api'; + const useRelationships = (listKey: string[], accountIds: string[]) => { const client = useClient(); const { isLoggedIn } = useLoggedIn(); @@ -14,7 +14,7 @@ const useRelationships = (listKey: string[], accountIds: string[]) => { [Entities.RELATIONSHIPS, ...listKey], accountIds, fetchRelationships, - { schema: relationshipSchema, enabled: isLoggedIn }, + { enabled: isLoggedIn }, ); return { relationships, ...result }; diff --git a/packages/pl-fe/src/api/hooks/groups/useCreateGroup.ts b/packages/pl-fe/src/api/hooks/groups/useCreateGroup.ts index 85b926f90..f8f8c1222 100644 --- a/packages/pl-fe/src/api/hooks/groups/useCreateGroup.ts +++ b/packages/pl-fe/src/api/hooks/groups/useCreateGroup.ts @@ -1,10 +1,10 @@ -import { groupSchema, type Group as BaseGroup } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useCreateEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; import { normalizeGroup, type Group } from 'pl-fe/normalizers'; +import type { Group as BaseGroup } from 'pl-api'; + interface CreateGroupParams { display_name: string; note?: string; @@ -21,7 +21,7 @@ const useCreateGroup = () => { const { createEntity, ...rest } = useCreateEntity( [Entities.GROUPS, 'search', ''], (params: CreateGroupParams) => client.experimental.groups.createGroup(params), - { schema: groupSchema, transform: normalizeGroup }, + { transform: normalizeGroup }, ); return { diff --git a/packages/pl-fe/src/api/hooks/groups/useDemoteGroupMember.ts b/packages/pl-fe/src/api/hooks/groups/useDemoteGroupMember.ts index 9af06816f..1a1e4d81f 100644 --- a/packages/pl-fe/src/api/hooks/groups/useDemoteGroupMember.ts +++ b/packages/pl-fe/src/api/hooks/groups/useDemoteGroupMember.ts @@ -1,4 +1,3 @@ -import { groupMemberSchema, type Group, type GroupMember as GroupMember, type GroupRole } from 'pl-api'; import { z } from 'zod'; import { Entities } from 'pl-fe/entity-store/entities'; @@ -6,13 +5,15 @@ import { useCreateEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; import { normalizeGroupMember } from 'pl-fe/normalizers'; +import type { Group, GroupMember as GroupMember, GroupRole } from 'pl-api'; + const useDemoteGroupMember = (group: Pick, groupMember: Pick) => { const client = useClient(); const { createEntity } = useCreateEntity( [Entities.GROUP_MEMBERSHIPS, groupMember.id], ({ account_ids, role }: { account_ids: string[]; role: GroupRole }) => client.experimental.groups.demoteGroupUsers(group.id, account_ids, role), - { schema: z.array(groupMemberSchema).transform((arr) => arr[0]), transform: normalizeGroupMember }, + { schema: z.any().transform((arr) => arr[0]), transform: normalizeGroupMember }, ); return createEntity; diff --git a/packages/pl-fe/src/api/hooks/groups/useGroup.ts b/packages/pl-fe/src/api/hooks/groups/useGroup.ts index bc82d9330..62b4bd71f 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroup.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroup.ts @@ -1,4 +1,3 @@ -import { type Group as BaseGroup, groupSchema } from 'pl-api'; import { useEffect } from 'react'; import { useHistory } from 'react-router-dom'; @@ -9,6 +8,8 @@ import { normalizeGroup, type Group } from 'pl-fe/normalizers'; import { useGroupRelationship } from './useGroupRelationship'; +import type { Group as BaseGroup } from 'pl-api'; + const useGroup = (groupId: string, refetch = true) => { const client = useClient(); const history = useHistory(); @@ -17,7 +18,6 @@ const useGroup = (groupId: string, refetch = true) => { [Entities.GROUPS, groupId], () => client.experimental.groups.getGroup(groupId), { - schema: groupSchema, transform: normalizeGroup, refetch, enabled: !!groupId, diff --git a/packages/pl-fe/src/api/hooks/groups/useGroupMedia.ts b/packages/pl-fe/src/api/hooks/groups/useGroupMedia.ts index 09eccdfee..273476510 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroupMedia.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroupMedia.ts @@ -1,5 +1,3 @@ -import { statusSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useEntities } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; @@ -11,7 +9,7 @@ const useGroupMedia = (groupId: string) => { return useEntities( [Entities.STATUSES, 'groupMedia', groupId], () => client.timelines.groupTimeline(groupId, { only_media: true }), - { schema: statusSchema, transform: normalizeStatus }) + { transform: normalizeStatus }) ; }; diff --git a/packages/pl-fe/src/api/hooks/groups/useGroupMembers.ts b/packages/pl-fe/src/api/hooks/groups/useGroupMembers.ts index 23fcc3a36..99cd25790 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroupMembers.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroupMembers.ts @@ -1,17 +1,17 @@ -import { groupMemberSchema, type GroupMember as BaseGroupMember, type GroupRoles } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useEntities } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; import { normalizeGroupMember, type GroupMember } from 'pl-fe/normalizers'; +import type { GroupMember as BaseGroupMember, GroupRoles } from 'pl-api'; + const useGroupMembers = (groupId: string, role: GroupRoles) => { const client = useClient(); const { entities, ...result } = useEntities( [Entities.GROUP_MEMBERSHIPS, groupId, role], () => client.experimental.groups.getGroupMemberships(groupId, role), - { schema: groupMemberSchema, transform: normalizeGroupMember }, + { transform: normalizeGroupMember }, ); return { diff --git a/packages/pl-fe/src/api/hooks/groups/useGroupMembershipRequests.ts b/packages/pl-fe/src/api/hooks/groups/useGroupMembershipRequests.ts index 49958f3c0..38e631cd7 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroupMembershipRequests.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroupMembershipRequests.ts @@ -1,4 +1,4 @@ -import { accountSchema, GroupRoles } from 'pl-api'; +import { GroupRoles } from 'pl-api'; import { Entities } from 'pl-fe/entity-store/entities'; import { useDismissEntity, useEntities } from 'pl-fe/entity-store/hooks'; @@ -19,7 +19,6 @@ const useGroupMembershipRequests = (groupId: string) => { path, () => client.experimental.groups.getGroupMembershipRequests(groupId), { - schema: accountSchema, transform: normalizeAccount, enabled: relationship?.role === GroupRoles.OWNER || relationship?.role === GroupRoles.ADMIN, }, diff --git a/packages/pl-fe/src/api/hooks/groups/useGroupRelationship.ts b/packages/pl-fe/src/api/hooks/groups/useGroupRelationship.ts index f71083fa9..1241f1d5d 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroupRelationship.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroupRelationship.ts @@ -1,10 +1,11 @@ -import { type GroupRelationship, groupRelationshipSchema } from 'pl-api'; import { z } from 'zod'; import { Entities } from 'pl-fe/entity-store/entities'; import { useEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; +import type { GroupRelationship } from 'pl-api'; + const useGroupRelationship = (groupId: string | undefined) => { const client = useClient(); @@ -13,7 +14,7 @@ const useGroupRelationship = (groupId: string | undefined) => { () => client.experimental.groups.getGroupRelationships([groupId!]), { enabled: !!groupId, - schema: z.array(groupRelationshipSchema).nonempty().transform(arr => arr[0]), + schema: z.any().transform(arr => arr[0]), }, ); diff --git a/packages/pl-fe/src/api/hooks/groups/useGroupRelationships.ts b/packages/pl-fe/src/api/hooks/groups/useGroupRelationships.ts index 61d8498eb..128b067a0 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroupRelationships.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroupRelationships.ts @@ -1,9 +1,9 @@ -import { type GroupRelationship, groupRelationshipSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useBatchedEntities } from 'pl-fe/entity-store/hooks/useBatchedEntities'; import { useClient, useLoggedIn } from 'pl-fe/hooks'; +import type { GroupRelationship } from 'pl-api'; + const useGroupRelationships = (listKey: string[], groupIds: string[]) => { const client = useClient(); const { isLoggedIn } = useLoggedIn(); @@ -15,7 +15,7 @@ const useGroupRelationships = (listKey: string[], groupIds: string[]) => { [Entities.RELATIONSHIPS, ...listKey], groupIds, fetchGroupRelationships, - { schema: groupRelationshipSchema, enabled: isLoggedIn }, + { enabled: isLoggedIn }, ); return { relationships, ...result }; diff --git a/packages/pl-fe/src/api/hooks/groups/useGroups.ts b/packages/pl-fe/src/api/hooks/groups/useGroups.ts index e7e4f2e14..ecfe71090 100644 --- a/packages/pl-fe/src/api/hooks/groups/useGroups.ts +++ b/packages/pl-fe/src/api/hooks/groups/useGroups.ts @@ -1,5 +1,3 @@ -import { groupSchema, type Group as BaseGroup } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useEntities } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; @@ -8,6 +6,8 @@ import { normalizeGroup, type Group } from 'pl-fe/normalizers'; import { useGroupRelationships } from './useGroupRelationships'; +import type { Group as BaseGroup } from 'pl-api'; + const useGroups = () => { const client = useClient(); const features = useFeatures(); @@ -15,7 +15,7 @@ const useGroups = () => { const { entities, ...result } = useEntities( [Entities.GROUPS, 'search', ''], () => client.experimental.groups.getGroups(), - { enabled: features.groups, schema: groupSchema, transform: normalizeGroup }, + { enabled: features.groups, transform: normalizeGroup }, ); const { relationships } = useGroupRelationships( ['search', ''], diff --git a/packages/pl-fe/src/api/hooks/groups/usePromoteGroupMember.ts b/packages/pl-fe/src/api/hooks/groups/usePromoteGroupMember.ts index 18aeaeb2f..641d77922 100644 --- a/packages/pl-fe/src/api/hooks/groups/usePromoteGroupMember.ts +++ b/packages/pl-fe/src/api/hooks/groups/usePromoteGroupMember.ts @@ -1,4 +1,3 @@ -import { groupMemberSchema } from 'pl-api'; import { z } from 'zod'; import { Entities } from 'pl-fe/entity-store/entities'; @@ -14,7 +13,7 @@ const usePromoteGroupMember = (group: Pick, groupMember: Pick client.experimental.groups.promoteGroupUsers(group.id, account_ids, role), - { schema: z.array(groupMemberSchema).transform((arr) => arr[0]), transform: normalizeGroupMember }, + { schema: z.any().transform((arr) => arr[0]), transform: normalizeGroupMember }, ); return createEntity; diff --git a/packages/pl-fe/src/api/hooks/groups/useUpdateGroup.ts b/packages/pl-fe/src/api/hooks/groups/useUpdateGroup.ts index 605930e41..c43f2e9cc 100644 --- a/packages/pl-fe/src/api/hooks/groups/useUpdateGroup.ts +++ b/packages/pl-fe/src/api/hooks/groups/useUpdateGroup.ts @@ -1,5 +1,3 @@ -import { groupSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useCreateEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; @@ -20,7 +18,7 @@ const useUpdateGroup = (groupId: string) => { const { createEntity, ...rest } = useCreateEntity( [Entities.GROUPS], (params: UpdateGroupParams) => client.experimental.groups.updateGroup(groupId, params), - { schema: groupSchema, transform: normalizeGroup }, + { transform: normalizeGroup }, ); return { diff --git a/packages/pl-fe/src/api/hooks/index.ts b/packages/pl-fe/src/api/hooks/index.ts index 0a22c9e7c..280f262cd 100644 --- a/packages/pl-fe/src/api/hooks/index.ts +++ b/packages/pl-fe/src/api/hooks/index.ts @@ -1,4 +1,3 @@ - // Accounts export { useAccount } from './accounts/useAccount'; export { useAccountLookup } from './accounts/useAccountLookup'; diff --git a/packages/pl-fe/src/api/hooks/statuses/useBookmarkFolders.ts b/packages/pl-fe/src/api/hooks/statuses/useBookmarkFolders.ts index da11b3e3c..a13815f8d 100644 --- a/packages/pl-fe/src/api/hooks/statuses/useBookmarkFolders.ts +++ b/packages/pl-fe/src/api/hooks/statuses/useBookmarkFolders.ts @@ -1,10 +1,10 @@ -import { bookmarkFolderSchema, type BookmarkFolder } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useEntities } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; import { useFeatures } from 'pl-fe/hooks/useFeatures'; +import type { BookmarkFolder } from 'pl-api'; + const useBookmarkFolders = () => { const client = useClient(); const features = useFeatures(); @@ -12,7 +12,7 @@ const useBookmarkFolders = () => { const { entities, ...result } = useEntities( [Entities.BOOKMARK_FOLDERS], () => client.myAccount.getBookmarkFolders(), - { enabled: features.bookmarkFolders, schema: bookmarkFolderSchema }, + { enabled: features.bookmarkFolders }, ); const bookmarkFolders = entities; diff --git a/packages/pl-fe/src/api/hooks/statuses/useCreateBookmarkFolder.ts b/packages/pl-fe/src/api/hooks/statuses/useCreateBookmarkFolder.ts index 3cc7560af..ce174d375 100644 --- a/packages/pl-fe/src/api/hooks/statuses/useCreateBookmarkFolder.ts +++ b/packages/pl-fe/src/api/hooks/statuses/useCreateBookmarkFolder.ts @@ -1,5 +1,3 @@ -import { bookmarkFolderSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useCreateEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; @@ -16,7 +14,6 @@ const useCreateBookmarkFolder = () => { [Entities.BOOKMARK_FOLDERS], (params: CreateBookmarkFolderParams) => client.myAccount.createBookmarkFolder(params), - { schema: bookmarkFolderSchema }, ); return { diff --git a/packages/pl-fe/src/api/hooks/statuses/useUpdateBookmarkFolder.ts b/packages/pl-fe/src/api/hooks/statuses/useUpdateBookmarkFolder.ts index 270120968..d45b22f50 100644 --- a/packages/pl-fe/src/api/hooks/statuses/useUpdateBookmarkFolder.ts +++ b/packages/pl-fe/src/api/hooks/statuses/useUpdateBookmarkFolder.ts @@ -1,5 +1,3 @@ -import { bookmarkFolderSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useCreateEntity } from 'pl-fe/entity-store/hooks'; import { useClient } from 'pl-fe/hooks'; @@ -16,7 +14,6 @@ const useUpdateBookmarkFolder = (folderId: string) => { [Entities.BOOKMARK_FOLDERS], (params: UpdateBookmarkFolderParams) => client.myAccount.updateBookmarkFolder(folderId, params), - { schema: bookmarkFolderSchema }, ); return { diff --git a/packages/pl-fe/src/api/hooks/streaming/useUserStream.ts b/packages/pl-fe/src/api/hooks/streaming/useUserStream.ts index dd8921007..0b013de11 100644 --- a/packages/pl-fe/src/api/hooks/streaming/useUserStream.ts +++ b/packages/pl-fe/src/api/hooks/streaming/useUserStream.ts @@ -1,5 +1,3 @@ - -import { announcementSchema, type Announcement, type AnnouncementReaction, type FollowRelationshipUpdate, type Relationship, type StreamingEvent } from 'pl-api'; import { useCallback } from 'react'; import { updateConversations } from 'pl-fe/actions/conversations'; @@ -22,6 +20,7 @@ import { updateReactions } from '../announcements/useAnnouncements'; import { useTimelineStream } from './useTimelineStream'; +import type { Announcement, AnnouncementReaction, FollowRelationshipUpdate, Relationship, StreamingEvent } from 'pl-api'; import type { AppDispatch, RootState } from 'pl-fe/store'; const updateAnnouncementReactions = ({ announcement_id: id, name }: AnnouncementReaction) => { @@ -42,10 +41,10 @@ const updateAnnouncement = (announcement: Announcement) => let updated = false; const result = prevResult.map(value => value.id === announcement.id - ? (updated = true, announcementSchema.parse(announcement)) + ? (updated = true, announcement) : value); - if (!updated) return [announcementSchema.parse(announcement), ...result]; + if (!updated) return [announcement, ...result]; }); const deleteAnnouncement = (announcementId: string) => diff --git a/packages/pl-fe/src/api/hooks/trends/useTrendingLinks.ts b/packages/pl-fe/src/api/hooks/trends/useTrendingLinks.ts index a2893ee2e..2c3dde949 100644 --- a/packages/pl-fe/src/api/hooks/trends/useTrendingLinks.ts +++ b/packages/pl-fe/src/api/hooks/trends/useTrendingLinks.ts @@ -1,17 +1,17 @@ -import { trendsLinkSchema } from 'pl-api'; - import { Entities } from 'pl-fe/entity-store/entities'; import { useEntities } from 'pl-fe/entity-store/hooks'; import { useClient, useFeatures } from 'pl-fe/hooks'; +import type { TrendsLink } from 'pl-api'; + const useTrendingLinks = () => { const client = useClient(); const features = useFeatures(); - const { entities, ...rest } = useEntities( + const { entities, ...rest } = useEntities( [Entities.TRENDS_LINKS], () => client.trends.getTrendingLinks(), - { schema: trendsLinkSchema, enabled: features.trendingLinks }, + { enabled: features.trendingLinks }, ); return { trendingLinks: entities, ...rest }; diff --git a/packages/pl-fe/src/components/polls/poll-footer.test.tsx b/packages/pl-fe/src/components/polls/poll-footer.test.tsx index 12821e200..600cc8682 100644 --- a/packages/pl-fe/src/components/polls/poll-footer.test.tsx +++ b/packages/pl-fe/src/components/polls/poll-footer.test.tsx @@ -1,5 +1,4 @@ import userEvent from '@testing-library/user-event'; -import { type Poll } from 'pl-api'; import React from 'react'; import { IntlProvider } from 'react-intl'; import { Provider } from 'react-redux'; @@ -9,6 +8,8 @@ import { mockStore, render, screen, rootState } from 'pl-fe/jest/test-helpers'; import PollFooter from './poll-footer'; +import type { Poll } from 'pl-api'; + let poll: Poll = { id: '1', options: [{ diff --git a/packages/pl-fe/src/middleware/sounds.ts b/packages/pl-fe/src/middleware/sounds.ts index 57c3534ec..61eca76d6 100644 --- a/packages/pl-fe/src/middleware/sounds.ts +++ b/packages/pl-fe/src/middleware/sounds.ts @@ -1,4 +1,3 @@ - import { play, soundCache } from 'pl-fe/utils/sounds'; import type { Sounds } from 'pl-fe/utils/sounds'; diff --git a/packages/pl-fe/src/utils/scopes.ts b/packages/pl-fe/src/utils/scopes.ts index f6f2e8e67..bfaf61d22 100644 --- a/packages/pl-fe/src/utils/scopes.ts +++ b/packages/pl-fe/src/utils/scopes.ts @@ -1,4 +1,3 @@ - import { getFeatures, PLEROMA, TOKI, type Instance } from 'pl-api'; import type { RootState } from 'pl-fe/store'; diff --git a/packages/pl-fe/src/utils/status.test.ts b/packages/pl-fe/src/utils/status.test.ts index 515d0a39c..89a5aa53b 100644 --- a/packages/pl-fe/src/utils/status.test.ts +++ b/packages/pl-fe/src/utils/status.test.ts @@ -1,4 +1,3 @@ - import { buildStatus } from 'pl-fe/jest/factory'; import { diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index 85772d2c3..56a476de8 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -8378,10 +8378,10 @@ pkg-types@^1.0.3: mlly "^1.2.0" pathe "^1.1.0" -pl-api@^0.0.25: - version "0.0.25" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.25.tgz#d950d902c4bfe268d9de66611372dbd589939ca4" - integrity sha512-gBS/5aN47w0ZcE7I0gBQMkngMwB9DSHvH40dM5XsZGPzUw7f3VECHM+tZyTlZI13rdVC9xJlVQTPX1h9KmGUOg== +pl-api@^0.0.26: + version "0.0.26" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-0.0.26.tgz#82b20fa0500a22efaae643782ac917c725eef4ff" + integrity sha512-vbH11YmElHNpQZWM5G6nvgyQDp4q+G6IoMKqa7ek156UbuDBuZx/de2LYjlCJQ9nGtTzwNoOYRdtbLcshDKyiw== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"