@@ -103,7 +103,9 @@ struct HandleLemmyLinksModifier: ViewModifier {
103
103
// The "@" check ensures that KBin links are excluded
104
104
if !host. contains ( " reddit.com " ) , components. count == 2 , components [ 1 ] . first != " @ " {
105
105
Task {
106
- await showToastAndLoad ( url: url)
106
+ await showToastAndResolve ( url: url) { url in
107
+ openRegularLink ( url: url)
108
+ }
107
109
}
108
110
return . handled
109
111
}
@@ -172,7 +174,11 @@ struct HandleLemmyLinksModifier: ViewModifier {
172
174
} else if isLemmyHost ( host) {
173
175
// If it's a Lemmy host, try to resolve as a Lemmy user
174
176
Task {
175
- await showToastAndLoad ( url: URL ( string: " https:// \( host) /u/ \( user) " ) !)
177
+ await showToastAndResolve ( url: URL ( string: " https:// \( host) /u/ \( user) " ) !) { _ in
178
+ // If resolution fails, show email alert as fallback
179
+ pendingMailtoURL = url
180
+ showingEmailAlert = true
181
+ }
176
182
}
177
183
} else {
178
184
// If it's neither a common email domain nor a Lemmy host, show email alert
@@ -183,7 +189,7 @@ struct HandleLemmyLinksModifier: ViewModifier {
183
189
return true
184
190
}
185
191
186
- func showToastAndLoad ( url: URL ) async {
192
+ func showToastAndResolve ( url: URL , fallback : @escaping ( URL ) -> Void ) async {
187
193
let toastId = ToastModel . main. add ( . loading( ) )
188
194
var output = try ? await appState. firstApi. resolve ( url: url)
189
195
if output == nil {
@@ -199,7 +205,7 @@ struct HandleLemmyLinksModifier: ViewModifier {
199
205
} else if let community = output as? any Community {
200
206
navigation. push ( . community( community) )
201
207
} else {
202
- openRegularLink ( url : url)
208
+ fallback ( url)
203
209
}
204
210
ToastModel . main. removeToast ( id: toastId)
205
211
}
0 commit comments