Keep in mind that John’s Gospel is highly spiritual. He does not necessarily stick to the same timeline as the other Gospels. John portrays the same events very differently.
Also remember that Jesus said he must go to the Father before the Holy Spirit comes.
And when he had said this, he breathed on them and said to them, “Receive the holy Spirit. (John 20:22)
Jesus breathed on the disciples and gave them the Holy Spirit the night after his resurrection. In John’s Gospel the resurrection and ascension were one “theological action”. John portrays’ Jesus as having returned from the Father that very night, glorified, and the Holy Spirit is given to the disciples. This is John’s version of Pentecost, the receipt of the Holy Spirit by the Church.
In John’s Gospel, Mary “clings” or “holds on” to Jesus before he ascends to the Father. The sense is that she is holding him back from completing part of his mission - ascending to the Father. Jesus is anxious to go and returns that very night, “standing in their midst” and gives the Holy Spirit to the disciples. Only then is Thomas is invited touch Jesus.
***Mary holds Jesus. Jesus says “Don’t do that. I have not yet been glorified.”
Thomas demands to touch Jesus. Jesus says, “Go ahead.” Thomas says, “No way, you are the glorified God!”***
They won’t touch Jesus after he is glorified. That is what the Eucharist is for. The whole thing is Eucharistic. John’s whole Gospel is Eucharistic.
Seeing and touching and conversing with God are major themes in John’s writings.