Skip to content

Commit

Permalink
fix: add fallbacks for the server background images (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Dec 10, 2024
1 parent c8b1335 commit 720d5d2
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions lib/view/widget/misskey_server_background.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,29 @@ class MisskeyServerBackground extends HookConsumerWidget {
final Widget child;

String? getBackgroundImageUrl(JoinMisskeyInstanceInfo? server) {
return server?.meta?['backgroundImageUrl'] as String? ??
(server != null && server.icon
? 'https://instanceapp.misskey.page/instance-icons/${server.url}.webp'
: null);
if (server == null) {
return null;
}
if (server.meta?['backgroundImageUrl'] case final String url
when url.isNotEmpty) {
return url;
}
if (server.background) {
return 'https://instanceapp.misskey.page/instance-backgrounds/${server.url}.webp';
}
if (server.meta?['bannerUrl'] case final String url when url.isNotEmpty) {
return url;
}
if (server.banner) {
return 'https://instanceapp.misskey.page/instance-banners/${server.url}.webp';
}
if (server.meta?['iconUrl'] case final String url when url.isNotEmpty) {
return url;
}
if (server.icon) {
return 'https://instanceapp.misskey.page/instance-icons/${server.url}.webp';
}
return null;
}

@override
Expand Down

0 comments on commit 720d5d2

Please sign in to comment.