diff --git a/lib/widgets/save_post_button.dart b/lib/widgets/save_post_button.dart index 13f8694..6df080c 100644 --- a/lib/widgets/save_post_button.dart +++ b/lib/widgets/save_post_button.dart @@ -21,6 +21,7 @@ class SavePostButton extends HookWidget { savePost() async { final api = LemmyApi(post.instanceUrl).v1; final token = accStore.defaultTokenFor(post.instanceUrl); + if (token == null) { Scaffold.of(context).showSnackBar( SnackBar(content: Text("can't save if you ain't logged in"))); @@ -35,13 +36,23 @@ class SavePostButton extends HookWidget { } catch (e) { Scaffold.of(context) .showSnackBar(SnackBar(content: Text('saving failed :('))); - return; } loading.cancel(); } - if (loading.loading) return CircularProgressIndicator(); + if (loading.loading) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 14), + child: SizedBox( + width: 30, + height: 30, + child: CircularProgressIndicator( + backgroundColor: Theme.of(context).iconTheme.color, + )), + ); + } - return IconButton(icon: Icon(savedIcon), onPressed: savePost); + return IconButton( + icon: Icon(savedIcon), onPressed: loading.pending ? () {} : savePost); } }