Skip to content

Commit f9f7637

Browse files
committed
Remove full HTML when raw HTML value changes
Previously the issue body html was not being re-encoded after edits and also the full html was never being flushed when the raw version has changed from the last time it was encoded. This would cause the issue description to not update after being edited. Closes pockethub#353
1 parent b5cd7d1 commit f9f7637

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

app/src/main/java/com/github/mobile/ui/issue/IssueFragment.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,9 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
500500

501501
switch (requestCode) {
502502
case ISSUE_EDIT:
503-
updateHeader((Issue) data.getSerializableExtra(EXTRA_ISSUE));
503+
Issue editedIssue = (Issue) data.getSerializableExtra(EXTRA_ISSUE);
504+
bodyImageGetter.encode(editedIssue.getId(), editedIssue.getBodyHtml());
505+
updateHeader(editedIssue);
504506
return;
505507
case COMMENT_CREATE:
506508
Comment comment = (Comment) data
@@ -557,4 +559,4 @@ public boolean onOptionsItemSelected(MenuItem item) {
557559
return super.onOptionsItemSelected(item);
558560
}
559561
}
560-
}
562+
}

app/src/main/java/com/github/mobile/util/HttpImageGetter.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,13 @@ public HttpImageGetter encode(final Object id, final String html) {
132132

133133
CharSequence encoded = HtmlUtils.encode(html, loading);
134134
// Use default encoding if no img tags
135-
if (containsImages(html))
136-
rawHtmlCache.put(id, encoded);
137-
else {
135+
if (containsImages(html)) {
136+
CharSequence currentEncoded = rawHtmlCache.put(id, encoded);
137+
// Remove full html if raw html has changed
138+
if (currentEncoded == null
139+
|| !currentEncoded.toString().equals(encoded.toString()))
140+
fullHtmlCache.remove(id);
141+
} else {
138142
rawHtmlCache.remove(id);
139143
fullHtmlCache.put(id, encoded);
140144
}
@@ -184,7 +188,6 @@ protected CharSequence run(Account account) throws Exception {
184188

185189
@Override
186190
protected void onSuccess(final CharSequence html) throws Exception {
187-
rawHtmlCache.remove(id);
188191
fullHtmlCache.put(id, html);
189192

190193
if (id.equals(view.getTag()))

0 commit comments

Comments
 (0)