Skip to content

Commit 716d608

Browse files
enhance: Improve shared issue tracker handling in RepositoryConfigure
Refactor the handling of shared issue trackers by reusing the `Commands.SharedIssueTracker` instance. Enhance the removal logic to check for the existence of the tracker file and delete it if empty.
1 parent 644bb94 commit 716d608

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/ViewModels/RepositoryConfigure.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Collections.Generic;
2+
using System.IO;
23
using System.Threading.Tasks;
34

45
using Avalonia.Collections;
@@ -305,10 +306,26 @@ public async Task ChangeIssueTrackerShareModeAsync()
305306
if (_selectedIssueTrackerRule is not { } rule)
306307
return;
307308

309+
var sharedTracker = new Commands.SharedIssueTracker(_repo.FullPath);
310+
308311
if (rule.IsShared)
309-
await new Commands.SharedIssueTracker(_repo.FullPath).AddAsync(rule);
312+
await sharedTracker.AddAsync(rule);
310313
else
311-
await new Commands.SharedIssueTracker(_repo.FullPath).RemoveAsync(rule);
314+
{
315+
await sharedTracker.RemoveAsync(rule);
316+
317+
if ((await sharedTracker.ReadAllAsync()).Count != 0)
318+
return;
319+
320+
var filePath = Path.Combine(_repo.FullPath, ".issuetracker");
321+
var content = await File.ReadAllTextAsync(filePath);
322+
323+
if (!string.IsNullOrEmpty(content))
324+
return;
325+
326+
if (File.Exists(filePath))
327+
File.Delete(filePath);
328+
}
312329
}
313330

314331
public void AddNewCustomAction()

0 commit comments

Comments
 (0)