-
Notifications
You must be signed in to change notification settings - Fork 408
-
This is my situation: I am using useDatabaseListData() but the subscription is no active until some data is in the database.
How I can say, "keep watching this subscription until some data show and render the data"
function Showmessages(messagesmetada) {
if (typeof (messagesmetada.messagesmetada.user) !== 'undefined') { var gameid = messagesmetada.messagesmetada.gameid; }
var database = useDatabase();
var querypath = '/messages/' + gameid;
const messagesRef = ref(database, querypath);
const { status, data: messages } = useDatabaseListData(messagesRef);
if (typeof (messages) !== 'undefined')
{ var messagessortedtimestamp=messages.sort((a, b) => { return a.timestamp - b.timestamp; })}
if (status === 'success') {
return (<div>
<table className="table">
<thead>
{table_game_chatboard.map(header => {
return (
<tr key={header.id}><th>{header.first_col}</th><th>{header.second_col}</th><th>{header.third_col}</th><th>{header.fourth_col}</th>
</tr>
)
})}
</thead>
<tbody>
{messagessortedtimestamp.map(message => {
var datetime_temp = new Date(message.timestamp);
var date_temp = datetime_temp.getDate() + "/" + (datetime_temp.getMonth() + 1) + "/" + datetime_temp.getFullYear();
var time_temp = datetime_temp.getHours() + ":" + datetime_temp.getMinutes() + ":" + datetime_temp.getSeconds();
return (
<tr key={message.id} ><td >{message.author}</td><td>{message.text}</td><td>{date_temp}</td><td>{time_temp}</td>
</tr>
)
})}
</tbody>
</table>
</div>
)
}
if (status === 'loading') {
return <span>Loading...</span>;
}
;
}
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
Team, I need a light on this, I no sure if this is a case of bad implementation from my side. Now I solved this with a trick in the side of the database with a blank entry, and I simulate and I activate the subscription, and all works nicely. But I need to figure out if I have a solution without this trick.
Beta Was this translation helpful? Give feedback.
All reactions
-
I was no able to solve this , I used a initial dummy data to activate the subcription .
Beta Was this translation helpful? Give feedback.