From 00128ad6f9b6482bc8b6e5e806605e8b9b2cbd48 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Fri, 2 Apr 2021 13:22:46 -0400 Subject: [PATCH] close #880 --- .../instagrabber/utils/ExportImportUtils.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java index ca5ca21c..a0a2e190 100755 --- a/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java +++ b/app/src/main/java/awais/instagrabber/utils/ExportImportUtils.java @@ -156,12 +156,21 @@ public final class ExportImportUtils { query, favoriteType, favsObject.optString("s"), - favoriteType == FavoriteType.HASHTAG ? null - : favsObject.optString("pic_url"), + favoriteType == FavoriteType.USER ? favsObject.optString("pic_url") : null, new Date(favsObject.getLong("d"))); // Log.d(TAG, "importJson: favoriteModel: " + favoriteModel); - FavoriteRepository.getInstance(FavoriteDataSource.getInstance(context)) - .insertOrUpdateFavorite(favorite, null); + final FavoriteRepository favRepo = FavoriteRepository.getInstance(FavoriteDataSource.getInstance(context)); + favRepo.getFavorite(query, favoriteType, new RepositoryCallback() { + @Override + public void onSuccess(final Favorite result) { + // local has priority since it's more frequently updated + } + + @Override + public void onDataNotAvailable() { + favRepo.insertOrUpdateFavorite(favorite, null); + } + }); } }