mirror of
https://gitlab.com/wgp/dougal/software.git
synced 2025-12-06 10:27:09 +00:00
Add notification handlers to Map.
They reload any sequence data on notification of changes.
This commit is contained in:
@@ -1310,6 +1310,55 @@ export default {
|
|||||||
return arr.buffer;
|
return arr.buffer;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async handleSequences (context, {payload}) {
|
||||||
|
if (payload.pid != this.$route.params.project) {
|
||||||
|
console.warn(`${this.$route.params.project} ignoring notification for ${payload.pid}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("handleSequences (Map)", payload);
|
||||||
|
|
||||||
|
if (payload.old?.sequence) {
|
||||||
|
console.log(`Remove sequence ${payload.old.sequence} from data`);
|
||||||
|
this.sequenceDataElements = this.sequenceDataElements.filter( el => el.sequence != payload.old.sequence );
|
||||||
|
if (window.caches) {
|
||||||
|
const cache = await caches.open("dougal");
|
||||||
|
const rx = new RegExp(`/project/${this.$route.params.project}/sequence/${payload.old.sequence}(\\?.*)?$`);
|
||||||
|
const keys = await cache.keys();
|
||||||
|
for (const req of keys) {
|
||||||
|
if (rx.test(req.url)) {
|
||||||
|
console.log(`Removing ${req.url} from cache`);
|
||||||
|
cache.delete(req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (payload.new?.sequence) {
|
||||||
|
console.log(`Add sequence ${payload.new.sequence} to data`);
|
||||||
|
this.getSequenceData([payload.new.sequence]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
registerNotificationHandlers (action = "registerHandler") {
|
||||||
|
|
||||||
|
["raw_lines", "raw_shots", "final_lines", "final_shots"].forEach( table => {
|
||||||
|
this.$store.dispatch(action, {
|
||||||
|
table,
|
||||||
|
|
||||||
|
handler: (context, message) => {
|
||||||
|
this.handleSequences(context, message);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
unregisterNotificationHandlers () {
|
||||||
|
this.registerNotificationHandlers("unregisterHandler");
|
||||||
|
},
|
||||||
|
|
||||||
...mapActions(["api"])
|
...mapActions(["api"])
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -1403,8 +1452,14 @@ export default {
|
|||||||
this.isFullscreen = !!document.fullscreenElement;
|
this.isFullscreen = !!document.fullscreenElement;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.registerNotificationHandlers();
|
||||||
|
|
||||||
//this.layerSelection = [ "seq" ];
|
//this.layerSelection = [ "seq" ];
|
||||||
this.getSequenceData();
|
this.getSequenceData();
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeDestroy () {
|
||||||
|
this.unregisterNotificationHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user