Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into feature/anonymou…
Browse files Browse the repository at this point in the history
…s-instances
  • Loading branch information
micahmo committed Sep 8, 2023
2 parents d855318 + 41264f5 commit c81eb34
Show file tree
Hide file tree
Showing 52 changed files with 1,187 additions and 552 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,32 @@ jobs:

- name: Tests
run: flutter test

# Read the version number
- name: Read pubspec.yaml version
id: output-pubspec-version
uses: NiklasLehnfeld/flutter-version-number-action@main
with:
file-path: pubspec.yaml

# Read the globals.dart file
- name: Read globals.dart version
id: output-globals-version
uses: juliangruber/read-file-action@v1
with:
path: lib/globals.dart

# Get just the first line of the globals.dart file
- name: Get first line of globals.dart file
uses: jungwinter/split@v2
id: split-globals-output
with:
msg: ${{ steps.output-globals-version.outputs.content }}
separator: '\n'

# Assert that the version has been updated in globals
- name: Assert globals.dart has correct version
uses: nick-fields/assert-action@v1
with:
expected: const String currentVersion = '${{ steps.output-pubspec-version.outputs.version-number }}';
actual: ${{ steps.split-globals-output.outputs._0 }}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
- Added lock icon indicating a post is locked. Visible in feed and post view. Also blocks commenting functionality and instead shows a toast indicating the post is blocked - contribution from @ajsosa
- Added the ability to combine the post FAB with the comment navigation buttons - contribution from @micahmo
- Show special user identifiers in post - contribution from @micahmo
- Added setting to import and export settings
- Added liveness and latency indicators for instances in profile switcher - contribution from @micahmo
- Add option to disabling graying out read posts - contribution from @micahmo
- Downvote actions will be disabled when instances have downvotes disabled
- Improved account switching and added anonymous browsing mode for any intance - contribution from @micahmo

### Changed
Expand All @@ -27,6 +30,9 @@
- Make comment indicators use colours blended from the current theme - contribution from @tom-james-watson
- Star indicator for saved posts now prefixes the post title so that it's consistent with the indicators for locked posts and featured community posts - contribution from @ajsosa
- Improved ability to refresh posts - contribution from @micahmo
- Improve the option selector dialog to show the currently selected item - contribution from @micahmo
- Show swatches and live previews for accent color selection - contribution from @micahmo
- Use Android system back button to navigate from Saved to History on profile page - contribution from @micahmo

### Fixed

Expand Down Expand Up @@ -123,6 +129,8 @@
- Fixed feed page reaching the end in some cases where NSFW content is turned on
- Fixed issue where external link thumbnails weren't being displayed due to show external link previews option being off which was only intended to prevent html scraping - contribution from @ajsosa
- Fixed community/user link handling from posts - contribution from @micahmo
- Fixed double tap zoom sometimes triggering again if attempting to pan immediately after - contribution from @CTalvio


## 0.2.1+13 - 2023-07-25

Expand Down
12 changes: 12 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ PODS:
- Flutter (1.0.0)
- flutter_custom_tabs (0.0.1):
- Flutter
- flutter_file_dialog (0.0.1):
- Flutter
- flutter_icmp_ping (0.0.1):
- Flutter
- flutter_native_splash (0.0.1):
- Flutter
- FMDB (2.7.5):
Expand Down Expand Up @@ -37,6 +41,8 @@ DEPENDENCIES:
- device_info_plus (from `.symlinks/plugins/device_info_plus/ios`)
- Flutter (from `Flutter`)
- flutter_custom_tabs (from `.symlinks/plugins/flutter_custom_tabs/ios`)
- flutter_file_dialog (from `.symlinks/plugins/flutter_file_dialog/ios`)
- flutter_icmp_ping (from `.symlinks/plugins/flutter_icmp_ping/ios`)
- flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`)
- gallery_saver (from `.symlinks/plugins/gallery_saver/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
Expand All @@ -60,6 +66,10 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_custom_tabs:
:path: ".symlinks/plugins/flutter_custom_tabs/ios"
flutter_file_dialog:
:path: ".symlinks/plugins/flutter_file_dialog/ios"
flutter_icmp_ping:
:path: ".symlinks/plugins/flutter_icmp_ping/ios"
flutter_native_splash:
:path: ".symlinks/plugins/flutter_native_splash/ios"
gallery_saver:
Expand Down Expand Up @@ -87,6 +97,8 @@ SPEC CHECKSUMS:
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
flutter_custom_tabs: 7a10a08686955cb748e5d26e0ae586d30689bf89
flutter_file_dialog: 4c014a45b105709a27391e266c277d7e588e9299
flutter_icmp_ping: 2b159955eee0c487c766ad83fec224ae35e7c935
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
gallery_saver: 9fc173c9f4fcc48af53b2a9ebea1b643255be542
Expand Down
4 changes: 2 additions & 2 deletions lib/community/bloc/community_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CommunityState extends Equatable {
this.communityName,
this.communityInfo,
this.blockedCommunity,
this.tagline,
this.tagline = '',
});

