Copy the loadable when adding to history

Otherwise the database will possible use the loadable from a pin, and when clearing the history also deleting the loadable from the pin.
filtering
Floens 10 years ago
parent fec551bc55
commit 17e747b2fc
  1. 2
      Clover/app/src/main/java/org/floens/chan/core/model/Loadable.java
  2. 5
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java

@ -28,7 +28,7 @@ import com.j256.ormlite.table.DatabaseTable;
@DatabaseTable @DatabaseTable
public class Loadable { public class Loadable {
@DatabaseField(generatedId = true) @DatabaseField(generatedId = true)
private int id; public int id;
@DatabaseField @DatabaseField
public int mode = Mode.INVALID; public int mode = Mode.INVALID;

@ -571,7 +571,10 @@ public class ThreadPresenter implements ChanLoader.ChanLoaderCallback, PostAdapt
if (!historyAdded && ChanSettings.historyEnabled.get() && loadable.isThreadMode()) { if (!historyAdded && ChanSettings.historyEnabled.get() && loadable.isThreadMode()) {
historyAdded = true; historyAdded = true;
History history = new History(); History history = new History();
history.loadable = loadable; // Copy the loadable when adding to history
// Otherwise the database will possible use the loadable from a pin, and when clearing the history also deleting the loadable from the pin.
history.loadable = loadable.copy();
history.loadable.id = 0;
history.thumbnailUrl = chanLoader.getThread().op.thumbnailUrl; history.thumbnailUrl = chanLoader.getThread().op.thumbnailUrl;
databaseManager.addHistory(history); databaseManager.addHistory(history);
} }

Loading…
Cancel
Save