Question on how to check simultaneously if someone else remove my access on my application?

For my application,

I can lock or unlock a folder. When I lock a folder, I will be able go into a edit folder component and edit the folder related data that I locked with.

But there is a situation I want to cover: When I lock a folder, and when I am at the edit folder component, If someone unlock me on their side, I want to get kicked out and route to a different component.

What I want my application to do is:

When someone else unlock my folder, I will get routed to a different component.

How can I implement this kind of check?

( I am doing the check when I lock or unlock a folder myself, but I don't know how to check when someone else is removing my lock.)