mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-29 19:53:47 +02:00
improve add new dashboard behavior
This commit is contained in:
@@ -138,8 +138,23 @@ export const useDashboardStore = defineStore('dashboard', () => {
|
||||
return `dashboard-${Date.now()}-${Math.random().toString().slice(2, 8)}`;
|
||||
}
|
||||
|
||||
async function createDashboard(name = 'Dashboard') {
|
||||
function generateNextDashboardName(baseName = 'Dashboard') {
|
||||
const existingNames = new Set(
|
||||
dashboards.value.map((d) => d.name)
|
||||
);
|
||||
if (!existingNames.has(baseName)) {
|
||||
return baseName;
|
||||
}
|
||||
let n = 1;
|
||||
while (existingNames.has(`${baseName} ${n}`)) {
|
||||
n++;
|
||||
}
|
||||
return `${baseName} ${n}`;
|
||||
}
|
||||
|
||||
async function createDashboard(baseName = 'Dashboard') {
|
||||
const id = generateDashboardId();
|
||||
const name = generateNextDashboardName(baseName);
|
||||
const dashboard = {
|
||||
id,
|
||||
name,
|
||||
|
||||
Reference in New Issue
Block a user