@@ -10,17 +10,12 @@ import {
10
10
} from "@/features/conversation/conversation-requests-list/conversations-unknown-consent.query"
11
11
import { getConversationQueryData } from "@/features/conversation/queries/conversation.query"
12
12
import { getDmQueryData , setDmQueryData } from "@/features/dm/use-dm-query"
13
- import {
14
- IXmtpConversationId ,
15
- IXmtpConversationTopic ,
16
- IXmtpConversationWithCodecs ,
17
- IXmtpDmWithCodecs ,
18
- IXmtpInboxId ,
19
- } from "@/features/xmtp/xmtp.types"
13
+ import { IXmtpConversationId , IXmtpInboxId } from "@/features/xmtp/xmtp.types"
20
14
import { updateObjectAndMethods } from "@/utils/update-object-and-methods"
15
+ import { IConversationId , IConversationTopic } from "../conversation/conversation.types"
21
16
import {
22
17
setXmtpConsentStateForInboxId ,
23
- updateConsentForGroupsForAccount ,
18
+ updateConsentForGroupsForInbox ,
24
19
} from "../xmtp/xmtp-consent/xmtp-consent"
25
20
26
21
export function useAllowDmMutation ( ) {
@@ -29,17 +24,17 @@ export function useAllowDmMutation() {
29
24
return useMutation ( {
30
25
mutationFn : async ( args : {
31
26
peerInboxId : IXmtpInboxId
32
- conversationId : IXmtpConversationId
33
- topic : IXmtpConversationTopic
27
+ conversationId : IConversationId
28
+ topic : IConversationTopic
34
29
} ) => {
35
30
const { peerInboxId, conversationId } = args
36
31
if ( ! peerInboxId ) {
37
32
throw new Error ( "Peer inbox id not found" )
38
33
}
39
34
await Promise . all ( [
40
- updateConsentForGroupsForAccount ( {
35
+ updateConsentForGroupsForInbox ( {
41
36
clientInboxId : currentSenderInboxId ,
42
- groupIds : [ conversationId ] ,
37
+ groupIds : [ conversationId as unknown as IXmtpConversationId ] ,
43
38
consent : "allowed" ,
44
39
} ) ,
45
40
setXmtpConsentStateForInboxId ( {
@@ -55,19 +50,19 @@ export function useAllowDmMutation() {
55
50
} )
56
51
if ( conversation ) {
57
52
const updatedDm = updateObjectAndMethods ( conversation , {
58
- state : "allowed" ,
53
+ consentState : "allowed" ,
59
54
} )
60
55
61
56
setDmQueryData ( {
62
- ethAccountAddress : currentSenderInboxId ,
63
- inboxId : peerInboxId ,
64
- dm : updatedDm as IXmtpDmWithCodecs ,
57
+ targetInboxId : currentSenderInboxId ,
58
+ clientInboxId : peerInboxId ,
59
+ dm : updatedDm ,
65
60
} )
66
61
67
62
// Add to main conversations list
68
63
addConversationToAllowedConsentConversationsQuery ( {
69
64
inboxId : currentSenderInboxId ,
70
- conversation : updatedDm as IXmtpConversationWithCodecs ,
65
+ conversation : updatedDm ,
71
66
} )
72
67
73
68
// Remove from requests
@@ -76,35 +71,35 @@ export function useAllowDmMutation() {
76
71
topic,
77
72
} )
78
73
79
- return { previousDmConsent : conversation . state }
74
+ return { previousDmConsent : conversation . consentState }
80
75
}
81
76
} ,
82
77
onError : ( error , { topic, peerInboxId } , context ) => {
83
78
const { previousDmConsent } = context || { }
84
79
if ( previousDmConsent ) {
85
80
const dm = getDmQueryData ( {
86
- ethAccountAddress : currentSenderInboxId ,
87
- inboxId : peerInboxId ,
81
+ targetInboxId : currentSenderInboxId ,
82
+ clientInboxId : peerInboxId ,
88
83
} )
89
84
90
85
if ( ! dm ) {
91
86
return
92
87
}
93
88
94
89
const previousDm = updateObjectAndMethods ( dm , {
95
- state : previousDmConsent ,
90
+ consentState : previousDmConsent ,
96
91
} )
97
92
98
93
setDmQueryData ( {
99
- ethAccountAddress : currentSenderInboxId ,
100
- inboxId : peerInboxId ,
94
+ targetInboxId : currentSenderInboxId ,
95
+ clientInboxId : peerInboxId ,
101
96
dm : previousDm ,
102
97
} )
103
98
104
99
// Add back in requests
105
100
addConversationToUnknownConsentConversationsQuery ( {
106
101
inboxId : currentSenderInboxId ,
107
- conversation : previousDm as IXmtpConversationWithCodecs ,
102
+ conversation : previousDm ,
108
103
} )
109
104
110
105
// Remove from main conversations list
0 commit comments