-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
持ち物追加処理を実装 #112
持ち物追加処理を実装 #112
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shimizu-saffle
持ち物一覧追加処理実装した!
暇なとき確認お願い!
); | ||
return [result, ...state.value ?? []]; | ||
}); | ||
ref.read(overlayLoadingProvider.notifier).endLoading(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo]
- 追加した持ち物は一番上に来るように修正
- TODO: サーバーサイドからidが降順で帰ってくるように修正する
- オーバーレイのローディングを出したいのでAsyncValueのisLoadingではなくoverlayLoadingProviderを使用
expect(result, [testAddBelonging, ...testFetchBelongings]); | ||
}); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[memo]
正常系のみ実装
理由としては
エラー帰ってきた際,AsyncValueのstateがAsyncValue.errorになるかなどはriverpod側の仕様なのでわざわざ
自分たちのテストで書かなくてもよいかなとおもったから
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seigi0714
AddTripBelongingSheet
のデザインと UXライティング良いね!
一箇所コメントした〜!
VoidCallback? onSuccess, | ||
}) async { | ||
ref.read(overlayLoadingProvider.notifier).startLoading(); | ||
state = await AsyncValue.guard(() async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここで、AsyncValue.guard()
すると、ref.read(tripInteractorProvider).addTripBelonging()
を呼んだ時に例外が生じると、TripBelongingList
に ErrorCat
が表示されちゃう。
(fetchTripBelongings に失敗してデータ取得できなかった時は ErrorCat
で良い)
例外発生時の挙動は上記のようになるよりは、すでにフェッチ成功している持ち物リストを表示したままスナックバーを出したほうが UX が良いと思う💡
Future<void> addBelonging({
required int tripId,
required String name,
required int numOf,
required bool isShareAmongMember,
VoidCallback? onSuccess,
}) async {
ref.read(overlayLoadingProvider.notifier).startLoading();
// 例外発生時に AsyncValue.when でビルドしているウィジェットを error にしないため、
// AsyncValue.guard() を使っていない。
try {
final result = await ref.read(tripInteractorProvider).addTripBelonging(
tripId: tripId,
name: name,
numOf: numOf,
isShareAmongMember: isShareAmongMember,
);
state = AsyncValue.data([result, ...state.value ?? []]);
} on Exception catch (e) {
ref.read(exceptionHandlerProvider).handleException(e);
} finally {
ref.read(overlayLoadingProvider.notifier).endLoading();
onSuccess?.call();
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとう確かにそやね〜!修正する!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shimizu-saffle
修正した!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!!(遅くなってごめん🙏) @seigi0714
改修内容
※ 一覧画面の見た目は次回以降のタスク
改修後キャプチャ
2023-05-13.16.34.24.mov