-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1298 from get10101/chore/sync-position-with-dlc-c…
…hannel-state chore: Sync position with dlc channel state
- Loading branch information
Showing
21 changed files
with
721 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:f_logs/model/flog/flog.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; | ||
import 'package:get_10101/common/application/event_service.dart'; | ||
import 'package:get_10101/common/domain/background_task.dart'; | ||
import 'package:get_10101/common/global_keys.dart'; | ||
import 'package:get_10101/common/task_status_dialog.dart'; | ||
import 'package:provider/provider.dart'; | ||
|
||
class RecoverDlcChangeNotifier extends ChangeNotifier implements Subscriber { | ||
late TaskStatus taskStatus; | ||
|
||
@override | ||
void notify(bridge.Event event) { | ||
if (event is bridge.Event_BackgroundNotification) { | ||
if (event.field0 is! bridge.BackgroundTask_RecoverDlc) { | ||
// ignoring other kinds of background tasks | ||
return; | ||
} | ||
RecoverDlc recoverDlc = RecoverDlc.fromApi(event.field0 as bridge.BackgroundTask_RecoverDlc); | ||
FLog.debug(text: "Received a recover dlc event. Status: ${recoverDlc.taskStatus}"); | ||
|
||
taskStatus = recoverDlc.taskStatus; | ||
|
||
if (taskStatus == TaskStatus.pending) { | ||
// initialize dialog for the pending task | ||
showDialog( | ||
context: shellNavigatorKey.currentContext!, | ||
builder: (context) { | ||
TaskStatus status = context.watch<RecoverDlcChangeNotifier>().taskStatus; | ||
late Widget content = const Text("Recovering your dlc channel"); | ||
return TaskStatusDialog(title: "Catching up!", status: status, content: content); | ||
}, | ||
); | ||
|
||
// setting the task status to failed after a timeout of 30 seconds. | ||
Future.delayed(const Duration(seconds: 30), () { | ||
taskStatus = TaskStatus.failed; | ||
notifyListeners(); | ||
}); | ||
} else { | ||
// notify dialog about changed task status | ||
notifyListeners(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.