I finally went for separating the two buttons here into two separate functions, instead of using the one function and an if/else statement - that seems to work better although I did like having it all in one function; but on the upside I've gotten better at ternary operators I think?
Head into the source code to see all the stuff I commented out