Skip to content

Commit

Permalink
89: Add hasNotified check
Browse files Browse the repository at this point in the history
  • Loading branch information
JICA98 committed Aug 17, 2024
1 parent 12bf655 commit 9a7871b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/n8TN5qDG22PAuP50Il
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ APP_CONFIG_URL=https://raw.githubusercontent.com/JICA98/DailyAL/psycho/config
ERROR_REPORT_URL=
API_URL=https://dal-rust-api.onrender.com
API_SECRET=9XkJNP7ACL4BCVpXzwAzFZaeqdPpwv0aWpV1b89AxkCCSXq6N035YN8wCV8fX1yijaJzinJBMHhyku92qVPXFiQSayfXYajtZtwktYJMrzSTSva18yGLQf9vvQuTALCc
BUILD_VARIANT=fdroid
BUILD_VARIANT=github
17 changes: 15 additions & 2 deletions lib/screens/homescreen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dailyanimelist/api/credmal.dart';
import 'package:dailyanimelist/cache/cachemanager.dart';
import 'package:dailyanimelist/constant.dart';
import 'package:dailyanimelist/notifservice.dart';
import 'package:dailyanimelist/pages/explorepage.dart';
Expand Down Expand Up @@ -131,16 +132,28 @@ class _HomeScreenState extends State<HomeScreen> with TickerProviderStateMixin {
}
final tag = await getCurrentTag();
final git = await getLatestRelease();
final available = isUpdateAvailable(tag, git.tagName ?? '');
if (available) {
final latestTag = git.tagName ?? '';
final available = isUpdateAvailable(tag, latestTag);
final hasAlreadyNotified = await _hasAlreadyNotified(latestTag);
if (available && !hasAlreadyNotified) {
await showDialog(
context: context,
builder: (context) => showUpdateAvailablePopup(git, context, tag),
);
CacheManager.instance
.setValueForServiceAutoExpireIn('update', latestTag, 'true');
}
} catch (e) {}
}

Future<bool> _hasAlreadyNotified(String latestTag) async {
return (await CacheManager.instance
.getValueForServiceAutoExpire('update', latestTag))
?.toString()
.equals('true') ??
false;
}

@override
void dispose() {
super.dispose();
Expand Down

0 comments on commit 9a7871b

Please sign in to comment.