You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
useEffect(()=>{if(!userStore.currentUser)returnconstclient=generateClient<Schema>({authMode: "userPool"})constsub=client.models.Message.observeQuery({filter: {and: [{senderId: {eq: userStore.currentUser.id}},{viewedTimestamp: {attributeExists: false}},],},selectionSet: [...messageSelectionSet],}).subscribe({next: ({ items, isSynced })=>{console.log(`Detected [${items.length}] messages are awaiting me to view:`,// JSON.stringify(items, null, 4),)},error: ({ error })=>console.log("Create subscriptions error",JSON.stringify(error.errors,null,4)),})return()=>{sub.unsubscribe()}},[userStore.currentUser?.id])
Upon loading, I see the logs: "Detected [4] messages awaiting me to view". but from that point on, I'm not seeing the logs appear when things are viewed or deleted. The other user on the client side will call client.models.Message.create({...}) and create a message correctly.
Expected behavior
I would expect that if a message is created by another user with me as the sender, I would immediately get a new log appearing that says: "Detected [5] messages are awaiting me to view". But nothing happens client side.
Yes, I accidentally deleted that when I was simplifying the schema for replicating, good catch! I fixed it!
I just did that using this, and it did not work:
useEffect(()=>{if(!userStore.currentUser)returnconstclient=generateClient<Schema>({authMode: "userPool"})constsub=client.models.Message.observeQuery({filter: {receiverId: {eq: userStore.currentUser.id}},// I also tried various other filters with the same result (I also tried leaving filter blank but that resulted in a crash)selectionSet: [...messageSelectionSet],}).subscribe({next: ({ items, isSynced })=>{console.log("UPDATE DETECTED",items.length,isSynced)},error: ({ error })=>console.log("Create subscriptions error",JSON.stringify(error.errors,null,4)),})return()=>{sub.unsubscribe()}},[userStore.currentUser?.id])
I basically get:
UPDATE DETECTED 3 true
on mount, but it never runs again. With another logged in user I run a client.models.Message.create({ ... }) with receiverId set to this particular user, and I would expect to immediately see a log appear UPDATE DETECTED 4 true or whatever, but I never get that.
I have not tried in the AppSync console but I can. I am creating a DynamoDB node with another client, which should effectively be doing the same thing right?
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify Gen 2
Environment information
Describe the bug
I subscribe to a messages like so:
Upon loading, I see the logs: "Detected [4] messages awaiting me to view". but from that point on, I'm not seeing the logs appear when things are viewed or deleted. The other user on the client side will call
client.models.Message.create({...})
and create a message correctly.Expected behavior
I would expect that if a message is created by another user with me as the sender, I would immediately get a new log appearing that says: "Detected [5] messages are awaiting me to view". But nothing happens client side.
Reproduction steps
Here is a schema:
Code Snippet
Shown above.
Log output
aws-exports.js
N/A
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: