Skip to content

Commit

Permalink
Merge branch 'register_modifier' of https://github.com/zincware/ZnDraw
Browse files Browse the repository at this point in the history
…into register_modifier
  • Loading branch information
PythonFZ committed Oct 27, 2023
2 parents 4d31ced + ee0a4e5 commit 19b0d6e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions zndraw/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,11 @@ def connect():
except KeyError:
app.config["ROOM_HOSTS"][token] = [request.sid]

emit(
"webclient:available", request.sid, to=app.config["DEFAULT_PYCLIENT"]
)
emit("webclient:available", request.sid, to=app.config["DEFAULT_PYCLIENT"])

data = {"modifiers": []} # {schema: ..., name: ...}
data = {"modifiers": []} # {schema: ..., name: ...}
for name, schema in app.config["MODIFIER"]["default_schema"].items():
data["modifiers"].append({"schema": schema, "name": name})
data["modifiers"].append({"schema": schema, "name": name})

emit("modifier:register", data, to=app.config["DEFAULT_PYCLIENT"])

Expand Down Expand Up @@ -485,12 +483,14 @@ def modifier_register(data):
# we can only register one modifier at a time
name = data["modifiers"][0]["name"]
if name in app.config["MODIFIER"]:
# issue with the same modifier name on different webclients / tokens!
# only for default we need to ensure, there is only one.
raise ValueError(f"Modifier {name} is already registered.")
# issue with the same modifier name on different webclients / tokens!
# only for default we need to ensure, there is only one.
raise ValueError(f"Modifier {name} is already registered.")
app.config["MODIFIER"][name] = request.sid
if data["modifiers"][0]["default"]:
app.config["MODIFIER"]["default_schema"][name] = data["modifiers"][0]["schema"]
app.config["MODIFIER"]["default_schema"][name] = data["modifiers"][0][
"schema"
]
except KeyError:
print("Could not identify the modifier name.")

Expand Down

0 comments on commit 19b0d6e

Please sign in to comment.