Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/features/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ class _HomeState extends ConsumerState<Home> {
}

Widget _buildBody(WidgetRef ref, bool isUserPro) {
final serverLocationAsync = ref.watch(serverLocationProvider);
final serverLocation = ref.watch(serverLocationProvider);

// Choose a safe default while loading/error
final serverLocation = serverLocationAsync.value;
final serverType = (serverLocation?.serverType ?? '').toServerLocationType;
final serverType = serverLocation.serverType.toServerLocationType;

return Padding(
padding: EdgeInsets.symmetric(horizontal: defaultSize),
Expand Down
20 changes: 7 additions & 13 deletions lib/features/home/provider/home_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,14 @@ class HomeNotifier extends _$HomeNotifier {
/// if user logs out or downgrade to free plan
/// we need to reset the server location set to smart location
void resetServerLocation() {
final serverLocationAsync = ref.read(serverLocationProvider);
final serverLocation = ref.read(serverLocationProvider);

serverLocationAsync.when(
data: (serverLocation) {
if (serverLocation.serverType.toServerLocationType ==
ServerLocationType.lanternLocation) {
ref
.read(serverLocationProvider.notifier)
.updateServerLocation(initialServerLocation());
}
},
loading: () {},
error: (_, __) {},
);
if (serverLocation.serverType.toServerLocationType ==
ServerLocationType.lanternLocation) {
ref
.read(serverLocationProvider.notifier)
.updateServerLocation(initialServerLocation());
}
}

/// Fetches the latest user data from the server if not cached locally.
Expand Down
Loading
Loading