Skip to content

Commit 069cfa9

Browse files
committed
Many changes
Setting -> BaseSetting AboutSettingsTab mostly added Added logic to see if discord is currently down
1 parent 40754f8 commit 069cfa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+368
-157
lines changed

MultiRPC/Assets/Language/en-gb.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"Debug": "Debug",
7171
"CheckForUpdates": "Check for\r\nupdates",
7272
"Donations": "Donations",
73-
"PaypalMin1": "PayPal (min $2)",
73+
"PaypalMin": "PayPal (min $2)",
7474
"PatreonMonthly": "Patreon (Monthly)",
7575
"ClickHere": "Click Here",
7676
"Disable": "Disable",
@@ -226,5 +226,14 @@
226226
"DiscordCanary": "Discord Canary",
227227
"DiscordDevelopment": "Discord Development",
228228
"About": "About",
229-
"Warn": "Warn"
229+
"Warn": "Warn",
230+
"ClickToDonate": "Click here to donate!",
231+
"CheckingDiscordStatus": "Checking discord status",
232+
"Operational": "Operational",
233+
"PartialOutage": "Partial outage",
234+
"DegradedPerformance": "Degraded performance",
235+
"MajorOutage": "Major outage!",
236+
"LogLevel": "Log Level",
237+
"GithubTooltip": "Access all the source code",
238+
"FluxpointTooltip": "Look at the other services that Fluxpoint offer!"
230239
}

MultiRPC/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static Constants()
3838
/// <summary>
3939
/// Url to the MultiRPC's info + download page
4040
/// </summary>
41-
public const string WebsiteUrl = "https://multirpc.fluxpoint.dev/";
41+
public const string WebsiteUrl = "https://fluxpoint.dev/multirpc";
4242

4343
/// <summary>
4444
/// The app developer
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System.Net.Http;
2+
using System.Text.Json;
3+
using System.Threading.Tasks;
4+
using MultiRPC.UI;
5+
using TinyUpdate.Http.Extensions;
6+
7+
namespace MultiRPC.Discord
8+
{
9+
public enum DiscordStatus
10+
{
11+
Operational,
12+
Degraded,
13+
PartialOutage,
14+
MajorOutage
15+
}
16+
17+
public static class DiscordStatusChecker
18+
{
19+
public static async Task<DiscordStatus> GetStatus()
20+
{
21+
var response = await App.HttpClient.GetResponseMessage(new HttpRequestMessage(HttpMethod.Get,
22+
"https://discordstatus.com/api/v2/components.json"));
23+
24+
if (response is null || !response.IsSuccessStatusCode)
25+
{
26+
return DiscordStatus.MajorOutage;
27+
}
28+
29+
var data = JsonSerializer.Deserialize<Status.Data>(await response.Content.ReadAsStreamAsync());
30+
var status = data?.Components[0].Status switch
31+
{
32+
"operational" => DiscordStatus.Operational,
33+
"degraded_performance" => DiscordStatus.Degraded,
34+
"partial_outage" => DiscordStatus.PartialOutage,
35+
"major_outage" => DiscordStatus.MajorOutage,
36+
_ => DiscordStatus.MajorOutage
37+
};
38+
39+
return status;
40+
}
41+
}
42+
}

MultiRPC/Rpc/IDChecker.cs renamed to MultiRPC/Discord/IDChecker.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using MultiRPC.UI;
77
using TinyUpdate.Http.Extensions;
88

