When running the following code in a Ticket Sidebar (example by @eric27 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
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?