mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-16 05:13:06 +00:00
Update last tab instead of create new (#6817)
Signed-off-by: Kristina Fefelova <kristin.fefelova@gmail.com>
This commit is contained in:
parent
39cc7dc280
commit
2f5efd9560
@ -184,27 +184,24 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
async function initCurrentTab (tabs: WorkbenchTab[]): Promise<void> {
|
async function initCurrentTab (tabs: WorkbenchTab[]): Promise<void> {
|
||||||
if (tabs.length === 0) {
|
const tab = tabs.find((t) => t._id === $tabIdStore)
|
||||||
const loc = getCurrentLocation()
|
const loc = getCurrentLocation()
|
||||||
|
const tabLoc = tab ? getTabLocation(tab) : undefined
|
||||||
const _id = await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
|
const isLocEqual = tabLoc ? areLocationsEqual(loc, tabLoc) : false
|
||||||
attachedTo: account._id,
|
if (!isLocEqual) {
|
||||||
location: locationToUrl(loc),
|
const url = locationToUrl(loc)
|
||||||
isPinned: false
|
const tabByUrl = tabs.find((t) => t.location === url)
|
||||||
})
|
if (tabByUrl !== undefined) {
|
||||||
prevTab = _id
|
prevTab = tabByUrl._id
|
||||||
selectTab(_id)
|
selectTab(tabByUrl._id)
|
||||||
} else {
|
} else {
|
||||||
const tab = tabs.find((t) => t._id === $tabIdStore)
|
const tabToReplace = tabs.findLast((t) => !t.isPinned)
|
||||||
const loc = getCurrentLocation()
|
if (tabToReplace !== undefined) {
|
||||||
const tabLoc = tab ? getTabLocation(tab) : undefined
|
await client.update(tabToReplace, {
|
||||||
const isLocEqual = tabLoc ? areLocationsEqual(loc, tabLoc) : false
|
location: url
|
||||||
if (!isLocEqual) {
|
})
|
||||||
const url = locationToUrl(loc)
|
prevTab = tabToReplace._id
|
||||||
const tabByUrl = tabs.find((t) => t.location === url)
|
selectTab(tabToReplace._id)
|
||||||
if (tabByUrl !== undefined) {
|
|
||||||
prevTab = tabByUrl._id
|
|
||||||
selectTab(tabByUrl._id)
|
|
||||||
} else {
|
} else {
|
||||||
const _id = await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
|
const _id = await client.createDoc(workbench.class.WorkbenchTab, core.space.Workspace, {
|
||||||
attachedTo: account._id,
|
attachedTo: account._id,
|
||||||
|
Loading…
Reference in New Issue
Block a user