[Bug] ZAF // Ticket sidebar // "app.activated" not triggered on load
When running the following code in a Ticket Sidebar (example by Eric Nelson here)
var zafClient = ZAFClient.init();
zafClient.on("app.registered", e => {
zafClient.context().then(function (context) {
console.log(`DEBUG ${zafClient._context["location"]} app.registered`, context.ticketId);
})
zafClient.on("app.activated", function () {
zafClient.context().then(function (context) {
console.log(`DEBUG ${zafClient._context["location"]} app.activated`, context.ticketId);
})
})
});
It seems that 'app.activated' is being fired only when the instance is transitioning from inactive to active. Meaning that on the first load, one cannot infer whether an instance is active or not.
I considered the option that the initial state is "active" and therefore activation is not being announced on load. However, in the case of multiple registered sidebar instances and then refresh (clicking on the button above the apps), all apps are being registered, even though only one is actually active. From my understanding, in that case, there's no way to know if a given instance is active. Or did I get something wrong?
IMHO, there are three solutions for this conundrum:
- Announce 'app.activated' on load.
- Do not register the instance if it's inactive.
- Add an 'isActive' property (similar to 'isCollapsed') to allow getting the correct initial state.
For me - #1 seems in accordance to the docs but #3 the most backward compatible (if that's what you're after)
All the best
-
Hey Eran,
Seems there might be a bit of confusion here. This is covered in our documentation that app.activated in terms of the sidebar location happens when "the app becomes active when the user switches to the tab containing this instance of your app." so all apps in the sidebar are "active" when this happens of the tab being viewed. What is it you are trying to accomplish?
-
Hi Eric! Thank you for your answer, I really appreciate the quick response
Simply put - I want to track if a given instance is active or not (i.e if the ticket is now open or not). I use it to inform the top_bar & the backend the current active ticket
And for that purpose, the "app.activated" and "app.deactivated" events works perfectly. However, it's impossible to know the initial state (i.e whether it's active or not on launch)
Thanks again, Eran
Iniciar sesión para dejar un comentario.
2 Comentarios