Hello!
I had a little development break due to loosing the desk to the better halfs work for a month +
Now i have reclaimed, i am back with the struggle i was previously, i recently spent the time reading through the shopping list tutorial with firebase sent out and it has raised a question.
I am trying to add a marker to a calendar, so far trying to use a for loop in my callback advised elsewhere but this isn’t working 🙁 my code is;
FirebaseDatabase {
config: customConfig
onFirebaseReady: {
firebaseDb.getUserValue("dates", {
}
}, function(success, key, value) {
if(success) {
console.log(JSON.stringify(value))
// value here is JSON ARRAY
// value =[{"date":"2018-10-01T21:17:00.926"},{"date":"2018-10-02T12:00:00.000"}]
// so value[0].date ="2018-10-01T21:17:00.926"
//then you gonna insert here your dates in arrayFromFireBase as strings as follow
for(i=0 ; i < arrayFromFireBase.length-1 ; i++)
arrayFromFireBase.push(new Date(value[i].date).getTime())
}
})
}
}
Calendar {
...
style: CalendarStyle {
dayDelegate: Item {
...
Image {
// HERE WE MUST COMPARE TIME (we used Date.getTime()) FROM FIREBASE with the calendar's date converted to time also
visible: arrayFromFireBase.indexOf(styleData.date.getTime()) > -1
...
source: "qrc:/images/eventindicator.png"
}
}
}
}
Now like i say this doesn’t work, i’ve tried adapting, the code/loop in various ways, is it unable to read the date due to how it’s saved in firebase? when i read the JSON.stringify in the console log it’s human readable as shown in the code example but when i just log the value it appears as [object Object] (one for however many dates), now if i say try to push the JSON.stringify to another array for the for loop it still doesn’t work?
is it because of the “date” : key in firebase confusing the loop to not read the date? or should i format the date to unix epoch or would this not make a difference? i only want whole dates to be saved those not time periods, so when my app reads for example 24/11/18 it will mark that date?
Is there any immediate fixes you can see with this? alternatively would you say to scrap the for loop all together and work with an adapted dataModel as described in the tutortial