fix file view display for cached reposts

This commit is contained in:
Akinwale Ariwodola 2020-05-31 21:22:37 +01:00
parent 1d97f9008d
commit f49a3570e9
2 changed files with 27 additions and 8 deletions

View file

@ -342,6 +342,7 @@ public class FileViewFragment extends BaseFragment implements
((MainActivity) context).onBackPressed();
}
boolean invalidRepost = false;
if (updateRequired) {
if (context instanceof MainActivity) {
((MainActivity) context).clearNowPlayingClaim();
@ -365,6 +366,20 @@ public class FileViewFragment extends BaseFragment implements
onNewClaim(currentUrl);
if (Lbry.claimCache.containsKey(key)) {
claim = Lbry.claimCache.get(key);
if (Claim.TYPE_REPOST.equalsIgnoreCase(claim.getValueType())) {
claim = claim.getRepostedClaim();
if (claim == null || Helper.isNullOrEmpty(claim.getClaimId())) {
// Invalid repost, probably
invalidRepost = true;
renderNothingAtLocation();
} else if (claim.getName().startsWith("@")) {
// this is a reposted channel, so launch the channel url
if (context instanceof MainActivity) {
((MainActivity) context).openChannelUrl(!Helper.isNullOrEmpty(claim.getShortUrl()) ? claim.getShortUrl() : claim.getPermanentUrl());
}
return;
}
}
} else {
resolveUrl(currentUrl);
}
@ -380,7 +395,7 @@ public class FileViewFragment extends BaseFragment implements
Helper.saveUrlHistory(currentUrl, claim != null ? claim.getTitle() : null, UrlSuggestion.TYPE_FILE);
}
if (claim != null) {
if (claim != null && !invalidRepost) {
Helper.saveViewHistory(currentUrl, claim);
checkAndLoadRelatedContent();
checkAndLoadComments();

View file

@ -103,16 +103,20 @@ public class TransactionHistoryFragment extends BaseFragment implements Transact
TransactionListTask task = new TransactionListTask(currentTransactionPage, TRANSACTION_PAGE_LIMIT, loading, new TransactionListTask.TransactionListHandler() {
@Override
public void onSuccess(List<Transaction> transactions, boolean hasReachedEnd) {
Context context = getContext();
transactionsLoading = false;
transactionsHaveReachedEnd = hasReachedEnd;
if (adapter == null) {
adapter = new TransactionListAdapter(transactions, getContext());
adapter.setListener(TransactionHistoryFragment.this);
if (transactionList != null) {
transactionList.setAdapter(adapter);
if (context != null) {
if (adapter == null) {
adapter = new TransactionListAdapter(transactions, context);
adapter.setListener(TransactionHistoryFragment.this);
if (transactionList != null) {
transactionList.setAdapter(adapter);
}
} else {
adapter.addTransactions(transactions);
}
} else {
adapter.addTransactions(transactions);
}
checkNoTransactions();
}