fix: fix broken manager update implmentation

This commit is contained in:
Aunali321 2023-04-30 00:39:42 +05:30 committed by Palm
parent d2e8e7dd5d
commit 15a32a18b7
3 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class HomeView extends StatelessWidget {
Widget build(BuildContext context) {
return ViewModelBuilder<HomeViewModel>.reactive(
disposeViewModel: false,
fireOnViewModelReadyOnce: true,
onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<HomeViewModel>(),
builder: (context, model, child) => Scaffold(

View File

@ -116,7 +116,13 @@ class HomeViewModel extends BaseViewModel {
Future<bool> hasManagerUpdates() async {
final String? latestVersion = await _managerAPI.getLatestManagerVersion();
final String currentVersion = await _managerAPI.getCurrentManagerVersion();
String currentVersion = await _managerAPI.getCurrentManagerVersion();
// add v to current version
if (!currentVersion.startsWith('v')) {
currentVersion = 'v$currentVersion';
}
if (latestVersion != currentVersion) {
return true;
}

View File

@ -56,7 +56,7 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
],
),
FutureBuilder<bool>(
future: locator<HomeViewModel>().hasManagerUpdates(),
future: model.hasManagerUpdates(),
initialData: false,
builder: (context, snapshot) => Opacity(
opacity: snapshot.hasData && snapshot.data! ? 1.0 : 0.25,