Use existing profile data to handle blocks
This commit is contained in:
@@ -814,7 +814,13 @@ export class Convo {
|
|||||||
switch (e.message) {
|
switch (e.message) {
|
||||||
case 'block between recipient and sender':
|
case 'block between recipient and sender':
|
||||||
this.pendingMessageFailure = 'unrecoverable'
|
this.pendingMessageFailure = 'unrecoverable'
|
||||||
this.emitter.emit('event', {type: 'sync-convo-state'})
|
this.emitter.emit('event', {
|
||||||
|
type: 'invalidate-block-state',
|
||||||
|
accountDids: [
|
||||||
|
this.sender!.did,
|
||||||
|
...this.recipients!.map(r => r.did),
|
||||||
|
],
|
||||||
|
})
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
logger.warn(
|
logger.warn(
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, {useContext, useState, useSyncExternalStore} from 'react'
|
import React, {useContext, useState, useSyncExternalStore} from 'react'
|
||||||
import {AppState} from 'react-native'
|
import {AppState} from 'react-native'
|
||||||
import {useFocusEffect, useIsFocused} from '@react-navigation/native'
|
import {useFocusEffect, useIsFocused} from '@react-navigation/native'
|
||||||
|
import {useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {Convo} from '#/state/messages/convo/agent'
|
import {Convo} from '#/state/messages/convo/agent'
|
||||||
import {
|
import {
|
||||||
@@ -13,6 +14,8 @@ import {
|
|||||||
import {isConvoActive} from '#/state/messages/convo/util'
|
import {isConvoActive} from '#/state/messages/convo/util'
|
||||||
import {useMessagesEventBus} from '#/state/messages/events'
|
import {useMessagesEventBus} from '#/state/messages/events'
|
||||||
import {useMarkAsReadMutation} from '#/state/queries/messages/conversation'
|
import {useMarkAsReadMutation} from '#/state/queries/messages/conversation'
|
||||||
|
import {RQKEY as ListConvosQueryKey} from '#/state/queries/messages/list-converations'
|
||||||
|
import {RQKEY as createProfileQueryKey} from '#/state/queries/profile'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
|
||||||
export * from '#/state/messages/convo/util'
|
export * from '#/state/messages/convo/util'
|
||||||
@@ -52,6 +55,7 @@ export function ConvoProvider({
|
|||||||
children,
|
children,
|
||||||
convoId,
|
convoId,
|
||||||
}: Pick<ConvoParams, 'convoId'> & {children: React.ReactNode}) {
|
}: Pick<ConvoParams, 'convoId'> & {children: React.ReactNode}) {
|
||||||
|
const queryClient = useQueryClient()
|
||||||
const isScreenFocused = useIsFocused()
|
const isScreenFocused = useIsFocused()
|
||||||
const {getAgent} = useAgent()
|
const {getAgent} = useAgent()
|
||||||
const events = useMessagesEventBus()
|
const events = useMessagesEventBus()
|
||||||
@@ -81,12 +85,19 @@ export function ConvoProvider({
|
|||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
return convo.on(event => {
|
return convo.on(event => {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'sync-convo-state': {
|
case 'invalidate-block-state': {
|
||||||
console.log('SYNC')
|
for (const did of event.accountDids) {
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: createProfileQueryKey(did),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
queryClient.invalidateQueries({
|
||||||
|
queryKey: ListConvosQueryKey,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}, [convo])
|
}, [convo, queryClient])
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
const handleAppStateChange = (nextAppState: string) => {
|
const handleAppStateChange = (nextAppState: string) => {
|
||||||
|
|||||||
@@ -211,5 +211,6 @@ export type ConvoState =
|
|||||||
| ConvoStateError
|
| ConvoStateError
|
||||||
|
|
||||||
export type ConvoEvent = {
|
export type ConvoEvent = {
|
||||||
type: 'sync-convo-state'
|
type: 'invalidate-block-state'
|
||||||
|
accountDids: string[]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user