mirror of
https://github.com/meditohq/medito-app.git
synced 2024-09-11 12:15:46 +03:00
Merge pull request #661 from osamaasifoak/change-res-to-response
chore: res changed to response, provider ref types added
This commit is contained in:
commit
3e671762cd
@ -45,11 +45,11 @@ class AuthNotifier extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> initializeUser() async {
|
||||
var res = await getUserFromSharedPref();
|
||||
if (res == null) {
|
||||
var response = await getUserFromSharedPref();
|
||||
if (response == null) {
|
||||
await generateUserToken();
|
||||
} else {
|
||||
userResponse = ApiResponse.completed(res);
|
||||
userResponse = ApiResponse.completed(response);
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
@ -58,9 +58,9 @@ class AuthNotifier extends ChangeNotifier {
|
||||
userResponse = ApiResponse.loading();
|
||||
notifyListeners();
|
||||
try {
|
||||
var res = await authRepository.generateUserToken();
|
||||
await saveUserInSharedPref(res);
|
||||
userResponse = ApiResponse.completed(res);
|
||||
var response = await authRepository.generateUserToken();
|
||||
await saveUserInSharedPref(response);
|
||||
userResponse = ApiResponse.completed(response);
|
||||
} catch (e) {
|
||||
userResponse = ApiResponse.error(e.toString());
|
||||
}
|
||||
@ -71,8 +71,8 @@ class AuthNotifier extends ChangeNotifier {
|
||||
sendOTPResponse = ApiResponse.loading();
|
||||
notifyListeners();
|
||||
try {
|
||||
var res = await authRepository.sendOTP(email);
|
||||
sendOTPResponse = ApiResponse.completed(res);
|
||||
var response = await authRepository.sendOTP(email);
|
||||
sendOTPResponse = ApiResponse.completed(response);
|
||||
} catch (e) {
|
||||
sendOTPResponse = ApiResponse.error(e.toString());
|
||||
}
|
||||
@ -83,9 +83,9 @@ class AuthNotifier extends ChangeNotifier {
|
||||
verifyOTPResponse = ApiResponse.loading();
|
||||
notifyListeners();
|
||||
try {
|
||||
var res = await authRepository.verifyOTP(email, OTP);
|
||||
var response = await authRepository.verifyOTP(email, OTP);
|
||||
await updateUserInSharedPref(email);
|
||||
verifyOTPResponse = ApiResponse.completed(res);
|
||||
verifyOTPResponse = ApiResponse.completed(response);
|
||||
} catch (e) {
|
||||
verifyOTPResponse = ApiResponse.error(e.toString());
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'me_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<MeModel> me(ref) {
|
||||
Future<MeModel> me(MeRef ref) {
|
||||
ref.keepAlive();
|
||||
|
||||
return ref.watch(meRepositoryProvider).fetchMe();
|
||||
|
@ -39,7 +39,7 @@ Future<TrackModel> tracks(
|
||||
|
||||
@riverpod
|
||||
Future<void> likeDislikeTrack(
|
||||
ref, {
|
||||
LikeDislikeTrackRef ref, {
|
||||
required bool isLiked,
|
||||
required String trackId,
|
||||
required String audioFileId,
|
||||
@ -89,7 +89,7 @@ final likeDislikeCombineProvider =
|
||||
|
||||
@riverpod
|
||||
Future<void> addTrackListInPreference(
|
||||
ref, {
|
||||
AddTrackListInPreferenceRef ref, {
|
||||
required List<TrackModel> tracks,
|
||||
}) async {
|
||||
return await ref.read(trackRepositoryProvider).addTrackInPreference(tracks);
|
||||
@ -97,7 +97,7 @@ Future<void> addTrackListInPreference(
|
||||
|
||||
@riverpod
|
||||
Future<void> addSingleTrackInPreference(
|
||||
ref, {
|
||||
AddSingleTrackInPreferenceRef ref, {
|
||||
required TrackModel trackModel,
|
||||
required TrackFilesModel file,
|
||||
}) async {
|
||||
|
@ -7,7 +7,7 @@ import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
part 'pack_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
Future<List<PackItemsModel>> fetchAllPacks(ref) {
|
||||
Future<List<PackItemsModel>> fetchAllPacks(FetchAllPacksRef ref) {
|
||||
var packRepository = ref.watch(packRepositoryProvider);
|
||||
ref.keepAlive();
|
||||
|
||||
|
@ -7,7 +7,7 @@ part 'audio_position_provider.g.dart';
|
||||
|
||||
@riverpod
|
||||
void slideAudioPosition(
|
||||
ref, {
|
||||
SlideAudioPositionRef ref, {
|
||||
required int duration,
|
||||
}) {
|
||||
final audioPlayer = ref.watch(audioPlayerNotifierProvider);
|
||||
@ -17,7 +17,7 @@ void slideAudioPosition(
|
||||
|
||||
@riverpod
|
||||
void skipAudio(
|
||||
ref, {
|
||||
SkipAudioRef ref, {
|
||||
required SKIP_AUDIO skip,
|
||||
}) {
|
||||
final audioPlayer = ref.watch(audioPlayerNotifierProvider);
|
||||
|
@ -15,7 +15,7 @@ Future<StatsModel> remoteStats(RemoteStatsRef ref) {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
Future<Map<String, dynamic>?> localStats(ref) {
|
||||
Future<TransferStatsModel?> localStats(LocalStatsRef ref) {
|
||||
return ref.watch(statsRepositoryProvider).fetchStatsFromPreference();
|
||||
}
|
||||
|
||||
|
@ -32,30 +32,30 @@ class AuthRepositoryImpl extends AuthRepository {
|
||||
|
||||
@override
|
||||
Future<UserTokenModel> generateUserToken() async {
|
||||
var res = await client.postRequest(
|
||||
var response = await client.postRequest(
|
||||
HTTPConstants.USERS,
|
||||
options: Options(headers: {
|
||||
HttpHeaders.authorizationHeader: HTTPConstants.INIT_TOKEN,
|
||||
}),
|
||||
);
|
||||
|
||||
return UserTokenModel.fromJson(res);
|
||||
return UserTokenModel.fromJson(response);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> sendOTP(String email) async {
|
||||
var res = await client
|
||||
var response = await client
|
||||
.postRequest('${HTTPConstants.OTP}', data: {'email': email});
|
||||
|
||||
return res['success'];
|
||||
return response['success'];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> verifyOTP(String email, String OTP) async {
|
||||
var res = await client
|
||||
var response = await client
|
||||
.postRequest('${HTTPConstants.OTP}/$OTP', data: {'email': email});
|
||||
|
||||
return res['success'];
|
||||
return response['success'];
|
||||
}
|
||||
|
||||
@override
|
||||
@ -77,6 +77,6 @@ class AuthRepositoryImpl extends AuthRepository {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
AuthRepository authRepository(ref) {
|
||||
AuthRepository authRepository(AuthRepositoryRef ref) {
|
||||
return AuthRepositoryImpl(ref: ref, client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
@ -36,8 +36,8 @@ class BackgroundSoundsRepositoryImpl extends BackgroundSoundsRepository {
|
||||
|
||||
@override
|
||||
Future<List<BackgroundSoundsModel>> fetchBackgroundSounds() async {
|
||||
var res = await client.getRequest(HTTPConstants.BACKGROUND_SOUNDS);
|
||||
var tempResponse = res as List;
|
||||
var response = await client.getRequest(HTTPConstants.BACKGROUND_SOUNDS);
|
||||
var tempResponse = response as List;
|
||||
var bgSoundList = <BackgroundSoundsModel>[];
|
||||
const noneBgSound = BackgroundSoundsModel(
|
||||
id: '0',
|
||||
|
@ -113,7 +113,7 @@ class DownloaderRepositoryImpl extends DownloaderRepository {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
DownloaderRepositoryImpl downloaderRepository(ref) {
|
||||
DownloaderRepositoryImpl downloaderRepository(DownloaderRepositoryRef ref) {
|
||||
return DownloaderRepositoryImpl(
|
||||
client: ref.watch(dioClientProvider),
|
||||
ref: ref,
|
||||
|
@ -34,6 +34,6 @@ class EventsRepositoryImpl extends EventsRepository {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
EventsRepository eventsRepository(ref) {
|
||||
EventsRepository eventsRepository(EventsRepositoryRef ref) {
|
||||
return EventsRepositoryImpl(client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
@ -17,13 +17,13 @@ class MeRepositoryImpl extends MeRepository {
|
||||
|
||||
@override
|
||||
Future<MeModel> fetchMe() async {
|
||||
var res = await client.getRequest(HTTPConstants.ME);
|
||||
var response = await client.getRequest(HTTPConstants.ME);
|
||||
|
||||
return MeModel.fromJson(res);
|
||||
return MeModel.fromJson(response);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
MeRepository meRepository(ref) {
|
||||
MeRepository meRepository(MeRepositoryRef ref) {
|
||||
return MeRepositoryImpl(client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
@ -19,21 +19,21 @@ class PackRepositoryImpl extends PacksRepository {
|
||||
|
||||
@override
|
||||
Future<List<PackItemsModel>> fetchAllPacks() async {
|
||||
var res = await client.getRequest('${HTTPConstants.PACKS}');
|
||||
var tempResponse = res as List;
|
||||
var response = await client.getRequest('${HTTPConstants.PACKS}');
|
||||
var tempResponse = response as List;
|
||||
|
||||
return tempResponse.map((x) => PackItemsModel.fromJson(x)).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PackModel> fetchPacks(String packId) async {
|
||||
var res = await client.getRequest('${HTTPConstants.PACKS}/$packId');
|
||||
var response = await client.getRequest('${HTTPConstants.PACKS}/$packId');
|
||||
|
||||
return PackModel.fromJson(res);
|
||||
return PackModel.fromJson(response);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
PackRepositoryImpl packRepository(ref) {
|
||||
PackRepositoryImpl packRepository(PackRepositoryRef ref) {
|
||||
return PackRepositoryImpl(client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ class StatsRepositoryImpl extends StatsRepository {
|
||||
|
||||
@override
|
||||
Future<StatsModel> fetchStatsFromRemote() async {
|
||||
var res = await client.getRequest(HTTPConstants.STATS);
|
||||
var response = await client.getRequest(HTTPConstants.STATS);
|
||||
|
||||
return StatsModel.fromJson(res);
|
||||
return StatsModel.fromJson(response);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -98,6 +98,6 @@ class StatsRepositoryImpl extends StatsRepository {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
StatsRepository statsRepository(ref) {
|
||||
StatsRepository statsRepository(StatsRepositoryRef ref) {
|
||||
return StatsRepositoryImpl(client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ class TrackRepositoryImpl extends TrackRepository {
|
||||
|
||||
@override
|
||||
Future<TrackModel> fetchTrack(String trackId) async {
|
||||
var res = await client.getRequest('${HTTPConstants.TRACKS}/$trackId');
|
||||
var response = await client.getRequest('${HTTPConstants.TRACKS}/$trackId');
|
||||
|
||||
return TrackModel.fromJson(res);
|
||||
return TrackModel.fromJson(response);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -96,6 +96,6 @@ class TrackRepositoryImpl extends TrackRepository {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
TrackRepository trackRepository(ref) {
|
||||
TrackRepository trackRepository(TrackRepositoryRef ref) {
|
||||
return TrackRepositoryImpl(ref: ref, client: ref.watch(dioClientProvider));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user