If my understanding is correct, there was no mortal sin on your part. You have to consciously choose to have mortal sin, and, in dreaming, we don’t choose.
I have a recurring nightmare of being swept up in a tsunami, possibly due to a near-drowning incident when I was 14. Why would I consciously choose to relive that? But I do relive the feeling when I have this nightmare. There is no control over your dreams.
Perhaps, when you dream “badly,” you could use it for good? For example, let’s say you have “bad dreams” about a certain person. When you wake up, pray for that person, that they might live their lives following Christ. If you are dreaming of violence, pray that violence in the world might end and that peace be brought to all lands. If you dream of lust, pray that husbands and wives might be faithful to their vows, that priests and religious be faithful to theirs, and that single people might have the strength for chastity and celibacy outside of marriage. Etc.