I’m building an app where Users can save Events. I have a “Save Event” button that I want to use for both saving and un-saving an event.
(I’m using conditional statements to change the color and text of the button, depending on if the event if saved in the User’s List of Saved Events or not, so that the “Save Event” button turns into an “Remove Event” button depending on whether or not the User has saved the Event.)
If the user clicks the button and they DON’T already have the event saved, I want to add the event to their List of Saved Events. If they click the button and they DO already have the event saved, I want to remove the event from their List of Saved Events.
The Workflow that I’ve tried looks like this:
- Check to see if Event is in User’s List of Saved Events. If it isn’t, then add it.
- Check to see if Event is in Users’s List of Saved Events. If it is, then remove it.
The problem is that I want to only do one of those operations, but currently in the Workflow they run in sequence, which means that the event gets added (because it doesn’t exist) and then removed immediately afterwards (because now it does exist).
I can do this using custom states on the page, and I can also do it by show/hiding two different buttons, but ideally I want to do it in a simple Workflow using a single button so that I can easily create an isolated reusable element.
Does anyone know how to do this kind of “add if not exists, remove if exists” logic in the simplest / cleanest way?
Thank you!