Working single post rendering
This commit is contained in:
14
static/db.js
14
static/db.js
@@ -147,12 +147,19 @@ export async function clearData(userID) {
|
||||
console.error('Error in opening database:', error);
|
||||
}
|
||||
}
|
||||
// TODO - this function can return before the data is stored!
|
||||
export async function addDataArray(userID, array) {
|
||||
try {
|
||||
const { db, transaction, store } = await getDBTransactionStore(userID, "readwrite");
|
||||
transaction.onerror = (event) => {
|
||||
console.error('Error in adding data:', event);
|
||||
};
|
||||
let completionPromise = new Promise((resolve, reject) => {
|
||||
transaction.oncomplete = (event) => {
|
||||
resolve();
|
||||
};
|
||||
transaction.onerror = (event) => {
|
||||
console.error('Error in adding data:', event);
|
||||
reject();
|
||||
};
|
||||
});
|
||||
// let count = 0;
|
||||
array.reverse();
|
||||
for (let data of array) {
|
||||
@@ -170,6 +177,7 @@ export async function addDataArray(userID, array) {
|
||||
// console.log(`Added ${count} posts...`);
|
||||
// }
|
||||
}
|
||||
return completionPromise;
|
||||
}
|
||||
catch (error) {
|
||||
console.error('Error in opening database:', error);
|
||||
|
||||
Reference in New Issue
Block a user