Skip to content

Commit cfcc572

Browse files
committed
Move IAM cache cleaning to OSInAppMessageController
* IAM database access and all regarding IAM should live in OSInAppMessageController
1 parent 47a85e3 commit cfcc572

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageController.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
class OSInAppMessageController implements OSDynamicTriggerControllerObserver, OSSystemConditionController.OSSystemConditionObserver {
2727

2828
private static final Object LOCK = new Object();
29+
private final static String OS_DELETE_CACHED_REDISPLAYED_IAMS_THREAD = "OS_DELETE_CACHED_REDISPLAYED_IAMS_THREAD";
2930
private static final String OS_SAVE_IN_APP_MESSAGE = "OS_SAVE_IN_APP_MESSAGE";
3031
public static final String IN_APP_MESSAGES_JSON_KEY = "in_app_messages";
3132
private static ArrayList<String> PREFERRED_VARIANT_ORDER = new ArrayList<String>() {{
@@ -826,6 +827,23 @@ void onSuccess(String response) {
826827
}, null);
827828
}
828829

830+
/**
831+
* Remove IAMs that the last display time was six month ago
832+
* 1. Query for all old message ids and old clicked click ids
833+
* 2. Delete old IAMs from SQL
834+
* 3. Use queried data to clean SharedPreferences
835+
*/
836+
void cleanCachedInAppMessages() {
837+
new Thread(new Runnable() {
838+
@Override
839+
public void run() {
840+
Thread.currentThread().setPriority(Process.THREAD_PRIORITY_BACKGROUND);
841+
842+
inAppMessageRepository.cleanCachedInAppMessages();
843+
}
844+
}, OS_DELETE_CACHED_REDISPLAYED_IAMS_THREAD).start();
845+
}
846+
829847
/**
830848
* Part of redisplay logic
831849
* <p>

OneSignalSDK/onesignal/src/main/java/com/onesignal/OSInAppMessageRepository.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ synchronized void cleanCachedInAppMessages() {
147147
* Note: This should only ever be called by {@link OSInAppMessageRepository#cleanCachedInAppMessages()}
148148
* <br/><br/>
149149
*
150-
* @see OneSignalCacheCleaner#cleanCachedInAppMessages(OneSignalDbHelper)
151150
* @see OSInAppMessageRepository#cleanCachedInAppMessages()
152151
*/
153152
private void cleanInAppMessageIds(Set<String> oldMessageIds) {
@@ -187,7 +186,6 @@ private void cleanInAppMessageIds(Set<String> oldMessageIds) {
187186
* Note: This should only ever be called by {@link OSInAppMessageRepository#cleanCachedInAppMessages()}
188187
* <br/><br/>
189188
*
190-
* @see OneSignalCacheCleaner#cleanCachedInAppMessages(OneSignalDbHelper)
191189
* @see OSInAppMessageRepository#cleanCachedInAppMessages()
192190
*/
193191
private void cleanInAppMessageClickedClickIds(Set<String> oldClickedClickIds) {

0 commit comments

Comments
 (0)