9-
namespace MultiRPC.Rpc
9+
namespace MultiRPC.Discord
1010
{
1111
public static class IDChecker
1212
{
@@ -15,7 +15,7 @@ public static class IDChecker
1515
/// </summary>
1616
/// <param name="id">ID to check</param>
1717
/// <returns>Fail: returns false with error message
18-
/// Success: returns true with name that is linked to that ID</returns>
18+
/// Success: returns true with the name that is linked to that ID</returns>
1919
public static async Task<(bool Successful, string? ResultMessage)> Check(long id)
2020
{
2121
var responseMessage =
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Text.Json.Serialization;
3+
4+
namespace MultiRPC.Discord.Status
5+
{
6+
/*public class Page
7+
{
8+
[JsonPropertyName("id")]
9+
public string Id { get; set; }
10+
11+
[JsonPropertyName("name")]
12+
public string Name { get; set; }
13+
14+
[JsonPropertyName("url")]
15+
public string Url { get; set; }
16+
17+
[JsonPropertyName("time_zone")]
18+
public string TimeZone { get; set; }
19+
20+
[JsonPropertyName("updated_at")]
21+
public DateTime UpdatedAt { get; set; }
22+
}*/
23+
24+
public class Component
25+
{
26+
[JsonPropertyName("id")]
27+
public string Id { get; set; }
28+
29+
[JsonPropertyName("name")]
30+
public string Name { get; set; }
31+
32+
[JsonPropertyName("status")]
33+
public string Status { get; set; }
34+
35+
[JsonPropertyName("created_at")]
36+
public DateTime CreatedAt { get; set; }
37+
38+
[JsonPropertyName("updated_at")]
39+
public DateTime UpdatedAt { get; set; }
40+
41+
[JsonPropertyName("position")]
42+
public int Position { get; set; }
43+
44+
[JsonPropertyName("description")]
45+
public string Description { get; set; }
46+
47+
[JsonPropertyName("showcase")]
48+
public bool Showcase { get; set; }
49+
50+
[JsonPropertyName("start_date")]
51+
public string StartDate { get; set; }
52+
53+
[JsonPropertyName("group_id")]
54+
public string GroupId { get; set; }
55+
56+
[JsonPropertyName("page_id")]
57+
public string PageId { get; set; }
58+
59+
[JsonPropertyName("group")]
60+
public bool Group { get; set; }
61+
62+
[JsonPropertyName("only_show_if_degraded")]
63+
public bool OnlyShowIfDegraded { get; set; }
64+
65+
[JsonPropertyName("components")]
66+
public string[] Components { get; set; }
67+
}
68+
69+
public class Data
70+
{
71+
//[JsonPropertyName("page")]
72+
//public Page Page { get; set; }
73+
74+
[JsonPropertyName("components")]
75+
public Component[] Components { get; set; }
76+
}
77+
}

MultiRPC/Extensions/RpcExt.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using MultiRPC.Rpc;
2+
using RichPresence = DiscordRPC.RichPresence;
23

34
namespace MultiRPC.Extensions
45
{
56
public static class RpcExt
67
{
7-
public static RpcProfile ToProfile(this DiscordRPC.RichPresence presence)
8+
public static RpcProfile ToProfile(this RichPresence presence)
89
{
9-
return new RpcProfile()
10+
return new RpcProfile
1011
{
1112
State = presence.State,
1213
Details = presence.Details,

MultiRPC/Extensions/UriExt.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Diagnostics;
33
using System.Runtime.InteropServices;
4-
using TinyUpdate.Core.Helper;
54

65
namespace MultiRPC.Extensions
76
{

MultiRPC/Language.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
using System.IO;
44
using System.Linq;
55
using System.Reactive.Disposables;
6-
using System.Text.Json;
76
using System.Threading;
87
using MultiRPC.Setting;
98
using MultiRPC.Setting.Settings;
9+
using Newtonsoft.Json;
1010
using TinyUpdate.Core.Logging;
1111

1212
namespace MultiRPC
@@ -91,11 +91,9 @@ private static string GetFilePath(string name) =>
9191
}
9292

9393
Logger.Debug("{0} exists, grabbing contents", fileLocation);
94-
using var fileContentsStream = File.OpenRead(fileLocation);
95-
9694
try
9795
{
98-
return JsonSerializer.Deserialize<Dictionary<string, string>>(fileContentsStream)!;
96+
return JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(fileLocation));
9997
}
10098
catch (Exception e)
10199
{

MultiRPC/Logging/LoggingPageLogger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using Avalonia.Controls;
4+
using Avalonia.Threading;
45
using TinyUpdate.Core.Logging;
56

67
namespace MultiRPC.Logging
@@ -60,9 +61,9 @@ public void Error(Exception e, params object?[] propertyValues)
6061

6162
private void WriteLog(string message, string type, params object?[] propertyValues)
6263
{
63-
Avalonia.Threading.Dispatcher.UIThread.Post(() =>
64+
Dispatcher.UIThread.Post(() =>
6465
{
65-
var textBlock = new TextBlock()
66+
var textBlock = new TextBlock
6667
{
6768
Text = $"[{type} - {Name}]: " + string.Format(message, propertyValues)
6869
};

MultiRPC/Rpc/DiscordClient.cs renamed to MultiRPC/Rpc/DiscordClients.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace MultiRPC.Rpc
22
{
3-
public enum DiscordClient
3+
public enum DiscordClients
44
{
55
Auto,
66
Discord,

0 commit comments

Comments
 (0)