feat: avoid recreating workspaces
parent
193040c41e
commit
e845db84ad
|
@ -458,17 +458,16 @@ std::optional<std::string> Workspace::on_window_closed(WindowAddress &addr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspaces::create_workspace(Json::Value &workspace_data, const Json::Value &clients_data) {
|
void Workspaces::create_workspace(Json::Value &workspace_data, const Json::Value &clients_data) {
|
||||||
// replace the existing persistent workspace if it exists
|
// avoid recreating existing workspaces
|
||||||
auto workspace = std::find_if(
|
auto workspace = std::find_if(
|
||||||
workspaces_.begin(), workspaces_.end(), [&](std::unique_ptr<Workspace> const &x) {
|
workspaces_.begin(), workspaces_.end(), [&](std::unique_ptr<Workspace> const &x) {
|
||||||
auto name = workspace_data["name"].asString();
|
auto name = workspace_data["name"].asString();
|
||||||
return x->is_persistent() &&
|
return x->is_persistent() &&
|
||||||
((name.starts_with("special:") && name.substr(8) == x->name()) || name == x->name());
|
((name.starts_with("special:") && name.substr(8) == x->name()) || name == x->name());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (workspace != workspaces_.end()) {
|
if (workspace != workspaces_.end()) {
|
||||||
// replace workspace, but keep persistent flag
|
return;
|
||||||
workspaces_.erase(workspace);
|
|
||||||
workspace_data["persistent"] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create new workspace
|
// create new workspace
|
||||||
|
|
Loading…
Reference in New Issue