final CommunityStatus status;
Expand All @@ -40,7 +40,7 @@ class CommunityState extends Equatable {

final BlockedCommunity? blockedCommunity;

final String? tagline;
final String tagline;

CommunityState copyWith({
CommunityStatus? status,
Expand Down
11 changes: 6 additions & 5 deletions lib/community/pages/community_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,7 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
? GestureFab(
distance: 60,
icon: Icon(
singlePressAction.isAllowed(state: state, widget: widget)
? singlePressAction.getIcon(override: singlePressAction == FeedFabAction.changeSort ? sortTypeIcon : null)
: FeedFabAction.dismissRead.getIcon(),
singlePressAction.isAllowed(state: state, widget: widget) ? singlePressAction.getIcon() : FeedFabAction.dismissRead.getIcon(),
semanticLabel: singlePressAction.isAllowed(state: state) ? singlePressAction.getTitle(context) : FeedFabAction.dismissRead.getTitle(context),
size: 35,
),
Expand Down Expand Up @@ -387,7 +385,7 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
context.read<ThunderBloc>().add(const OnFabToggle(false));
},
child: Container(
color: theme.colorScheme.background.withOpacity(0.85),
color: theme.colorScheme.background.withOpacity(0.95),
),
)
: null,
Expand Down Expand Up @@ -417,6 +415,7 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
}

Widget _getBody(BuildContext context, CommunityState state) {
ThunderState thunderState = context.read<ThunderBloc>().state;
switch (state.status) {
case CommunityStatus.initial:
// communityId and communityName are mutually exclusive - only one of the two should be passed in
Expand Down Expand Up @@ -450,7 +449,8 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
onSaveAction: (int postId, bool save) => context.read<CommunityBloc>().add(SavePostEvent(postId: postId, save: save)),
onVoteAction: (int postId, VoteType voteType) => context.read<CommunityBloc>().add(VotePostEvent(postId: postId, score: voteType)),
onToggleReadAction: (int postId, bool read) => context.read<CommunityBloc>().add(MarkPostAsReadEvent(postId: postId, read: read)),
tagline: state.tagline!,
tagline: state.tagline,
indicateRead: thunderState.dimReadPosts,
);
case CommunityStatus.empty:
return Center(child: Text(AppLocalizations.of(context)!.noPosts));
Expand Down Expand Up @@ -479,6 +479,7 @@ class _CommunityPageState extends State<CommunityPage> with AutomaticKeepAliveCl
),
);
},
previouslySelected: sortType,
),
);
}
Expand Down
9 changes: 9 additions & 0 deletions lib/community/utils/post_actions.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

import 'package:lemmy_api_client/v3.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';

