Skip to content

Commit

Permalink
地震履歴のWebSocket結合 (#632)
Browse files Browse the repository at this point in the history
* rename proxy name

* add: websocket listen

* fix: kmoni

* Merge branch 'develop' into feature/earthquake-history-websocket
  • Loading branch information
YumNumm authored Apr 8, 2024
1 parent de605f8 commit c4abc2c
Show file tree
Hide file tree
Showing 24 changed files with 113 additions and 102 deletions.
48 changes: 18 additions & 30 deletions app/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = iOSAppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -540,7 +539,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -558,11 +556,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -582,7 +579,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor.FcmServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor.FcmServiceExtension";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -600,11 +596,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -623,7 +618,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor.FcmServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore net.yumnumm.eqmonitor.FcmServiceExtension";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -641,11 +635,10 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
Expand All @@ -664,7 +657,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor.FcmServiceExtension;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor.FcmServiceExtension";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -785,11 +777,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = iOSAppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -802,7 +793,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand All @@ -817,11 +807,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = iOSAppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1158;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = CPL7H8SHVM;
DEVELOPMENT_TEAM = CPL7H8SHVM;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = EQMonitor;
Expand All @@ -834,7 +823,6 @@
PRODUCT_BUNDLE_IDENTIFIER = net.yumnumm.eqmonitor;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore net.yumnumm.eqmonitor";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic";
Expand Down
4 changes: 2 additions & 2 deletions app/lib/core/provider/dio_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ Dio dio(DioRef ref) {
createHttpClient: () =>
HttpClient()..findProxy = (url) => 'PROXY macbook-pro:9090',
);
HttpOverrides.global = MyHttpOverrides();
HttpOverrides.global = _HttpOverrides();
}
return dio;
}

