While developing a website using angular-meteor, I encountered an unusual issue. Each page on my site features a chat block where messages are stored in the chatMessages collection and displayed correctly. However, whenever I modify the current user (either manually editing the MongoDB document or updating it within meteor's method), all subscriptions in my app are removed. This results in the disappearance of messages from the chat. In an attempt to diagnose the problem, I referred to this code snippet, but I find it quite difficult to grasp. Here are some noteworthy excerpts from the browser console output:
// Upon page load
send Object {
msg: "sub",
id: "EPgQwMiDggM7wafCN",
name: "chatMessages",
params: Array[0]
}
receive Object {
msg: "added",
collection: "chatMessages",
id: "G6tv76ZSJYXmnsrAY",
fields: Object
}
// Calling 'createArenaRoom' method
send Object {
msg: "method",
method: "createArenaRoom",
params: Array[1],
id: "8",
randomSeed: "516b5128615f1c7849f2"
}
// User updated
receive Object {
msg: "changed",
collection: "users",
id: "sQnaLPj2FvH692rQM",
fields: Object
}
// ??? WHY ????
send Object {
msg: "unsub",
id: "EPgQwMiDggM7wafCN"
}
receive Object {
msg: "removed",
collection: "chatMessages",
id: "G6tv76ZSJYXmnsrAY"
}
receive Object {
msg: "nosub",
id: "EPgQwMiDggM7wafCN"
}
It is important to note that the data is not actually deleted from MongoDB. Simply refreshing the page brings back the chat messages and other content.
I would greatly appreciate any assistance with this matter.