Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1193e4b

Browse files
authored
chore: rework mutagen controller, add polling (#65)
- Use locks during operations for daemon process consistency- Use a state model for UI rendering- Use events to signal state changes- Fix some tooltip problems that arise from polling
1 parent9b1aaa5 commit1193e4b

13 files changed

+544
-343
lines changed

‎App/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ protected override void OnLaunched(LaunchActivatedEventArgs args)
120120
// Initialize file sync.
121121
varsyncSessionCts=newCancellationTokenSource(TimeSpan.FromSeconds(10));
122122
varsyncSessionController=_services.GetRequiredService<ISyncSessionController>();
123-
_=syncSessionController.Initialize(syncSessionCts.Token).ContinueWith(t=>
123+
_=syncSessionController.RefreshState(syncSessionCts.Token).ContinueWith(t=>
124124
{
125125
// TODO: log
126126
#ifDEBUG

‎App/Models/RpcModel.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
usingSystem.Collections.Generic;
2-
usingSystem.Linq;
32
usingCoder.Desktop.Vpn.Proto;
43

54
namespaceCoder.Desktop.App.Models;
@@ -26,18 +25,18 @@ public class RpcModel
2625

2726
publicVpnLifecycleVpnLifecycle{get;set;}=VpnLifecycle.Unknown;
2827

29-
publicList<Workspace>Workspaces{get;set;}=[];
28+
publicIReadOnlyList<Workspace>Workspaces{get;set;}=[];
3029

31-
publicList<Agent>Agents{get;set;}=[];
30+
publicIReadOnlyList<Agent>Agents{get;set;}=[];
3231

3332
publicRpcModelClone()
3433
{
3534
returnnewRpcModel
3635
{
3736
RpcLifecycle=RpcLifecycle,
3837
VpnLifecycle=VpnLifecycle,
39-
Workspaces=Workspaces.ToList(),
40-
Agents=Agents.ToList(),
38+
Workspaces=Workspaces,
39+
Agents=Agents,
4140
};
4241
}
4342
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
usingSystem.Collections.Generic;
2+
3+
namespaceCoder.Desktop.App.Models;
4+
5+
publicenumSyncSessionControllerLifecycle
6+
{
7+
// Uninitialized means that the daemon has not been started yet. This can
8+
// be resolved by calling RefreshState (or any other RPC method
9+
// successfully).
10+
Uninitialized,
11+
12+
// Stopped means that the daemon is not running. This could be because:
13+
// - It was never started (pre-Initialize)
14+
// - It was stopped due to no sync sessions (post-Initialize, post-operation)
15+
// - The last start attempt failed (DaemonError will be set)
16+
// - The last daemon process crashed (DaemonError will be set)
17+
Stopped,
18+
19+
// Running is the normal state where the daemon is running and managing
20+
// sync sessions. This is only set after a successful start (including
21+
// being able to connect to the daemon).
22+
Running,
23+
}
24+
25+
publicclassSyncSessionControllerStateModel
26+
{
27+
publicSyncSessionControllerLifecycleLifecycle{get;init;}=SyncSessionControllerLifecycle.Stopped;
28+
29+
/// <summary>
30+
/// May be set when Lifecycle is Stopped to signify that the daemon failed
31+
/// to start or unexpectedly crashed.
32+
/// </summary>
33+
publicstring?DaemonError{get;init;}
34+
35+
publicrequiredstringDaemonLogFilePath{get;init;}
36+
37+
/// <summary>
38+
/// This contains the last known state of all sync sessions. Sync sessions
39+
/// are periodically refreshed if the daemon is running. This list is
40+
/// sorted by creation time.
41+
/// </summary>
42+
publicIReadOnlyList<SyncSessionModel>SyncSessions{get;init;}=[];
43+
}

‎App/Models/SyncSessionModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public string Description(string linePrefix = "")
5151
publicclassSyncSessionModel
5252
{
5353
publicreadonlystringIdentifier;
54+
publicreadonlyDateTimeCreatedAt;
5455

5556
publicreadonlystringAlphaName;
5657
publicreadonlystringAlphaPath;
@@ -99,6 +100,7 @@ public string SizeDetails
99100
publicSyncSessionModel(Statestate)
100101
{
101102
Identifier=state.Session.Identifier;
103+
CreatedAt=state.Session.CreationTime.ToDateTime();
102104

103105
(AlphaName,AlphaPath)=NameAndPathFromUrl(state.Session.Alpha);
104106
(BetaName,BetaPath)=NameAndPathFromUrl(state.Session.Beta);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp