forked from jsnbuchanan/crowd-funder-for-time-pwa
disable SQLite in Java & Swift (since they don't compile) & add SQL queueing on startup
At this point, the app compiles and runs in Android & iOS but DB operations fail.
This commit is contained in:
@@ -124,6 +124,7 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
||||
}
|
||||
|
||||
let lastCleanupDate: string | null = null;
|
||||
export let memoryLogs: string[] = [];
|
||||
|
||||
/**
|
||||
* Logs a message to the database with proper handling of concurrent writes
|
||||
@@ -136,6 +137,7 @@ export async function logToDb(message: string): Promise<void> {
|
||||
const nowKey = new Date().toISOString();
|
||||
|
||||
try {
|
||||
memoryLogs.push(`${new Date().toISOString()} ${message}`);
|
||||
// Try to insert first, if it fails due to UNIQUE constraint, update instead
|
||||
await platform.dbExec("INSERT INTO logs (date, message) VALUES (?, ?)", [
|
||||
nowKey,
|
||||
@@ -148,6 +150,9 @@ export async function logToDb(message: string): Promise<void> {
|
||||
const sevenDaysAgo = new Date(
|
||||
new Date().getTime() - 7 * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
memoryLogs = memoryLogs.filter(
|
||||
(log) => log.split(" ")[0] > sevenDaysAgo.toDateString(),
|
||||
);
|
||||
await platform.dbExec("DELETE FROM logs WHERE date < ?", [
|
||||
sevenDaysAgo.toDateString(),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user