Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance Uptime #884

Merged
merged 93 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
93 commits
Select commit Hold shift + click to select a range
5cf1c2b
Update
Sjmarf Jan 14, 2024
fe8c799
Show instance version
Sjmarf Jan 14, 2024
84c9e38
Rewrite CommunityResultView and UserResultView
Sjmarf Jan 14, 2024
e298d1d
Remove extra divider
Sjmarf Jan 14, 2024
95a4671
Don't show instance in admin list
Sjmarf Jan 14, 2024
e7cb5bf
Merge branch 'dev' into sjmarf/instance-page
Sjmarf Jan 17, 2024
4a81fc3
Use existing `GetSiteRequest(instanceURL: URL)` system
Sjmarf Jan 17, 2024
672a9ba
Bug fix
Sjmarf Jan 19, 2024
85e7d44
Fix
Sjmarf Jan 19, 2024
9129886
KBin fix
Sjmarf Jan 20, 2024
cf282dd
Update InstanceView.swift
Sjmarf Jan 20, 2024
31acf9c
Update InstanceView.swift
Sjmarf Jan 20, 2024
fa2f0f9
Update InstanceView.swift
Sjmarf Jan 20, 2024
d416622
Faster loading for own instance page
Sjmarf Jan 20, 2024
a385c1d
Update
Sjmarf Jan 20, 2024
30186f7
Update project.pbxproj
Sjmarf Jan 20, 2024
c2f59e0
Fix again
Sjmarf Jan 20, 2024
401add5
Remove unnecessary code
Sjmarf Jan 20, 2024
0703e89
Merge branch 'sjmarf/instance-page' into sjmarf/instance-stats
Sjmarf Jan 21, 2024
0840ead
Update
Sjmarf Jan 21, 2024
563e340
Update
Sjmarf Jan 21, 2024
7f792fa
Update project.pbxproj
Sjmarf Jan 21, 2024
b97ea61
Rename "Statistics" tab to "Details"
Sjmarf Jan 21, 2024
597a24b
Bug fix
Sjmarf Jan 22, 2024
6f777f7
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 22, 2024
d8a9901
Update
Sjmarf Jan 22, 2024
06837fd
Fix background on light mode
Sjmarf Jan 22, 2024
9291310
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 22, 2024
b5dd5bd
Update
Sjmarf Jan 22, 2024
2b654ca
Update RecentSearchesView.swift
Sjmarf Jan 22, 2024
19f7e4c
Add pre-emptive support for `GetPersonDetailsResponse.site`
Sjmarf Jan 24, 2024
16de9ef
Merge branch 'sjmarf/instance-page' into sjmarf/instance-stats
Sjmarf Jan 24, 2024
86119c3
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 24, 2024
b210e58
Design tweak
Sjmarf Jan 24, 2024
51e7868
Design tweak
Sjmarf Jan 24, 2024
50ccbf3
Remove debug print
Sjmarf Jan 24, 2024
e8d6c1f
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 25, 2024
0fc3e09
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 27, 2024
a8d31b8
Update project.pbxproj
Sjmarf Jan 27, 2024
513f3a2
Bug fixes
Sjmarf Jan 27, 2024
51a1c8a
Tweak
Sjmarf Jan 27, 2024
634b24e
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 27, 2024
6ee52e0
Add context menu to search results
Sjmarf Jan 27, 2024
cfee83e
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 27, 2024
ebae6dd
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 28, 2024
e85f37b
Show/hide slur filter with animation
Sjmarf Jan 28, 2024
37d06c2
Make some settings always show
Sjmarf Jan 28, 2024
eb1c0e7
Update
Sjmarf Jan 28, 2024
f0a025e
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 28, 2024
2c64908
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 28, 2024
383f5b4
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 28, 2024
e73c7a1
Update InstanceModel.swift
Sjmarf Jan 28, 2024
e59ca40
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 28, 2024
2ff9694
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 28, 2024
3b6fbd4
Update
Sjmarf Jan 29, 2024
d5cbfeb
Update
Sjmarf Jan 29, 2024
6f53f6f
Update InstanceView.swift
Sjmarf Jan 29, 2024
84689f8
Tweak
Sjmarf Jan 29, 2024
a2e134a
Bug fix
Sjmarf Jan 29, 2024
949f59d
Tweak
Sjmarf Jan 29, 2024
eee8677
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 30, 2024
64b6428
Update
Sjmarf Jan 30, 2024
483a9c8
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 30, 2024
49eec0b
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 30, 2024
cba9293
Merge branch 'dev' into sjmarf/instance-stats
Sjmarf Jan 30, 2024
d846319
Merge branch 'sjmarf/instance-stats' into sjmarf/instance-search
Sjmarf Jan 30, 2024
836f1f6
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 30, 2024
6ec86a4
Merge branch 'dev' into sjmarf/instance-search
Sjmarf Jan 31, 2024
fdbf279
Merge branch 'dev' into sjmarf/instance-search
Sjmarf Jan 31, 2024
26c2a62
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 31, 2024
34f26b1
Update project.pbxproj
Sjmarf Jan 31, 2024
0242c4b
Added average response time
Sjmarf Jan 31, 2024
49fe30d
Bug fix
Sjmarf Jan 31, 2024
b1d90e7
Fix another bug
Sjmarf Jan 31, 2024
bfc2174
Merge branch 'sjmarf/instance-search' into sjmarf/instance-uptime
Sjmarf Jan 31, 2024
fb864ef
Fix padding
Sjmarf Feb 1, 2024
08b5d51
Add fade-in transition
Sjmarf Feb 1, 2024
e95a641
Tweaks
Sjmarf Feb 3, 2024
878eb88
Update UptimeData.swift
Sjmarf Feb 3, 2024
5b351ae
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 3, 2024
3ba580e
Update InstanceView.swift
Sjmarf Feb 3, 2024
e1c81da
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 5, 2024
4f0b133
auto-refresh
Sjmarf Feb 8, 2024
dcb6b76
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 8, 2024
1ec59df
icons
Sjmarf Feb 8, 2024
186177f
Update InstanceUptimeView.swift
Sjmarf Feb 8, 2024
8cc10b1
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 11, 2024
a539881
Update InstanceUptimeView.swift
Sjmarf Feb 12, 2024
d37429f
Implement requested changes
Sjmarf Feb 12, 2024
99d8ed2
Only show today's incidents
Sjmarf Feb 12, 2024
9056975
Update InstanceUptimeView.swift
Sjmarf Feb 12, 2024
5b6c214
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 16, 2024
d618026
Merge branch 'dev' into sjmarf/instance-uptime
Sjmarf Feb 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Mlem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
03E0B9C82A61F0F400FED265 /* AdvancedSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */; };
03E0B9CA2A62B4A400FED265 /* ContributorsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9C92A62B4A400FED265 /* ContributorsView.swift */; };
03E0B9CC2A62CD5800FED265 /* ThemeSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E0B9CB2A62CD5800FED265 /* ThemeSettingsView.swift */; };
03E47AEB2B66BADC00A3E4DB /* UptimeData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E47AEA2B66BADC00A3E4DB /* UptimeData.swift */; };
03E47AED2B66BC0000A3E4DB /* InstanceUptimeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E47AEC2B66BC0000A3E4DB /* InstanceUptimeView.swift */; };
03E47AEF2B66BD3C00A3E4DB /* InstanceModel+Uptime.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E47AEE2B66BD3C00A3E4DB /* InstanceModel+Uptime.swift */; };
03E79F3F2AE3E7100006700D /* SortingSettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E79F3E2AE3E7100006700D /* SortingSettingsView.swift */; };
03E90FB12B3703ED00E5A802 /* AccountSortMode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03E90FB02B3703ED00E5A802 /* AccountSortMode.swift */; };
03EA79C42AC0D92C00BCDC91 /* PostComposerView+Logic.swift in Sources */ = {isa = PBXBuildFile; fileRef = 03EA79C32AC0D92C00BCDC91 /* PostComposerView+Logic.swift */; };
Expand Down Expand Up @@ -667,6 +670,9 @@
03E0B9C72A61F0F400FED265 /* AdvancedSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdvancedSettingsView.swift; sourceTree = "<group>"; };
03E0B9C92A62B4A400FED265 /* ContributorsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContributorsView.swift; sourceTree = "<group>"; };
03E0B9CB2A62CD5800FED265 /* ThemeSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThemeSettingsView.swift; sourceTree = "<group>"; };
03E47AEA2B66BADC00A3E4DB /* UptimeData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UptimeData.swift; sourceTree = "<group>"; };
03E47AEC2B66BC0000A3E4DB /* InstanceUptimeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstanceUptimeView.swift; sourceTree = "<group>"; };
03E47AEE2B66BD3C00A3E4DB /* InstanceModel+Uptime.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "InstanceModel+Uptime.swift"; sourceTree = "<group>"; };
03E79F3E2AE3E7100006700D /* SortingSettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SortingSettingsView.swift; sourceTree = "<group>"; };
03E90FB02B3703ED00E5A802 /* AccountSortMode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountSortMode.swift; sourceTree = "<group>"; };
03EA79C32AC0D92C00BCDC91 /* PostComposerView+Logic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PostComposerView+Logic.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1393,6 +1399,8 @@
isa = PBXGroup;
children = (
03A54C312B5331F30064CCDE /* InstanceView.swift */,
03E47AEC2B66BC0000A3E4DB /* InstanceUptimeView.swift */,
03E47AEA2B66BADC00A3E4DB /* UptimeData.swift */,
031F95562B5C7FF20069C244 /* InstanceDetailsView.swift */,
);
path = Instance;
Expand All @@ -1402,6 +1410,7 @@
isa = PBXGroup;
children = (
03A54C342B533BC50064CCDE /* InstanceModel.swift */,
03E47AEE2B66BD3C00A3E4DB /* InstanceModel+Uptime.swift */,
0355DA4E2B5EB63600CDF5A5 /* InstanceStub.swift */,
0355DA4C2B5EB51900CDF5A5 /* InstanceModel+ContentModel.swift */,
03A54C362B545A430064CCDE /* InstanceModel+MenuFunctions.swift */,
Expand Down Expand Up @@ -3244,6 +3253,7 @@
039C8DBB2B35B2EB0096BAAF /* AccountListView.swift in Sources */,
CD1446252A5B357900610EF1 /* Document.swift in Sources */,
CDEBC32C2A9A582500518D9D /* Votes Model.swift in Sources */,
03E47AED2B66BC0000A3E4DB /* InstanceUptimeView.swift in Sources */,
CDEBC3282A9A57F200518D9D /* Content Model Identifier.swift in Sources */,
6FF17D012B685C16007E1814 /* AppLockView.swift in Sources */,
B1955A1D2A606B950056CF99 /* Easter Rewards.swift in Sources */,
Expand Down Expand Up @@ -3363,10 +3373,12 @@
039439912A98FA6100463032 /* UserFeedView.swift in Sources */,
03EA79C42AC0D92C00BCDC91 /* PostComposerView+Logic.swift in Sources */,
03A18CBF2B1252BD00BA69D2 /* ListingType.swift in Sources */,
03E47AEF2B66BD3C00A3E4DB /* InstanceModel+Uptime.swift in Sources */,
637218482A3A2AAD008C4816 /* APICommentReply.swift in Sources */,
CD3720EC2B2E8F96004D7103 /* AlternativeIconCell.swift in Sources */,
032109472AA7C3FC00912DFC /* CommunityLabelView.swift in Sources */,
637218502A3A2AAD008C4816 /* APIPersonAggregates.swift in Sources */,
03E47AEB2B66BADC00A3E4DB /* UptimeData.swift in Sources */,
CD4368D72AE2464D00BD8BD1 /* ReplyModel+InboxItem.swift in Sources */,
6D693A422A5114DF009E2D76 /* APIPostReport.swift in Sources */,
5064D03F2A6DE0DB00B22EE3 /* Notifier+Dependency.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Mlem/Extensions/View Modifiers/View+HandleLemmyLinks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct HandleLemmyLinksDisplay: ViewModifier {
UserView(user: user, communityContext: communityContext)
.environmentObject(appState)
.environmentObject(quickLookState)
case let .instance(domainName, instance):
InstanceView(domainName: domainName, instance: instance)
case let .instance(instance):
InstanceView(instance: instance)
case let .postLinkWithContext(postLink):
ExpandedPost(post: postLink.post, community: postLink.community, scrollTarget: postLink.scrollTarget)
.environmentObject(postLink.postTracker)
Expand Down
5 changes: 5 additions & 0 deletions Mlem/Icons.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ enum Icons {
static let close: String = "multiply"
static let cakeDay: String = "birthday.cake"

// uptime
static let uptimeOffline: String = "xmark.circle.fill"
static let uptimeOnline: String = "checkmark.circle.fill"
static let uptimeOutage: String = "exclamationmark.circle.fill"

// end of feed
static let endOfFeedHobbit: String = "figure.climbing"
static let endOfFeedCartoon: String = "figure.wave"
Expand Down
30 changes: 17 additions & 13 deletions Mlem/Models/Content/Community/CommunityModel+MenuFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,20 +95,24 @@ extension CommunityModel {
functions.append(.standard(function))
functions.append(.standard(favoriteMenuFunction(callback)))
}
if let instanceHost = communityUrl.host() {
let instance: InstanceModel?
if let site {
instance = .init(from: site)
} else {
instance = nil
}
functions.append(
.navigationMenuFunction(
text: instanceHost,
imageName: Icons.instance,
destination: .instance(instanceHost, instance)
do {
if let instanceHost = self.communityUrl.host() {
let instance: InstanceModel
if let site {
instance = .init(from: site)
} else {
instance = try .init(domainName: instanceHost)
}
functions.append(
.navigationMenuFunction(
text: instanceHost,
imageName: Icons.instance,
destination: .instance(instance)
)
)
)
}
} catch {
print("Failed to add instance menu function!")
}
functions.append(
.standardMenuFunction(
Expand Down
59 changes: 59 additions & 0 deletions Mlem/Models/Content/Instance/InstanceModel+Uptime.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// InstanceModel+Uptime.swift
// Mlem
//
// Created by Sjmarf on 28/01/2024.
//

import SwiftUI

extension InstanceModel {

// Instances watched by lemmy-status.org
static let uptimeSupportedInstances: [String] = [
"aussie.zone",
"beehaw.org",
"discuss.online",
"discuss.tchncs.de",
"dubvee.org",
"feddit.de",
"feddit.dk",
"hexbear.net",
"infosec.pub",
"jlai.lu",
"lemdro.id",
"lemm.ee",
"lemmings.world",
"lemmy.blahaj.zone",
"lemmy.ca",
"lemmy.dbzer0.com",
"lemmy.eco.br",
"lemmy.ml",
"lemmy.myserv.one",
"lemmy.nz",
"lemmy.world",
"lemmy.zip",
"literature.cafe",
"mander.xyz",
"midwest.social",
"programming.dev",
"sh.itjust.works",
"slrpnk.net",
"sopuli.xyz",
"startrek.website"
]

var canFetchUptime: Bool { InstanceModel.uptimeSupportedInstances.contains(name) }

var uptimeDataUrl: URL? {
guard canFetchUptime else { return nil }
let name = "_\(name.replacingOccurrences(of: ".", with: "-"))"
return URL(string: "https://lemmy-status.org/api/v1/endpoints/\(name)/statuses?page=1")
}

var uptimeFrontendUrl: URL? {
guard canFetchUptime else { return nil }
let name = "_\(name.replacingOccurrences(of: ".", with: "-"))"
return URL(string: "https://lemmy-status.org/endpoints/\(name)")
}
}
17 changes: 17 additions & 0 deletions Mlem/Models/Content/Instance/InstanceModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
import SwiftUI

struct InstanceModel {

enum InstanceError: Error {
case invalidUrl
}

var displayName: String!
var description: String?
var avatar: URL?
Expand Down Expand Up @@ -41,6 +46,18 @@ struct InstanceModel {
var applicationsEmailAdmins: Bool?
var reportsEmailAdmins: Bool?

init(domainName: String) throws {
var components = URLComponents()
components.scheme = "https"
components.host = domainName
if let url = components.url {
self.url = url
displayName = name
} else {
throw InstanceError.invalidUrl
}
}

init(from response: SiteResponse) {
update(with: response)
}
Expand Down
30 changes: 17 additions & 13 deletions Mlem/Models/Content/User/UserModel+MenuFunctions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,24 @@ extension UserModel {
editorTracker: EditorTracker? = nil
) -> [MenuFunction] {
var functions: [MenuFunction] = .init()
if let instanceHost = profileUrl.host() {
let instance: InstanceModel?
if let site {
instance = .init(from: site)
} else {
instance = nil
}
functions.append(
.navigationMenuFunction(
text: instanceHost,
imageName: Icons.instance,
destination: .instance(instanceHost, instance)
do {
if let instanceHost = self.profileUrl.host() {
let instance: InstanceModel
if let site {
instance = .init(from: site)
} else {
instance = try .init(domainName: instanceHost)
}
functions.append(
.navigationMenuFunction(
text: instanceHost,
imageName: Icons.instance,
destination: .instance(instance)
)
)
)
}
} catch {
print("Failed to add instance menu function!")
}
functions.append(
.standardMenuFunction(
Expand Down
2 changes: 1 addition & 1 deletion Mlem/Navigation/Routes/AppRoutes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Foundation
///
enum AppRoute: Routable {
case community(CommunityModel)
case instance(String? = nil, InstanceModel? = nil)
case instance(InstanceModel)

case userProfile(UserModel, communityContext: CommunityModel? = nil)

Expand Down
Loading
Loading