File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,10 +25,23 @@ export const useVaultStore = defineStore('vault', () => {
2525 collaborators . value . push ( collaborator ) ;
2626 }
2727
28+ function updateCollaborator ( collaborator : VaultCollaborator ) : void {
29+ const index = collaborators . value . findIndex ( c => c . id === collaborator . id ) ;
30+
31+ if ( index === - 1 ) {
32+ addCollaborator ( collaborator ) ;
33+
34+ return ;
35+ }
36+
37+ collaborators . value [ index ] = {
38+ ...collaborators . value [ index ] ,
39+ ...collaborator ,
40+ } ;
41+ }
42+
2843 function removeCollaborator ( userId : number ) : void {
29- collaborators . value = collaborators . value . filter (
30- collaborator => collaborator . id !== userId
31- ) ;
44+ collaborators . value = collaborators . value . filter ( c => c . id !== userId ) ;
3245 }
3346
3447 return {
@@ -39,6 +52,7 @@ export const useVaultStore = defineStore('vault', () => {
3952 setVault,
4053 updateVault,
4154 addCollaborator,
55+ updateCollaborator,
4256 removeCollaborator,
4357 } ;
4458} ) ;
You can’t perform that action at this time.
0 commit comments