Working single post rendering

This commit is contained in:
2026-02-17 07:43:51 +00:00
parent 63643f0f9a
commit eba5413c36
12 changed files with 70 additions and 34 deletions

View File

@@ -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);