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) { Widget build(BuildContext context) {
return ViewModelBuilder<HomeViewModel>.reactive( return ViewModelBuilder<HomeViewModel>.reactive(
disposeViewModel: false, disposeViewModel: false,
fireOnViewModelReadyOnce: true,
onViewModelReady: (model) => model.initialize(context), onViewModelReady: (model) => model.initialize(context),
viewModelBuilder: () => locator<HomeViewModel>(), viewModelBuilder: () => locator<HomeViewModel>(),
builder: (context, model, child) => Scaffold( builder: (context, model, child) => Scaffold(

View file

@ -116,7 +116,13 @@ class HomeViewModel extends BaseViewModel {
Future<bool> hasManagerUpdates() async { Future<bool> hasManagerUpdates() async {
final String? latestVersion = await _managerAPI.getLatestManagerVersion(); 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) { if (latestVersion != currentVersion) {
return true; return true;
} }

View file

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