Skip to content

Commit

Permalink
refactor: comment out local schedule retrieval logic in getScheduleBy…
Browse files Browse the repository at this point in the history
…Id method
  • Loading branch information
jjoonleo committed Dec 1, 2024
1 parent 998bf4f commit e676b65
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/data/repositories/schedule_repository_impl.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:async';

import 'package:on_time_front/data/data_sources/schedule_local_data_source.dart';
import 'package:collection/collection.dart';
import 'package:on_time_front/data/data_sources/schedule_remote_data_source.dart';
import 'package:on_time_front/domain/entities/schedule_entity.dart';

Expand Down Expand Up @@ -40,27 +39,27 @@ class ScheduleRepositoryImpl implements ScheduleRepository {
Stream<ScheduleEntity> getScheduleById(String id) async* {
try {
final streamController = StreamController<ScheduleEntity>();
final localScheduleEntity = scheduleLocalDataSource.getScheduleById(id);
// final localScheduleEntity = scheduleLocalDataSource.getScheduleById(id);
final remoteScheduleEntity = scheduleRemoteDataSource.getScheduleById(id);

bool isFirstResponse = true;

localScheduleEntity.then((localScheduleEntity) {
if (isFirstResponse) {
isFirstResponse = false;
streamController.add(localScheduleEntity);
}
});
// localScheduleEntity.then((localScheduleEntity) {
// if (isFirstResponse) {
// isFirstResponse = false;
// streamController.add(localScheduleEntity);
// }
// });

remoteScheduleEntity.then((remoteScheduleEntity) async {
if (isFirstResponse) {
isFirstResponse = false;
streamController.add(remoteScheduleEntity);
} else {
if (await localScheduleEntity != remoteScheduleEntity) {
streamController.add(remoteScheduleEntity);
await scheduleLocalDataSource.updateSchedule(remoteScheduleEntity);
}
// if (await localScheduleEntity != remoteScheduleEntity) {
// streamController.add(remoteScheduleEntity);
// await scheduleLocalDataSource.updateSchedule(remoteScheduleEntity);
// }
}
});
yield* streamController.stream;
Expand Down

0 comments on commit e676b65

Please sign in to comment.