feat: add troubleshooting side panel and advanced queue controls
- Implemented a global toggle to enable/disable background queue processing. - Added a Side Panel (Sidebar.html) to view pending edits. - Added per-item controls: 'Delete' to remove from queue, 'Push' to force update. - Updated 'onEditQueue.ts' with robust error handling for batch processing. - Updated documentation (README, ARCHITECTURE) to reflect new features. - Fixed 'clasp' deployment issues by cleaning up manifest management.
This commit is contained in:
@ -8,6 +8,7 @@ const LOCK_TIMEOUT_MS = 10 * 1000 // 10 seconds for lock acquisition
|
||||
const CACHE_KEY_EDITS = "pendingEdits"
|
||||
const CACHE_KEY_LAST_EDIT_TIME = "lastEditTime"
|
||||
const SCRIPT_PROPERTY_TRIGGER_SCHEDULED = "batchTriggerScheduled"
|
||||
export const SCRIPT_PROPERTY_QUEUE_ENABLED = "queueEnabled"
|
||||
|
||||
export function onEditQueue(e) {
|
||||
const sheet = e.source.getActiveSheet()
|
||||
@ -79,6 +80,13 @@ export function processBatchedEdits() {
|
||||
}
|
||||
|
||||
console.log(`Total SKUs in queue: ${pendingEdits.length}`)
|
||||
|
||||
const queueEnabled = scriptProperties.getProperty(SCRIPT_PROPERTY_QUEUE_ENABLED) !== "false"
|
||||
if (!queueEnabled) {
|
||||
console.log("Queue disabled, skipping processing.")
|
||||
return
|
||||
}
|
||||
|
||||
const now = Date.now()
|
||||
const toProcess = pendingEdits.filter(
|
||||
(edit) => now - edit.timestamp > BATCH_INTERVAL_MS
|
||||
@ -96,7 +104,11 @@ export function processBatchedEdits() {
|
||||
return
|
||||
}
|
||||
let p = new Product(edit.sku)
|
||||
p.UpdateShopifyProduct(shop)
|
||||
try {
|
||||
p.UpdateShopifyProduct(shop)
|
||||
} catch (err) {
|
||||
console.error(`Failed to update SKU ${edit.sku}: ${err.message}`)
|
||||
}
|
||||
})
|
||||
|
||||
pendingEdits = pendingEdits.filter(
|
||||
|
||||
Reference in New Issue
Block a user