From 8596528d9c0c07cc46279679f61729a3c06d902e Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 17 Jul 2023 21:00:10 +0200 Subject: client (un)follow fixed --- helpers.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'helpers.rb') 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 -- cgit v1.2.3