Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ const QUALITY_LEDGER_KEY = STORAGE_KEY_PREFIX + "quality-ledger";
const AUTOMATION_PIPELINE_KEY = STORAGE_KEY_PREFIX + "automation-pipeline";
const SESSION_STATE_KEY = STORAGE_KEY_PREFIX + 'active-session';

console.debug('APP JS loaded');

function saveActiveSession(accountId, viewId) {
try {
const payload = { accountId, lastView: viewId || '', timestamp: Date.now() };
Expand Down Expand Up @@ -71,7 +69,6 @@ function isViewValidForRole(viewId, role) {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('service-worker.js')
.then(reg => {
console.info('☁️ ReGenX SW v3 Registered');
window._swReg = reg;

// Listen for Background Sync completion messages from SW
Expand Down Expand Up @@ -5345,8 +5342,6 @@ if ('serviceWorker' in navigator) {
window.addEventListener('load', async () => {
try {
const registration = await navigator.serviceWorker.register('/service-worker.js');

console.info('Service Worker registered:', registration.scope);
} catch (error) {
console.error('Service Worker registration failed:', error);
}
Expand Down
8 changes: 0 additions & 8 deletions src/cloud-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,9 @@ export const CloudSync = {
if (!CloudSync.client || !CloudSync.config) return;

const channel = `databases.${CloudSync.config.databaseId}.collections.${CloudSync.config.ordersCollectionId}.documents`;
console.debug(`📡 Subscribed to Appwrite Realtime: ${channel}`);

try {
CloudSync.unsubscribe = CloudSync.client.subscribe(channel, response => {
console.debug("⚡ Appwrite Realtime Event Received:", response);

const syncedOrder = response.payload;
if (!syncedOrder || !syncedOrder.id) return;
Expand All @@ -235,7 +233,6 @@ export const CloudSync = {
localOrder.riderName !== syncedOrder.riderName;

if (hasChanged) {
console.log(`🔄 Synced order [${syncedOrder.id}] has changes. Saving locally.`);

const originalLive = CloudSync.isLive;
CloudSync.isLive = false;
Expand Down Expand Up @@ -325,7 +322,6 @@ export const CloudSync = {
payload.id,
sanitizedDoc
);
console.log(`☁️ Synced to Appwrite (Updated) -> Collection [${ordersCollectionId}]`, sanitizedDoc);
} catch (updateErr) {
if (updateErr.code === 404) {
await CloudSync.databases.createDocument(
Expand All @@ -334,7 +330,6 @@ export const CloudSync = {
payload.id,
sanitizedDoc
);
console.log(`☁️ Synced to Appwrite (Created) -> Collection [${ordersCollectionId}]`, sanitizedDoc);
} else {
throw updateErr;
}
Expand Down Expand Up @@ -461,7 +456,6 @@ export const CloudSync = {
const filtered = queue.filter(item => item.key !== key);
filtered.push({ key, data, ts: Date.now() });
localStorage.setItem('regenx-offline-queue', JSON.stringify(filtered));
console.debug(`[CloudSync] Queued offline write for key: ${key}`);
} catch (e) {
console.warn('[CloudSync] Failed to queue offline write:', e);
}
Expand All @@ -482,7 +476,6 @@ export const CloudSync = {
try {
const queue = JSON.parse(localStorage.getItem('regenx-offline-queue') || '[]');
if (queue.length === 0) return;
console.log(`[CloudSync] Flushing ${queue.length} offline queued writes...`);
const failed = [];
for (const item of queue) {
try {
Expand Down Expand Up @@ -547,7 +540,6 @@ export const CloudSync = {
}

CloudSync.renderSyncBadge('live', 'Cloud Live');
console.log(`☁️ Hydrated from cloud: account + ${cloudOrders.length} orders`);

// Refresh the current dashboard view with fresh data
window.refreshCurrentView?.(true);
Expand Down
3 changes: 0 additions & 3 deletions src/conflict-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
export function resolveConflict(localAction, serverData) {
// If no server data exists, local action wins
if (!serverData) {
console.debug(`[ConflictResolver] No server data — local action applied: ${localAction.id}`);
return localAction;
}

Expand All @@ -36,7 +35,6 @@ export function resolveConflict(localAction, serverData) {
return null;
}

console.debug(`[ConflictResolver] Local action is newer — applying: ${localAction.id}`);
return localAction;
}

Expand Down Expand Up @@ -85,7 +83,6 @@ export function mergeGPSUpdates(actions) {
current.timestamp > latest.timestamp ? current : latest
);

console.debug(`[ConflictResolver] Merged ${gpsActions.length} GPS actions → 1 kept`);
return [...otherActions, latestGPS];
}

Expand Down
6 changes: 0 additions & 6 deletions src/offline-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function initOfflineDB() {

request.onsuccess = (event) => {
db = event.target.result;
console.info('[OfflineSync] IndexedDB initialized');
resolve(db);
};

Expand Down Expand Up @@ -87,7 +86,6 @@ export function queueOfflineAction(type, payload) {
const request = store.add(action);

request.onsuccess = () => {
console.log(`[OfflineSync] Action queued: ${type} (${action.id})`);
updateSyncUI('pending');
resolve(action.id);
};
Expand Down Expand Up @@ -147,14 +145,12 @@ export async function syncPendingActions() {
return;
}

console.log(`[OfflineSync] Syncing ${actions.length} pending actions...`);
updateSyncUI('syncing');

for (const action of actions) {
try {
await processAction(action);
await removeAction(action.id);
console.log(`[OfflineSync] Synced: ${action.type} (${action.id})`);
} catch (error) {
console.warn(`[OfflineSync] Failed to sync: ${action.id}`, error);
await handleRetry(action);
Expand Down Expand Up @@ -260,13 +256,11 @@ export function updateSyncUI(status) {
*/
export function setupNetworkListeners() {
window.addEventListener('online', async () => {
console.log('[OfflineSync] Back online — starting sync...');
showOfflineBanner(false);
await syncPendingActions();
});

window.addEventListener('offline', () => {
console.log('[OfflineSync] Gone offline');
showOfflineBanner(true);
updateSyncUI('pending');
});
Expand Down