diff options
author | Eric Bailey <git@esb.lol> | 2025-02-18 08:54:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-18 08:54:25 -0600 |
commit | a51fc8e434b63a3f85accbf1bd29a01397c4b057 (patch) | |
tree | 44be28fc8812c6d4e20f0784be3a558ede9283cb /src/state/messages | |
parent | e2c0f78719a9e576ad18ef0e4657c63a3147efed (diff) | |
download | voidsky-a51fc8e434b63a3f85accbf1bd29a01397c4b057.tar.zst |
`@atproto/api@next` integration (#7344)
* Bump SDK * Use consistent type in profile query * Omit from constraint for profile shadow * Replace isRecord with isValidRecord in QuoteEmbed * Omit type from constraint for old ProfileCard * Omit type from constraint in profile queries where appropriate * Use correct type for update profile mutation * Conslidate and fix check for isValidRecord in Post.tsx * Replace isRecord with isValidRecord in PostThreadItem * Remove redundant cast in PostThreadFollowBtn * Ignore errors in DebugMod screen * Use matching type in ProfileFollows screen * Use matching type in ProfileFollowers screen * Migrate to isValidRecord in PostFeedItem * Use matching type if PostRepostedBy * Omit type from constraint in avatar props * Use matching types in NotificationFeedItem * Todo * Use isValidRecord in NotfyFeedItem * Improve MediaPreview types * Migrate another isValidRecord in NotificationFeedItem * Migrate to isValidView in queries/util * Migrate to isValidRecord in threadgate/util * Fix types in threadgates * Fix up types in starter-packs queries * Todo * Specify exact types in search-posts * Use internal type util to align types * Ditto last * Migrate postgate/index * Specify exact types in post-thread * Use correct type in post-quotes * FIX potential bug in post-thread * Use correct type in post-feed * Add correct type guards to notifications/feed * Migrate a guard in notifications/util * Migrate guard in Wizard/State * [@next] Profile handling, migrate `ProfileCard` (#7347) * Introduce new utils for profiles, migrate old ProfileCard * Rename, reorg * Add parseEmbed utils * Expand AnyProfileView to include chat profile view, update post shadow to reflect this * Cast for perf reasons * Tighten up types now that we have AnyProfileView * Add fastIsType util * Use `assertDid` Co-authored-by: Matthieu Sieben <matthieusieben@users.noreply.github.com> * Use util types * Comment * Use fastIsType where no validation was happening before * suggestions (#7382) * suggestions * Revert unneeded changes --------- Co-authored-by: Eric Bailey <git@esb.lol> * Use new util * Rename to dangerousIsType * Convert object shape * Use dangerous util * Use dangerous util * Use dangerous util, we can trust post records * Use dangerous util * Use AnyProfileVIew * Convert object shape * Clean up handling * Patch moderateProfile to accept known profile views, to discuss * Add AnyStarterPackView and related, implement in first usage * Remove validation, fix type, fix ref * Migrate over list-conversations * Clarify intent behind precacheProfile and its unstable query cache * Clean up unstable profile cache * Fix types during label creation in PwiOptOut (#7346) * Tighten types in queries/list * Chat: use correct profile views * Chat: fix log type check * Chat: construct lexically correct shape, even though it's only internal usage * Chat: use correct profile types * Chat: fix type check in logs * Starter: use correct profile types * Starter: use correct profile types * Starter: tighten types to match lex * Any profile type will work in blocked-and-muted * Use dangerous util * Use dangerousIsType * Update new ProfileCard to use AnyProfileView * Use dangerousIsType * Remove outdated todo * Use correct profile type * Use correct profile types * Tighten up types * Use dangerousIsType * Chat: more type fixes * Remove unused file * Add a few utils * Remove unused file * Ignore feedPost.__source * Clean up types, leave validation in critical path * Use dangerousIstype * Use ANyProfileView * Use isValidRecord * Use dangerousIsType * Fix types in ListCard * Fix FeedInterstitials types * Fix types in FeedCard * Fix types in dms ReportDialog * Fix types in SearchablePeopleList * Fix bad type in composer opts * Starter: ok these need to be loose too * Clarify docs Co-authored-by: Matthieu Sieben <matthieusieben@users.noreply.github.com> * Less code Co-authored-by: Matthieu Sieben <matthieusieben@users.noreply.github.com> * Use package exports Co-authored-by: Matthieu Sieben <matthieusieben@users.noreply.github.com> * Use package exports * Bump sdk, update $Typed imports * Format * Format * Fix weird TS error * Remove patch * Beter name * It's memo, can validate * Tighten up parseEmbed, dogfood * Bump sdk * Use asPredicate * Loosen types a bit * use asPredicate * Fix types * Use asPredicate * Use asPredicate * Use asPredicate * Clean up upsertProfile types * Use asPredicate * Use Un util * Fix types * Use new AnyProfileView * Use dangerousIsType * Use asPredicate * Use asPredicate * Add fallback content-type to pass typecheck * Clean up upsertProfile types * Align types * Use dangerousIsType * Use dangerousIsType * Use asPredicate * Align types * Convert findLast * Align types * Just ignore type errors and use findLast * Rename atproto -> bsky * Add validate util * Fix type error * Loosen types * Export post * rename atp bsky * Remove unused code * minor changes * Bump deps * Fix types * Tighten back up loose check * Tighten back up loose check * Fix small bug * Update comment * Revert change --------- Co-authored-by: Matthieu Sieben <matthieusieben@users.noreply.github.com> Co-authored-by: Matthieu Sieben <matthieu.sieben@gmail.com>
Diffstat (limited to 'src/state/messages')
-rw-r--r-- | src/state/messages/convo/agent.ts | 23 | ||||
-rw-r--r-- | src/state/messages/convo/types.ts | 26 | ||||
-rw-r--r-- | src/state/messages/events/agent.ts | 7 |
3 files changed, 28 insertions, 28 deletions
diff --git a/src/state/messages/convo/agent.ts b/src/state/messages/convo/agent.ts index 91dd59813..eed44c757 100644 --- a/src/state/messages/convo/agent.ts +++ b/src/state/messages/convo/agent.ts @@ -1,6 +1,6 @@ import { - AppBskyActorDefs, BskyAgent, + ChatBskyActorDefs, ChatBskyConvoDefs, ChatBskyConvoGetLog, ChatBskyConvoSendMessage, @@ -80,8 +80,8 @@ export class Convo { convoId: string convo: ChatBskyConvoDefs.ConvoView | undefined - sender: AppBskyActorDefs.ProfileViewBasic | undefined - recipients: AppBskyActorDefs.ProfileViewBasic[] | undefined + sender: ChatBskyActorDefs.ProfileViewBasic | undefined + recipients: ChatBskyActorDefs.ProfileViewBasic[] | undefined snapshot: ConvoState | undefined constructor(params: ConvoParams) { @@ -463,7 +463,7 @@ export class Convo { throw new Error('Convo: could not find recipients in convo') } - const userIsDisabled = this.sender.chatDisabled as boolean + const userIsDisabled = Boolean(this.sender.chatDisabled) if (userIsDisabled) { this.dispatch({event: ConvoDispatchEvent.Disable}) @@ -529,8 +529,8 @@ export class Convo { private pendingFetchConvo: | Promise<{ convo: ChatBskyConvoDefs.ConvoView - sender: AppBskyActorDefs.ProfileViewBasic | undefined - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic | undefined + recipients: ChatBskyActorDefs.ProfileViewBasic[] }> | undefined async fetchConvo() { @@ -538,8 +538,8 @@ export class Convo { this.pendingFetchConvo = new Promise<{ convo: ChatBskyConvoDefs.ConvoView - sender: AppBskyActorDefs.ProfileViewBasic | undefined - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic | undefined + recipients: ChatBskyActorDefs.ProfileViewBasic[] }>(async (resolve, reject) => { try { const response = await networkRetry(2, () => { @@ -704,7 +704,7 @@ export class Convo { * If there's a rev, we should handle it. If there's not a rev, we don't * know what it is. */ - if (typeof ev.rev === 'string') { + if ('rev' in ev && typeof ev.rev === 'string') { const isUninitialized = !this.latestRev const isNewEvent = this.latestRev && ev.rev > this.latestRev @@ -1049,7 +1049,10 @@ export class Convo { * `getItems` is only run in "active" status states, where * `this.sender` is defined */ - sender: this.sender!, + sender: { + $type: 'chat.bsky.convo.defs#messageViewSender', + did: this.sender!.did, + }, }, nextMessage: null, prevMessage: null, diff --git a/src/state/messages/convo/types.ts b/src/state/messages/convo/types.ts index 9f1707c71..69e15acc4 100644 --- a/src/state/messages/convo/types.ts +++ b/src/state/messages/convo/types.ts @@ -1,6 +1,6 @@ import { - AppBskyActorDefs, BskyAgent, + ChatBskyActorDefs, ChatBskyConvoDefs, ChatBskyConvoSendMessage, } from '@atproto/api' @@ -147,8 +147,8 @@ export type ConvoStateUninitialized = { items: [] convo: ChatBskyConvoDefs.ConvoView | undefined error: undefined - sender: AppBskyActorDefs.ProfileViewBasic | undefined - recipients: AppBskyActorDefs.ProfileViewBasic[] | undefined + sender: ChatBskyActorDefs.ProfileViewBasic | undefined + recipients: ChatBskyActorDefs.ProfileViewBasic[] | undefined isFetchingHistory: false deleteMessage: undefined sendMessage: undefined @@ -159,8 +159,8 @@ export type ConvoStateInitializing = { items: [] convo: ChatBskyConvoDefs.ConvoView | undefined error: undefined - sender: AppBskyActorDefs.ProfileViewBasic | undefined - recipients: AppBskyActorDefs.ProfileViewBasic[] | undefined + sender: ChatBskyActorDefs.ProfileViewBasic | undefined + recipients: ChatBskyActorDefs.ProfileViewBasic[] | undefined isFetchingHistory: boolean deleteMessage: undefined sendMessage: undefined @@ -171,8 +171,8 @@ export type ConvoStateReady = { items: ConvoItem[] convo: ChatBskyConvoDefs.ConvoView error: undefined - sender: AppBskyActorDefs.ProfileViewBasic - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic + recipients: ChatBskyActorDefs.ProfileViewBasic[] isFetchingHistory: boolean deleteMessage: DeleteMessage sendMessage: SendMessage @@ -183,8 +183,8 @@ export type ConvoStateBackgrounded = { items: ConvoItem[] convo: ChatBskyConvoDefs.ConvoView error: undefined - sender: AppBskyActorDefs.ProfileViewBasic - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic + recipients: ChatBskyActorDefs.ProfileViewBasic[] isFetchingHistory: boolean deleteMessage: DeleteMessage sendMessage: SendMessage @@ -195,8 +195,8 @@ export type ConvoStateSuspended = { items: ConvoItem[] convo: ChatBskyConvoDefs.ConvoView error: undefined - sender: AppBskyActorDefs.ProfileViewBasic - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic + recipients: ChatBskyActorDefs.ProfileViewBasic[] isFetchingHistory: boolean deleteMessage: DeleteMessage sendMessage: SendMessage @@ -219,8 +219,8 @@ export type ConvoStateDisabled = { items: ConvoItem[] convo: ChatBskyConvoDefs.ConvoView error: undefined - sender: AppBskyActorDefs.ProfileViewBasic - recipients: AppBskyActorDefs.ProfileViewBasic[] + sender: ChatBskyActorDefs.ProfileViewBasic + recipients: ChatBskyActorDefs.ProfileViewBasic[] isFetchingHistory: boolean deleteMessage: DeleteMessage sendMessage: SendMessage diff --git a/src/state/messages/events/agent.ts b/src/state/messages/events/agent.ts index 01165256a..9244a4fa5 100644 --- a/src/state/messages/events/agent.ts +++ b/src/state/messages/events/agent.ts @@ -65,10 +65,7 @@ export class MessagesEventBus { const handle = (event: MessagesEventBusEvent) => { if (event.type === 'logs' && options.convoId) { const filteredLogs = event.logs.filter(log => { - if ( - typeof log.convoId === 'string' && - log.convoId === options.convoId - ) { + if ('convoId' in log && log.convoId === options.convoId) { return log.convoId === options.convoId } return false @@ -355,7 +352,7 @@ export class MessagesEventBus { * If there's a rev, we should handle it. If there's not a rev, we don't * know what it is. */ - if (typeof ev.rev === 'string') { + if ('rev' in ev && typeof ev.rev === 'string') { /* * We only care about new events */ |