If you haven't accepted them as a companion I do not believe it matters. However, if they are near you and they are not your companion (edit - by this I mean they have been accepted as a companion but are not your current one) and you do something they like or dislike your actions will matter.
I banged the singer in Goodneighbor while Piper was with me long after Piper and I had fallen in love and I had gotten the lovers embrace perk. A message came up saying 'Piper Hated this', but she still loved me afterwards anyways. So ... I don't know how much it all matters. I think if you have maxed out Charisma you'll be fine no matter what. But I could be wrong. I'm at 10 Charisma.
No what you do before & after does not effect their view of you the only impact your actions have on them is while they are with you
If a companion is close by, they can still 'like' what you do. I was running with Cait as my companion, but fixing up guns at a workbench and that maxed out Codsworth, who was nearby and I got his perk too. Also, while running with MacReady, I slept in a bed with Cait nearby and still got the Lover's Embrace. Doesn't happen when only MacReady is nearby (which is a good thing!)
I did a whole bunch of things she hated and then had a conversation and she was still starry eyed with me. Quite odd really.