We are all entitled to be negative every once in a while, but if there is someone who is draining your energy every time you see them, then I feel you need to take a step back, that's what self care is all about.
Me, I try to plant little seeds, make some suggestions, maybe even be honest and explain why I have to just let that person go. I have in the past.
But you do need to put yourself first, that is a lesson that took me quite a while to take on board. xxxx
Sometimes helping negative people (trying to) can become a positive thing for an individual, however there's a threshold as @papilloncharity says in another comment here. When anything affects a person (ourselves) negatively then it's time to release it. That's just my opinion though, I know others think differently.
As you say, it can take some time to learn that lesson, but the sooner the better because we don't have all that much time when one looks at life objectively.