summaryrefslogtreecommitdiff
path: root/helpers.rb
diff options
context:
space:
mode:
authorpdp8 <pdp8@pdp8.info>2023-07-17 21:00:10 +0200
committerpdp8 <pdp8@pdp8.info>2023-07-17 21:00:10 +0200
commit8596528d9c0c07cc46279679f61729a3c06d902e (patch)
tree7fe1dd60cffddbe74488c360c119b87a5b125da1 /helpers.rb
parent4ca1c5555f18703d1dac673b1a77d1c919fb4787 (diff)
client (un)follow fixed
Diffstat (limited to 'helpers.rb')
-rw-r--r--helpers.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/helpers.rb b/helpers.rb
index 84f6a89..3e24b82 100644
--- a/helpers.rb
+++ b/helpers.rb
@@ -83,13 +83,12 @@ helpers do
json = f.read
collection = JSON.parse(json)
objects.each do |object|
+ id = object['id'] || object
if delete
- collection['orderedItems'].delete_if { |o| o['id'] == object['id'] }
- modified = true
+ collection['orderedItems'].delete_if { |o| o['id'] == id or o == id }
else
ids = collection['orderedItems'].collect { |i| i['id'] }
- collection['orderedItems'] << object unless ids.include?(object['id'])
- modified = true
+ collection['orderedItems'] << object unless ids.include?(id) or collection['orderedItems'].include?(id)
end
end
collection['totalItems'] = collection['orderedItems'].size