fix: prevent persistent workspaces from being duplicated if they exist under a different name
This commit is contained in:
@ -65,11 +65,15 @@ Json::Value Workspaces::createMonitorWorkspaceData(std::string const &name,
|
|||||||
void Workspaces::createWorkspace(Json::Value const &workspace_data,
|
void Workspaces::createWorkspace(Json::Value const &workspace_data,
|
||||||
Json::Value const &clients_data) {
|
Json::Value const &clients_data) {
|
||||||
auto workspaceName = workspace_data["name"].asString();
|
auto workspaceName = workspace_data["name"].asString();
|
||||||
|
auto workspaceId = workspace_data["id"].asInt();
|
||||||
spdlog::debug("Creating workspace {}", workspaceName);
|
spdlog::debug("Creating workspace {}", workspaceName);
|
||||||
|
|
||||||
// avoid recreating existing workspaces
|
// avoid recreating existing workspaces
|
||||||
auto workspace =
|
auto workspace =
|
||||||
std::ranges::find_if(m_workspaces, [workspaceName](std::unique_ptr<Workspace> const &w) {
|
std::ranges::find_if(m_workspaces, [&](std::unique_ptr<Workspace> const &w) {
|
||||||
|
if (workspaceId > 0) {
|
||||||
|
return w->id() == workspaceId;
|
||||||
|
}
|
||||||
return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) ||
|
return (workspaceName.starts_with("special:") && workspaceName.substr(8) == w->name()) ||
|
||||||
workspaceName == w->name();
|
workspaceName == w->name();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user