Hi. Its your non use of liquid nutrients that have given you gnats for sure. I have a diary on how to get rid of them in depth..
1. Yellow sticky traps to catch the gnats when they turn to fliers. Catching 1 flier will stop him laying up to 200eggs in its life span
2. Now you've to sort out the larva that has been laid by the males. If you don't fix the larva you'll never get rid of them. And the larva can release disease into your soil. Things like Silica are liquid nutrients that help kill larva off. A fully soil organic grow you're just giving the plant the best, but your also given them the best environment.
3. You need to let the soil dry from the top right to the bottom. You'll know a fully dried out pot as a heavy one with water. After a few inches has dried down. Use a flat scoop and rid yourself of that dry soil. (As when it dries out, the larva eggs don't die, they stay dormant until you introduce the perfect conditions (wet soil). As an extra measure if you wanna just stick with soil growing. Buy a big bag of clay pebbles and fill about an inch-2 on top your soil. That way, if you get any house ones that fly in they can't lay their eggs, hence ending the cycle. But, if you get soil, and 90% that's where they come from poorly kept soil, (kept outside) the larva will turn to flies and get out. But there is a way to tackle this to.
4. Heat treat your chosen soil. Just look up with the maker, I've yet to see one you can't treat. An oven at 220c for 30mins and keep mixing the soil. (This will cause a serious stink) so i just use my shower and turn the water up to its hottest. And drown the soil and any larva will be instantly killed.
If you need any more tips please feel free to mes me.