fix(lua): event type field

This commit is contained in:
əlemi 2024-09-17 02:02:38 +02:00
parent 7d212c6f10
commit 13ef05f8a2
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 7 additions and 3 deletions

View file

@ -3,6 +3,7 @@ name: lua
on:
push:
branches:
- dev
- stable
permissions:

View file

@ -304,11 +304,14 @@ impl LuaUserData for CodempEvent {
fn add_fields<F: LuaUserDataFields<Self>>(fields: &mut F) {
fields.add_field_method_get("type", |_, this| match this {
CodempEvent::FileTreeUpdated(_) => Ok("filetree"),
CodempEvent::UserJoin(_) | CodempEvent::UserLeave(_) => Ok("user"),
CodempEvent::UserJoin(_) => Ok("join"),
CodempEvent::UserLeave(_) => Ok("leave"),
});
fields.add_field_method_get("value", |_, this| match this {
CodempEvent::FileTreeUpdated(x) => Ok(x.clone()),
CodempEvent::UserJoin(x) | CodempEvent::UserLeave(x) => Ok(x.clone()),
CodempEvent::FileTreeUpdated(x)
| CodempEvent::UserJoin(x)
| CodempEvent::UserLeave(x)
=> Ok(x.clone()),
});
}
}