Implement show scores
This commit is contained in:
parent
7138f9b76c
commit
ef7ba71bcc
|
@ -93,6 +93,8 @@ class CommentWidget extends HookWidget {
|
|||
final theme = Theme.of(context);
|
||||
|
||||
final accStore = useAccountsStore();
|
||||
final showScores =
|
||||
useConfigStoreSelect((configStore) => configStore.showScores);
|
||||
|
||||
final isMine = commentTree.comment.comment.creatorId ==
|
||||
accStore.defaultUserDataFor(commentTree.comment.instanceHost)?.userId;
|
||||
|
@ -387,10 +389,13 @@ class CommentWidget extends HookWidget {
|
|||
SizedBox.fromSize(
|
||||
size: const Size.square(16),
|
||||
child: const CircularProgressIndicator())
|
||||
else
|
||||
else if (showScores)
|
||||
Text(compactNumber(comment.counts.score +
|
||||
(wasVoted ? 0 : myVote.value.value))),
|
||||
const Text(' · '),
|
||||
if (showScores)
|
||||
const Text(' · ')
|
||||
else
|
||||
const SizedBox(width: 4),
|
||||
Text(comment.comment.published.fancy),
|
||||
],
|
||||
),
|
||||
|
|
|
@ -9,6 +9,7 @@ import 'package:url_launcher/url_launcher.dart' as ul;
|
|||
|
||||
import '../hooks/delayed_loading.dart';
|
||||
import '../hooks/logged_in_action.dart';
|
||||
import '../hooks/stores.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../pages/full_post.dart';
|
||||
import '../url_launcher.dart';
|
||||
|
@ -496,6 +497,8 @@ class _Voting extends HookWidget {
|
|||
final theme = Theme.of(context);
|
||||
final myVote = useState(post.myVote ?? VoteType.none);
|
||||
final loading = useDelayedLoading();
|
||||
final showScores =
|
||||
useConfigStoreSelect((configStore) => configStore.showScores);
|
||||
final loggedInAction = useLoggedInAction(post.instanceHost);
|
||||
|
||||
vote(VoteType vote, Jwt token) async {
|
||||
|
@ -527,11 +530,12 @@ class _Voting extends HookWidget {
|
|||
myVote.value == VoteType.up ? VoteType.none : VoteType.up,
|
||||
token,
|
||||
),
|
||||
)),
|
||||
),
|
||||
),
|
||||
if (loading.loading)
|
||||
const SizedBox(
|
||||
width: 20, height: 20, child: CircularProgressIndicator())
|
||||
else
|
||||
else if (showScores)
|
||||
Text(NumberFormat.compact()
|
||||
.format(post.counts.score + (wasVoted ? 0 : myVote.value.value))),
|
||||
IconButton(
|
||||
|
|
Loading…
Reference in New Issue