import 'package:thunder/core/enums/swipe_action.dart';
import 'package:thunder/core/models/post_view_media.dart';
Expand All @@ -24,6 +26,13 @@ void triggerPostAction({
onVoteAction(postViewMedia.postView.post.id, voteType == VoteType.up ? VoteType.none : VoteType.up);
return;
case SwipeAction.downvote:
bool downvotesEnabled = context.read<AuthBloc>().state.downvotesEnabled;

if (downvotesEnabled == false) {
showSnackbar(context, AppLocalizations.of(context)!.downvotesDisabled);
return;
}

onVoteAction(postViewMedia.postView.post.id, voteType == VoteType.down ? VoteType.none : VoteType.down);
return;
case SwipeAction.reply:
Expand Down
16 changes: 7 additions & 9 deletions lib/community/utils/post_card_action_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'package:thunder/core/auth/bloc/auth_bloc.dart';
import 'package:thunder/core/enums/media_type.dart';
import 'package:thunder/core/enums/swipe_action.dart';
import 'package:thunder/core/models/post_view_media.dart';
import 'package:thunder/shared/picker_item.dart';
import 'package:thunder/shared/snackbar.dart';
import 'package:thunder/thunder/bloc/thunder_bloc.dart';
import 'package:thunder/user/pages/user_page.dart';
Expand Down Expand Up @@ -79,11 +80,11 @@ void showPostActionBottomModalSheet(BuildContext context, PostViewMedia postView
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 16.0, left: 16.0, right: 16.0),
padding: const EdgeInsets.only(bottom: 16.0, left: 26.0, right: 16.0),
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Actions',
AppLocalizations.of(context)!.actions,
style: theme.textTheme.titleLarge!.copyWith(),
),
),
Expand All @@ -102,13 +103,10 @@ void showPostActionBottomModalSheet(BuildContext context, PostViewMedia postView
return Container();
}

return ListTile(
title: Text(
postCardActionItemsToUse[index].label,
style: theme.textTheme.bodyMedium,
),
leading: Icon(postCardActionItemsToUse[index].icon),
onTap: () async {
return PickerItem(
label: postCardActionItemsToUse[index].label,
icon: postCardActionItemsToUse[index].icon,
onSelected: () async {
Navigator.of(context).pop();

PostCardAction postCardAction = postCardActionItemsToUse[index].postCardAction;
Expand Down
5 changes: 4 additions & 1 deletion lib/community/widgets/post_card_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/services.dart';

import 'package:lemmy_api_client/v3.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:thunder/core/auth/bloc/auth_bloc.dart';

import 'package:thunder/thunder/bloc/thunder_bloc.dart';

Expand Down Expand Up @@ -35,6 +36,8 @@ class PostCardActions extends StatelessWidget {
final bool showVoteActions = state.showVoteActions;
final bool showSaveAction = state.showSaveAction;

final bool downvotesEnabled = context.read<AuthBloc>().state.downvotesEnabled;

return Row(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
Expand All @@ -51,7 +54,7 @@ class PostCardActions extends StatelessWidget {
HapticFeedback.mediumImpact();
onVoteAction(voteType == VoteType.up ? VoteType.none : VoteType.up);
}),
if (showVoteActions)
if (showVoteActions && downvotesEnabled)
IconButton(
icon: Icon(
Icons.arrow_downward,
Expand Down
6 changes: 3 additions & 3 deletions lib/community/widgets/post_card_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class _PostCardListState extends State<PostCardList> with TickerProviderStateMix
},
child: CommunityHeader(communityInfo: widget.communityInfo),
);
} else if (widget.tagline.isNotEmpty == true) {
} else if (widget.tagline.isNotEmpty) {
final bool taglineIsLong = widget.tagline.length > 200;

return Padding(
Expand Down Expand Up @@ -266,7 +266,7 @@ class _PostCardListState extends State<PostCardList> with TickerProviderStateMix
);
}
}
if (index == ((widget.communityId != null || widget.communityName != null || widget.tagline.isNotEmpty == true) ? widget.postViews!.length + 1 : widget.postViews!.length)) {
if (index == ((widget.communityId != null || widget.communityName != null || widget.tagline.isNotEmpty) ? widget.postViews!.length + 1 : widget.postViews!.length)) {
if (widget.hasReachedEnd == true) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
Expand Down Expand Up @@ -297,7 +297,7 @@ class _PostCardListState extends State<PostCardList> with TickerProviderStateMix
);
}
} else {
PostViewMedia postViewMedia = widget.postViews![(widget.communityId != null || widget.communityName != null || widget.tagline.isNotEmpty == true) ? index - 1 : index];
PostViewMedia postViewMedia = widget.postViews![(widget.communityId != null || widget.communityName != null || widget.tagline.isNotEmpty) ? index - 1 : index];
return AnimatedSwitcher(
switchOutCurve: Curves.ease,
duration: const Duration(milliseconds: 0),
Expand Down
30 changes: 27 additions & 3 deletions lib/core/auth/bloc/auth_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,17 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
SharedPreferences prefs = (await UserPreferences.instance).sharedPreferences;
prefs.setString('active_profile_id', event.accountId);

return emit(state.copyWith(status: AuthStatus.success, account: account, isLoggedIn: true));
// Check to see the instance settings (for checking if downvotes are enabled)
LemmyClient.instance.changeBaseUrl(account.instance!.replaceAll('https://', ''));
LemmyApiV3 lemmy = LemmyClient.instance.lemmyApiV3;

FullSiteView fullSiteView = await lemmy.run(
GetSite(auth: account.jwt),
);

bool downvotesEnabled = fullSiteView.siteView?.localSite.enableDownvotes ?? true;

return emit(state.copyWith(status: AuthStatus.success, account: account, isLoggedIn: true, downvotesEnabled: downvotesEnabled));
});

// This event should be triggered during the start of the app, or when there is a change in the active account
Expand Down Expand Up @@ -73,7 +83,19 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
if (activeAccount.username != null && activeAccount.jwt != null && activeAccount.instance != null) {
// Set lemmy client to use the instance
LemmyClient.instance.changeBaseUrl(activeAccount.instance!.replaceAll('https://', ''));
return emit(state.copyWith(status: AuthStatus.success, account: activeAccount, isLoggedIn: true));

// Check to see the instance settings (for checking if downvotes are enabled)
LemmyApiV3 lemmy = LemmyClient.instance.lemmyApiV3;

FullSiteView fullSiteView = await lemmy.run(
GetSite(
auth: activeAccount.jwt,
),
);

bool downvotesEnabled = fullSiteView.siteView?.localSite.enableDownvotes ?? true;

return emit(state.copyWith(status: AuthStatus.success, account: activeAccount, isLoggedIn: true, downvotesEnabled: downvotesEnabled));
}
});

