Long explanation ahead, please bear with me. I'm ready to share all the necessary code to solve the problem, but I'm a bit lost on where to start. First, let me explain the issue at hand, and I would greatly appreciate any help from someone who can assist.
In my application using Vue/Vuex, an interesting (at least to me) problem has emerged: I have an Array
filled with Objects
of documents retrieved from a MySQL DB
. Each time a user selects one of these documents from a list, it gets moved from the documents Array
to the "Selected" Object of Objects
. It is then given a unique key
, which is the current route where the user is located. The structure looks something like this:
/machines/1/home : { }
Later on, if the user opens another tab, selects another document, etc., the "Selected" now appears as follows:
{/machines/1/home : { }, /machines/2/home : { }, /machines/3/home : { }}
Once all this is done, for each tab (identified by its current route), a distinct document is displayed. However, when the user closes the last tab, the document along with its key are successfully removed. But if they decide to close the second out of three tabs, everything falls apart because we end up with tabs 1 & 3 remaining in "Selected," while the routes of the tabs are still:
{/machines/1/home, /machines/2/home}
Therefore, what I'm wondering is: Is there a way to update the object keys still present in "Selected" to match the new tabs?