diff --git a/connection.pike b/connection.pike index e2425b10..62e1870a 100644 --- a/connection.pike +++ b/connection.pike @@ -231,6 +231,11 @@ class channel(string name) { //name begins with hash and is all lower case } //Otherwise, keep the string exactly as-is. vars[var] = val; + if (val == "" && per_user) { + //Per-user variables don't need to store blank + m_delete(vars, var); + if (!sizeof(vars)) m_delete(fetcher("variables", name, "*"), (string)users[?user]); + } if (ephemeral) return val; //Ephemeral variables are not pushed out to listeners. //Notify those that depend on this. Note that an unadorned per-user variable is //probably going to behave bizarrely in a monitor, so don't do that; use either diff --git a/modules/http/chan_variables.pike b/modules/http/chan_variables.pike index 88857d6b..929128bc 100644 --- a/modules/http/chan_variables.pike +++ b/modules/http/chan_variables.pike @@ -204,8 +204,6 @@ void websocket_cmd_update(mapping(string:mixed) conn, mapping(string:mixed) msg) string var = "*" + replace(msg->id, "*|${}" / 1, ""); //TODO: Filter to existing variables according to the all_per_user set //Currently just filters by validity. - //TODO: If value == "", delete this user's instance of the variable. - //And if that leaves the user's mapping empty, remove it altogether. foreach (msg->per_user; string uid; string value) channel->set_variable(var, value, "set", (["": uid])); return;