class MyHttpOverrides extends HttpOverrides {
class _HttpOverrides extends HttpOverrides {
@override
HttpClient createHttpClient(SecurityContext? context) {
return super.createHttpClient(context)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/core/provider/dio_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/lib/core/provider/eew/eew_alive_telegram.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class EewAliveChecker {
final depth = eew.depth;

// EEW警報の場合、420秒でイベント終了と判定する
final isWarning = (eew.headline ?? '').contains('強い揺れ');
final isWarning = eew.isWarning ?? eew.headline?.contains('強い揺れ') ?? false;
if (isWarning) {
return happenedDiff > 420;
}
Expand Down
12 changes: 5 additions & 7 deletions app/lib/core/provider/kmoni/viewmodel/kmoni_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ class KmoniViewModel extends _$KmoniViewModel {
Future<void> initialize() async {
// Timer開始
while (true) {
try {
await syncDelayWithKmoni();
// ignore: avoid_catches_without_on_clauses
} catch (e) {
log('error $e');
await Future<void>.delayed(const Duration(milliseconds: 1000));
continue;
final result = await syncDelayWithKmoni();
if (result != null) {
break;
}
await Future<void>.delayed(const Duration(milliseconds: 1000));

break;
}
state = state.copyWith(
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions app/lib/core/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,15 @@ class EarthquakeHistoryDetailsRoute extends GoRouteData {
required this.eventId,
});

final String eventId;
final int eventId;

@override
Widget build(BuildContext context, GoRouterState state) =>
EarthquakeHistoryDetailsPage(
Widget build(BuildContext context, GoRouterState state) {

return EarthquakeHistoryDetailsPage(
eventId: eventId,
);
}
}

@TypedGoRoute<InformationHistoryRoute>(path: '/information-history')
Expand Down
4 changes: 2 additions & 2 deletions app/lib/core/router/router.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class EarthquakeHistoryNotifier extends _$EarthquakeHistoryNotifier {
throw EarthquakeParameterHasNotInitializedException();
}
// 検索条件を指定していないNotifierでのみ、30秒ごとにデータ再取得するタイマーを設定
if (parameter == EarthquakeHistoryParameter.empty()) {
if (parameter == const EarthquakeHistoryParameter()) {
// 30秒ごとにデータ再取得するタイマー
final refetchTimer = Timer.periodic(
const Duration(seconds: 30),
Expand All @@ -55,8 +55,27 @@ class EarthquakeHistoryNotifier extends _$EarthquakeHistoryNotifier {
await _onResumed();
}
},
)
// WebSocketからのデータを適用する
..listen(
websocketTableMessagesProvider<EarthquakeV1>(),
(_, next) {
if (next case AsyncData(value: final value)) {
if (value is RealtimePostgresInsertPayload<EarthquakeV1>) {
_upsertEarthquakeV1s([value.newData]);
}
final _ = switch (value) {
RealtimePostgresInsertPayload<EarthquakeV1>(:final newData) =>
_upsertEarthquakeV1s([newData]),
RealtimePostgresUpdatePayload<EarthquakeV1>(:final newData) =>
_upsertEarthquakeV1s([newData]),
RealtimePostgresDeletePayload<EarthquakeV1>() => null,
};
}
},
);
}

return _fetchInitialData(
param: parameter,
regions: earthquakeParameter.regions,
Expand Down Expand Up @@ -156,7 +175,7 @@ class EarthquakeHistoryNotifier extends _$EarthquakeHistoryNotifier {

Future<void> _onResumed() async {
// パラメータが指定されている場合は何もしない
if (parameter != EarthquakeHistoryParameter.empty()) {
if (parameter != const EarthquakeHistoryParameter()) {
return;
}
final repository = ref.read(earthquakeHistoryRepositoryProvider);
Expand All @@ -175,7 +194,7 @@ class EarthquakeHistoryNotifier extends _$EarthquakeHistoryNotifier {
return;
}
// パラメータが指定されている場合は何もしない
if (parameter != EarthquakeHistoryParameter.empty()) {
if (parameter != const EarthquakeHistoryParameter()) {
return;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class EarthquakeHistoryParameter with _$EarthquakeHistoryParameter {
JmaIntensity? intensityLte,
JmaIntensity? intensityGte,
}) = _EarthquakeHistoryParameter;

factory EarthquakeHistoryParameter.empty() =>
const EarthquakeHistoryParameter();
}

extension EarthquakeHistoryParameterEx on EarthquakeHistoryParameter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class _SliverListBody extends HookConsumerWidget {
return EarthquakeHistoryListTile(
item: item,
onTap: () => EarthquakeHistoryDetailsRoute(
eventId: item.eventId.toString(),
eventId: item.eventId,
).push<void>(context),
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ class _StationAction extends _Action {
['linear'],
['zoom'],
3,
0.3,
0.2,
20,
1,
],
Expand Down Expand Up @@ -754,9 +754,9 @@ class _StationAction extends _Action {
['linear'],
['zoom'],
3,
0.1,
0.04,
7,
0.4,
0.3,
],
textAllowOverlap: true,
iconAllowOverlap: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class PrefectureLpgmIntensityWidget extends HookConsumerWidget {
child: CircularProgressIndicator.adaptive(),
),
),
AsyncData(:final value) when value.isEmpty => const SizedBox.shrink(),
AsyncData(:final value) => BorderedContainer(
elevation: 1,
padding: const EdgeInsets.symmetric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'earthquake_history_details_notifier.g.dart';

@Riverpod(keepAlive: true)
@riverpod
Future<EarthquakeV1Extended> earthquakeHistoryDetailsNotifier(
EarthquakeHistoryDetailsNotifierRef ref,
String eventId,
int eventId,
) async {
final api = ref.watch(eqApiProvider);
final response = await api.v1.getEarthquakeDetail(eventId: eventId);
final response = await api.v1.getEarthquakeDetail(eventId: eventId.toString());
final data = response.data;
// TODO(YumNumm): ここでWebSocketからの地震情報を結合する

final extended = await ref.read(earthquakeV1ExtendedProvider(data).future);
return extended;
Expand Down
Loading

0 comments on commit c4abc2c

Please sign in to comment.