Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/MicroBlogAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const MICRO_BLOG_AUTH_URL = 'https://micro.blog/indieauth/auth';
export const MICRO_BLOG_TOKEN_URL = 'https://micro.blog/indieauth/token';
export const MICRO_BLOG_VERIFY_URL = 'https://micro.blog/account/verify';
export const MICRO_BLOG_CLIENT_ID = 'https://micro.ink/client.json';
export const MICRO_BLOG_SCOPE = 'create';
export const MICRO_BLOG_SCOPE = 'read write';
export const MICRO_BLOG_REDIRECT_PATH = 'auth/callback';

export function get_micro_blog_redirect_uri() {
Expand Down
46 changes: 40 additions & 6 deletions src/stores/Feed.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const HIDE_READ_POSTS_SETTINGS_KEY = 'HideReadPosts';
const FEED_TIMELINE_CACHE_DIRECTORY_NAME = 'inkwell';
const FEED_TIMELINE_CACHE_FILENAME_PREFIX = 'RecentEntries';
const FEED_ICONS_CACHE_FILENAME = 'Icons.json';
const FEED_TIMELINE_CACHE_VERSION = 1;
const FEED_TIMELINE_CACHE_VERSION = 2;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve local entry state when invalidating the cache

When users update with pending offline/failed read or bookmark changes saved in the v1 timeline cache, this version bump makes normalize_timeline_cache_payload reject the whole payload before restore_local_entry_state_from_cache can restore the local_*_entry_ids, so bootstrap falls back to the server unread/starred state and those queued local actions are never retried. If the entry snapshots need invalidating to recompute future dates, please still migrate the local ID arrays or invalidate only the entries.

Useful? React with 👍 / 👎.

const FEED_TIMELINE_CACHE_WRITE_DELAY_MS = 240;
const FEED_ICONS_CACHE_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;

Expand Down Expand Up @@ -2979,21 +2979,55 @@ function get_subscription_host(subscription = null) {

function resolve_published_at(entry = null) {
const normalized_published_at = normalize_string(entry?.published_at);
const created_at = normalize_string(entry?.created_at);

if (normalized_published_at) {
return normalized_published_at;
return resolve_effective_timeline_date(
normalized_published_at,
created_at,
);
}

const published_at = normalize_string(entry?.published);
if (published_at) {
return published_at;
return resolve_effective_timeline_date(published_at, created_at);
} else if (created_at) {
return created_at;
}

const created_at = normalize_string(entry?.created_at);
if (created_at) {
return new Date().toISOString();
}

function resolve_effective_timeline_date(
published_at = '',
created_at = '',
) {
if (created_at && is_future_timeline_day(published_at)) {
return created_at;
} else {
return published_at;
}
}

return new Date().toISOString();
function is_future_timeline_day(raw_date = '') {
const date = new Date(raw_date);
if (Number.isNaN(date.getTime())) {
return false;
}

const now = new Date();
const today_midnight = new Date(
now.getFullYear(),
now.getMonth(),
now.getDate(),
);
const entry_midnight = new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
);

return entry_midnight.getTime() > today_midnight.getTime();
}

function resolve_entry_read_state(
Expand Down