Skip to content

Commit

Permalink
Revert SafeDate change because it does not avoid crash (#1583)
Browse files Browse the repository at this point in the history
  • Loading branch information
mchowning authored Dec 1, 2023
1 parent b034fb8 commit d739891
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 74 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
* Bug Fixes:
* Ensure we have the most up-to-date episode urls before attempting playback
([#1561](https://github.com/Automattic/pocket-casts-android/pull/1561))
* Prevent crash if database is missing date episode is published
([#1573](https://github.com/Automattic/pocket-casts-android/pull/1573))

7.52
-----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package au.com.shiftyjelly.pocketcasts.models.converter

import androidx.room.TypeConverter
import io.sentry.Sentry
import timber.log.Timber
import java.time.Instant
import java.util.Date

class DateTypeConverter {
Expand All @@ -18,29 +15,3 @@ class DateTypeConverter {
return value?.time
}
}

typealias SafeDate = Date

// Type converter for dates that will not return null even if a null parameter is passed in.
class SafeDateTypeConverter {

@TypeConverter
fun toDate(value: Long?): SafeDate {
return if (value == null) {
"ShouldNotBeNullDateTypeConverter::toDate called with null parameter. Returning epoch date.".let {
Timber.w(it)
Sentry.addBreadcrumb(it)
}
EPOCH
} else {
Date(value)
}
}

@TypeConverter
fun toLong(value: SafeDate?): Long = value?.time ?: 0L

companion object {
private val EPOCH = Date(Instant.EPOCH.toEpochMilli())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import au.com.shiftyjelly.pocketcasts.models.converter.EpisodesSortTypeConverter
import au.com.shiftyjelly.pocketcasts.models.converter.PodcastAutoUpNextConverter
import au.com.shiftyjelly.pocketcasts.models.converter.PodcastLicensingEnumConverter
import au.com.shiftyjelly.pocketcasts.models.converter.PodcastsSortTypeConverter
import au.com.shiftyjelly.pocketcasts.models.converter.SafeDateTypeConverter
import au.com.shiftyjelly.pocketcasts.models.converter.SyncStatusConverter
import au.com.shiftyjelly.pocketcasts.models.converter.TrimModeTypeConverter
import au.com.shiftyjelly.pocketcasts.models.converter.UserEpisodeServerStatusConverter
Expand Down Expand Up @@ -70,7 +69,6 @@ import au.com.shiftyjelly.pocketcasts.localization.R as LR
AnonymousBumpStat.CustomEventPropsTypeConverter::class,
BundlePaidTypeConverter::class,
DateTypeConverter::class,
SafeDateTypeConverter::class,
EpisodePlayingStatusConverter::class,
EpisodeStatusEnumConverter::class,
EpisodesSortTypeConverter::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import au.com.shiftyjelly.pocketcasts.localization.R
import au.com.shiftyjelly.pocketcasts.models.converter.SafeDate
import au.com.shiftyjelly.pocketcasts.models.type.EpisodePlayingStatus
import au.com.shiftyjelly.pocketcasts.models.type.EpisodeStatusEnum
import java.io.Serializable
Expand All @@ -24,7 +23,7 @@ import java.util.Date
data class PodcastEpisode(
@PrimaryKey(autoGenerate = false) @ColumnInfo(name = "uuid") override var uuid: String,
@ColumnInfo(name = "episode_description") override var episodeDescription: String = "",
@ColumnInfo(name = "published_date") override var publishedDate: SafeDate,
@ColumnInfo(name = "published_date") override var publishedDate: Date,
@ColumnInfo(name = "title") override var title: String = "",
@ColumnInfo(name = "size_in_bytes") override var sizeInBytes: Long = 0,
@ColumnInfo(name = "episode_status") override var episodeStatus: EpisodeStatusEnum = EpisodeStatusEnum.NOT_DOWNLOADED,
Expand Down

This file was deleted.

0 comments on commit d739891

Please sign in to comment.