Re-order to remove before adding when moving items.
This commit is contained in:
parent
62565e0887
commit
c26da1ed27
1 changed files with 9 additions and 6 deletions
|
@ -154,17 +154,17 @@ class WebsocketServer:
|
||||||
|
|
||||||
# SPECIAL CASE ALERT! We need to talk to two channels here.
|
# SPECIAL CASE ALERT! We need to talk to two channels here.
|
||||||
elif command == "MOVE":
|
elif command == "MOVE":
|
||||||
# TODO Should we trust the client with the item info?
|
|
||||||
|
|
||||||
# Tell the old channel to remove "weight"
|
# remove the exiting item first
|
||||||
extra += str(data["weight"])
|
self.channel_to_q[channel].put(
|
||||||
command = "REMOVE"
|
"{}REMOVE:{}".format(message, data["weight"])
|
||||||
|
)
|
||||||
|
|
||||||
|
# Now hijack to send the new add on the new channel.
|
||||||
|
|
||||||
# Now modify the item with the weight in the new channel
|
# Now modify the item with the weight in the new channel
|
||||||
new_channel = int(data["new_channel"])
|
new_channel = int(data["new_channel"])
|
||||||
self.logger.log.info(new_channel)
|
|
||||||
item = data["item"]
|
item = data["item"]
|
||||||
|
|
||||||
item["weight"] = int(data["new_weight"])
|
item["weight"] = int(data["new_weight"])
|
||||||
|
|
||||||
# If we're moving within the same channel, add 1 to the weight, since we're adding the new item before we remove the old one, UI gave us the weight expected after removing.
|
# If we're moving within the same channel, add 1 to the weight, since we're adding the new item before we remove the old one, UI gave us the weight expected after removing.
|
||||||
|
@ -175,6 +175,9 @@ class WebsocketServer:
|
||||||
self.channel_to_q[new_channel].put(
|
self.channel_to_q[new_channel].put(
|
||||||
"WEBSOCKET:ADD:" + json.dumps(item))
|
"WEBSOCKET:ADD:" + json.dumps(item))
|
||||||
|
|
||||||
|
# Don't bother, we should be done.
|
||||||
|
return
|
||||||
|
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
self.logger.log.exception(
|
self.logger.log.exception(
|
||||||
"Error decoding extra data {} for command {} ".format(
|
"Error decoding extra data {} for command {} ".format(
|
||||||
|
|
Loading…
Reference in a new issue