Skip to content

Commit

Permalink
[Application] Added the daily checkin url
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed May 5, 2021
1 parent 510b741 commit 11f1dfc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/application/settings/settings_bloc.dart
Expand Up @@ -84,7 +84,7 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
},
useOfficialMapChanged: (event) async {
_settingsService.useOfficialMap = event.newValue;
_urlPageBloc.add(const UrlPageEvent.init(loadMap: false, loadWishSimulator: false));
_urlPageBloc.add(const UrlPageEvent.init(loadMap: false, loadWishSimulator: false, loadDailyCheckIn: false));
return currentState.copyWith.call(useOfficialMap: event.newValue);
},
);
Expand Down
8 changes: 4 additions & 4 deletions lib/application/url_page/url_page_bloc.dart
Expand Up @@ -15,6 +15,7 @@ class UrlPageBloc extends Bloc<UrlPageEvent, UrlPageState> {
final wishSimulatorUrl = 'https://gi-wish-simulator.uzairashraf.dev';
final officialMapUrl = 'https://webstatic-sea.mihoyo.com/app/ys-map-sea/index.html';
final unofficialMapUrl = 'https://genshin-impact-map.appsample.com';
final dailyCheckInUrl = 'https://webstatic-sea.mihoyo.com/ys/event/signin-sea/index.html?act_id=e202102251931481&lang=en-us';

final NetworkService _networkService;
final TelemetryService _telemetryService;
Expand All @@ -29,18 +30,17 @@ class UrlPageBloc extends Bloc<UrlPageEvent, UrlPageState> {
) : super(const UrlPageState.loading());

@override
Stream<UrlPageState> mapEventToState(
UrlPageEvent event,
) async* {
Stream<UrlPageState> mapEventToState(UrlPageEvent event) async* {
final s = await event.map(
init: (e) async {
final finalMapUrl = _settingsService.useOfficialMap ? officialMapUrl : unofficialMapUrl;
final isInternetAvailable = await _networkService.isInternetAvailable();
await _telemetryService.trackUrlOpened(e.loadMap, e.loadWishSimulator, isInternetAvailable);
await _telemetryService.trackUrlOpened(e.loadMap, e.loadWishSimulator, e.loadDailyCheckIn, isInternetAvailable);
return UrlPageState.loaded(
hasInternetConnection: isInternetAvailable,
mapUrl: finalMapUrl,
wishSimulatorUrl: wishSimulatorUrl,
dailyCheckInUrl: dailyCheckInUrl,
userAgent: _deviceInfoService.userAgent,
);
},
Expand Down
1 change: 1 addition & 0 deletions lib/application/url_page/url_page_event.dart
Expand Up @@ -5,5 +5,6 @@ abstract class UrlPageEvent with _$UrlPageEvent {
const factory UrlPageEvent.init({
@required bool loadMap,
@required bool loadWishSimulator,
@required bool loadDailyCheckIn,
}) = _Init;
}
1 change: 1 addition & 0 deletions lib/application/url_page/url_page_state.dart
Expand Up @@ -6,6 +6,7 @@ abstract class UrlPageState with _$UrlPageState {
const factory UrlPageState.loaded({
@required String wishSimulatorUrl,
@required String mapUrl,
@required String dailyCheckInUrl,
@required bool hasInternetConnection,
@required String userAgent,
}) = _Loaded;
Expand Down

0 comments on commit 11f1dfc

Please sign in to comment.