Merge pull request #26 from lmontoute/main
Add plugin command to toggle connection
This commit is contained in:
		| @@ -201,9 +201,30 @@ namespace MareSynchronos | |||||||
|  |  | ||||||
|         private void OnCommand(string command, string args) |         private void OnCommand(string command, string args) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrEmpty(args)) |             var splitArgs = args?.ToLowerInvariant().Trim().Split(); | ||||||
|  |  | ||||||
|  |             if (splitArgs == null || splitArgs.Length == 0) | ||||||
|             { |             { | ||||||
|  |                 // Interpret this as toggling the UI | ||||||
|                 OpenUi(); |                 OpenUi(); | ||||||
|  |                 return; | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             if (splitArgs[0] == "toggle") | ||||||
|  |             { | ||||||
|  |                 var fullPause = splitArgs.Length > 1 ? splitArgs[1] switch | ||||||
|  |                 { | ||||||
|  |                     "on" => false, | ||||||
|  |                     "off" => true, | ||||||
|  |                     _ => !_configuration.FullPause, | ||||||
|  |                 } : !_configuration.FullPause; | ||||||
|  |  | ||||||
|  |                 if (fullPause != _configuration.FullPause) | ||||||
|  |                 { | ||||||
|  |                     _configuration.FullPause = fullPause; | ||||||
|  |                     _configuration.Save(); | ||||||
|  |                     _ = _apiController.CreateConnections(); | ||||||
|  |                 } | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 rootdarkarchon
					rootdarkarchon