Expand Down Expand Up @@ -126,7 +148,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
SharedPreferences prefs = (await UserPreferences.instance).sharedPreferences;
prefs.setString('active_profile_id', accountId);

return emit(state.copyWith(status: AuthStatus.success, account: account, isLoggedIn: true));
bool downvotesEnabled = fullSiteView.siteView?.localSite.enableDownvotes ?? true;

return emit(state.copyWith(status: AuthStatus.success, account: account, isLoggedIn: true, downvotesEnabled: downvotesEnabled));
} on LemmyApiException catch (e) {
return emit(state.copyWith(status: AuthStatus.failure, account: null, isLoggedIn: false, errorMessage: e.toString()));
} catch (e) {
Expand Down
6 changes: 5 additions & 1 deletion lib/core/auth/bloc/auth_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,31 @@ class AuthState extends Equatable {
this.isLoggedIn = false,
this.errorMessage,
this.account,
this.downvotesEnabled = true,
});

final AuthStatus status;
final bool isLoggedIn;
final String? errorMessage;
final Account? account;
final bool downvotesEnabled;

AuthState copyWith({
AuthStatus? status,
bool? isLoggedIn,
String? errorMessage,
Account? account,
bool? downvotesEnabled,
}) {
return AuthState(
status: status ?? this.status,
isLoggedIn: isLoggedIn ?? false,
errorMessage: errorMessage,
account: account,
downvotesEnabled: downvotesEnabled ?? this.downvotesEnabled,
);
}

@override
List<Object?> get props => [status, isLoggedIn, errorMessage, account];
List<Object?> get props => [status, isLoggedIn, errorMessage, account, downvotesEnabled];
}
Loading

0 comments on commit c81eb34

Please sign in to comment.