Skip to content

Commit

Permalink
fix: Allow unlocking token locks with confirmation
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Knorr <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Nov 14, 2024
1 parent e3981aa commit 9b79845
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const canUnlock = (node: Node): boolean => {
return true
}

if (state.lockOwnerType === LockType.Token && state.lockOwner === getCurrentUser()?.uid) {
return true
}

return false
}

Expand Down
8 changes: 8 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ const menuAction = new FileAction({
},

async exec(node: Node) {
const lock = getLockStateFromAttributes(node)

if (lock?.lockOwnerType === LockType.Token) {
if (!confirm('This might cause conflicts, are you sure that the client is not working on the file?')) {
return
}
}

return await switchLock(node)
},

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
export enum LockType {
User = 0,
App = 1,
Token = 2,
}

export type LockState = {
Expand Down

0 comments on commit 9b79845

Please sign in to comment.