Current Method
type SessionOpenTab = {
id: string;
userId: string;
tabId: string;
focus: boolean;
order: number;
}
let mySessionOpenTabs: SessionOpenTab[] = [
{ id: "1", userId: "5", tabId: "5", focus: false, order: 0 },
{ id: "2", userId: "5", tabId: "1", focus: true, order: 1 },
{ id: "3", userId: "5", tabId: "3", focus: false, order: 2 },
]
Versus a Possible Improvement
type SessionOpenTabs = {
id: string;
userId: string;
focusTabId: string;
tabIdOrders: [number, string][]; // (preceding_index, actual_id)
// A tuple of the index that precedes the tab id and the id itself.
// This implies tab table must have an auto-incrementing index column.
}
let mySessionOpenTabs: SessionOpenTabs = {
id: "1",
userId: "5",
focusTabId: "1",
tabIdOrders: [
[-1, "5"] // The only one moved by the user to the top
]
}