From 8f10c1c38e8bca23d56c0631aa8445771a50ff87 Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Fri, 22 Nov 2019 00:16:02 -0500 Subject: [PATCH] (feat): fetch chapters on app load to display numNewUnread - so if any new chapters were released since you last opened the app, it will update immediately and indicate if there are any new unread chapters as of just now - prev would only show new unread chapters since the last time you clicked into the manga, which was bound to be out-of-date - other than multiple providers, this is the last big, must-have feature I really needed to make me consistently return & use this app instead of others - others are more "nice-to-have" or "very-nice-to-have", but not necessarily dealbreakers for me at least --- App.js | 3 +++ models/models.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/App.js b/App.js index fbd5b62..4021b41 100644 --- a/App.js +++ b/App.js @@ -15,6 +15,9 @@ persist('@mangaStoreKey', appStore, { 'mangas', 'favorites' ] +}).then(() => { + // fetch chapters on app load so that numNewUnread is updated + appStore.loadFavoritesChapters() }) const App = () => ( diff --git a/models/models.js b/models/models.js index 186ea82..5e748f7 100644 --- a/models/models.js +++ b/models/models.js @@ -90,6 +90,10 @@ const AppModel = types.model('App', { self.favorites.splice(self.favorites.findIndex((elem) => { return elem === self.selectedManga }), 1) + }, + + loadFavoritesChapters () { + self.favorites.forEach((favorite) => favorite.loadChapters()) }} })