Browse Source

refactor(notifications): update supporting classes for new timestamp model

- Remove setFetchTime() calls from DailyNotificationFetchWorker
- Remove setFetchTime() calls from DailyNotificationFetcher
- Update DailyNotificationMaintenanceWorker to use getFetchedAt()
- Update DailyNotificationMigration to use getFetchedAt()
- Align all classes with immutable fetchedAt timestamp approach
- Ensure consistent timestamp handling across the codebase

These changes support the new timestamp model where fetchedAt
is immutable and set at object creation time.
master
Matthew Raymer 1 week ago
parent
commit
0d2be9619d
  1. 6
      android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationFetchWorker.java
  2. 6
      android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationFetcher.java
  3. 2
      android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationMaintenanceWorker.java
  4. 2
      android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationMigration.java

6
android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationFetchWorker.java

@ -385,7 +385,7 @@ public class DailyNotificationFetchWorker extends Worker {
content.setId("timesafari_fallback_" + System.currentTimeMillis());
content.setTitle("TimeSafari Update Available");
content.setBody("Your community updates are ready. Tap to view offers, projects, and connections.");
content.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
content.setScheduledTime(System.currentTimeMillis() + 30000); // 30 seconds from now
return content;
@ -448,7 +448,7 @@ public class DailyNotificationFetchWorker extends Worker {
fallbackContent.setSound(lastContent.isSound());
fallbackContent.setPriority(lastContent.getPriority());
fallbackContent.setUrl(lastContent.getUrl());
fallbackContent.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
return fallbackContent;
}
@ -474,7 +474,7 @@ public class DailyNotificationFetchWorker extends Worker {
content.setTitle("Daily Update");
content.setBody("🌅 Good morning! Ready to make today amazing?");
content.setScheduledTime(scheduledTime);
content.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
content.setPriority("default");
content.setSound(true);

6
android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationFetcher.java

@ -223,7 +223,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update");
content.setBody("Your daily notification is ready");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
return content;
@ -250,7 +250,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update");
content.setBody("Your daily notification is ready");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
Log.d(TAG, "Network response parsed successfully");
return content;
@ -296,7 +296,7 @@ public class DailyNotificationFetcher {
content.setTitle("Daily Update");
content.setBody("🌅 Good morning! Ready to make today amazing?");
content.setScheduledTime(System.currentTimeMillis() + TimeUnit.HOURS.toMillis(1));
content.setFetchTime(System.currentTimeMillis());
// fetchedAt is set in constructor, no need to set it again
content.setPriority("default");
content.setSound(true);

2
android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationMaintenanceWorker.java

@ -327,7 +327,7 @@ public class DailyNotificationMaintenanceWorker extends Worker {
return false;
}
if (notification.getFetchTime() <= 0) {
if (notification.getFetchedAt() <= 0) {
Log.w(TAG, "Data integrity issue: Invalid fetch time");
return false;
}

2
android/plugin/src/main/java/com/timesafari/dailynotification/DailyNotificationMigration.java

@ -177,7 +177,7 @@ public class DailyNotificationMigration {
values.put(DailyNotificationDatabase.COL_CONTENTS_PAYLOAD_JSON,
gson.toJson(notification));
values.put(DailyNotificationDatabase.COL_CONTENTS_FETCHED_AT,
notification.getFetchTime());
notification.getFetchedAt());
// ETag is null for migrated data
values.putNull(DailyNotificationDatabase.COL_CONTENTS_ETAG);

Loading…
Cancel
Save