@@ -18,14 +18,17 @@ class ProjectWindowInterface : AssetPostprocessor
18
18
private static List < GitLock > locks = new List < GitLock > ( ) ;
19
19
private static List < string > guids = new List < string > ( ) ;
20
20
private static List < string > guidsLocks = new List < string > ( ) ;
21
+ private static string loggedInUser ;
21
22
22
23
private static IApplicationManager manager ;
23
24
private static bool isBusy = false ;
24
25
private static ILogging logger ;
25
26
private static ILogging Logger { get { return logger = logger ?? LogHelper . GetLogger < ProjectWindowInterface > ( ) ; } }
26
27
private static CacheUpdateEvent lastRepositoryStatusChangedEvent ;
27
28
private static CacheUpdateEvent lastLocksChangedEvent ;
29
+ private static CacheUpdateEvent lastUserChangedEvent ;
28
30
private static IRepository Repository { get { return manager != null ? manager . Environment . Repository : null ; } }
31
+ private static IPlatform Platform { get { return manager != null ? manager . Platform : null ; } }
29
32
private static bool IsInitialized { get { return Repository != null ; } }
30
33
31
34
public static void Initialize ( IApplicationManager theManager )
@@ -35,6 +38,9 @@ public static void Initialize(IApplicationManager theManager)
35
38
36
39
manager = theManager ;
37
40
41
+ Platform . Keychain . ConnectionsChanged += KeychainMayHaveChanged ;
42
+ KeychainMayHaveChanged ( ) ;
43
+
38
44
if ( IsInitialized )
39
45
{
40
46
Repository . StatusEntriesChanged += RepositoryOnStatusEntriesChanged ;
@@ -83,6 +89,11 @@ private static void RepositoryOnLocksChanged(CacheUpdateEvent cacheUpdateEvent)
83
89
}
84
90
}
85
91
92
+ private static void KeychainMayHaveChanged ( )
93
+ {
94
+ loggedInUser = Platform . Keychain . Connections . Select ( x => x . Username ) . FirstOrDefault ( ) ;
95
+ }
96
+
86
97
[ MenuItem ( AssetsMenuRequestLock , true , 10000 ) ]
87
98
private static bool ContextMenu_CanLock ( )
88
99
{
@@ -104,7 +115,7 @@ private static bool ContextMenu_CanUnlock()
104
115
return false ;
105
116
if ( isBusy )
106
117
return false ;
107
- return Selection . objects . Any ( IsObjectLocked ) ;
118
+ return Selection . objects . Any ( f => IsObjectLocked ( f , true ) ) ;
108
119
}
109
120
110
121
[ MenuItem ( AssetsMenuReleaseLockForced , true , 10002 ) ]
@@ -180,14 +191,20 @@ private static bool IsObjectUnlocked(Object selected)
180
191
}
181
192
182
193
private static bool IsObjectLocked ( Object selected )
194
+ {
195
+ return IsObjectLocked ( selected , false ) ;
196
+ }
197
+
198
+ private static bool IsObjectLocked ( Object selected , bool isLockedByCurrentUser )
183
199
{
184
200
if ( selected == null )
185
201
return false ;
186
202
187
203
NPath assetPath = AssetDatabase . GetAssetPath ( selected . GetInstanceID ( ) ) . ToNPath ( ) ;
188
204
NPath repositoryPath = manager . Environment . GetRepositoryPath ( assetPath ) ;
189
205
190
- return locks . Any ( x => repositoryPath == x . Path ) ;
206
+ var isObjectLocked = locks . Any ( x => repositoryPath == x . Path && ( ! isLockedByCurrentUser || x . Owner . Name == loggedInUser ) ) ;
207
+ return isObjectLocked ;
191
208
}
192
209
193
210
private static ITask CreateUnlockObjectTask ( Object selected , bool force )
0 commit comments