That's absolutely correct. If you consume harmful content just before going to sleep, when your subconscious mind is active, then it can cause much damage to your mental health because it enters your subconscious mind.
That's why it is recommended to meditate and practice positive affirmations just before sleep.