Skip to content

Add timestamp to Redirect/Summary banners with the time they happened #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: mv2
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions src/components/ChatSummary.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Icon from 'smelte/src/components/Icon';
import { Theme } from '../ts/chat-constants';
import { createEventDispatcher } from 'svelte';
import { showTimestamps } from '../ts/storage';

export let summary: Ytc.ParsedSummary;

Expand Down Expand Up @@ -55,6 +56,11 @@
<span class="align-middle">{run.text}</span>
{/if}
{/each}
{#if summary.timestamp && $showTimestamps}
<span class="text-xs ml-1 text-gray-400 dark:text-gray-600 align-middle">
{summary.timestamp}
</span>
{/if}
</div>
<div class="flex-none self-end" style="transform: translateY(3px);">
<Tooltip offsetY={0} small>
Expand Down
9 changes: 7 additions & 2 deletions src/components/RedirectBanner.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import { slide, fade } from 'svelte/transition';
import MessageRun from './MessageRuns.svelte';
import Tooltip from './common/Tooltip.svelte';
import Button from 'smelte/src/components/Button';
import Icon from 'smelte/src/components/Icon';
import { Theme } from '../ts/chat-constants';
import { createEventDispatcher } from 'svelte';
import { showProfileIcons } from '../ts/storage';
import Button from 'smelte/src/components/Button';
import { showProfileIcons, showTimestamps } from '../ts/storage';

export let redirect: Ytc.ParsedRedirect;

Expand Down Expand Up @@ -53,6 +53,11 @@
</Icon>
</span>
<span class="align-middle">Live Redirect Notice</span>
{#if redirect.timestamp && $showTimestamps}
<span class="text-xs ml-1 text-gray-400 dark:text-gray-600 align-middle">
{redirect.timestamp}
</span>
{/if}
</div>
<div class="flex-none self-end" style="transform: translateY(3px);">
<Tooltip offsetY={0} small>
Expand Down
2 changes: 2 additions & 0 deletions src/ts/chat-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ const parseChatSummary = (renderer: Ytc.AddChatItem, actionId: string, showtime:
message: splitRuns[2],
},
showtime: showtime,
timestamp: formatTimestamp(Date.now() * 1000),
};
return item;
}
Expand Down Expand Up @@ -132,6 +133,7 @@ const parseRedirectBanner = (renderer: Ytc.AddChatItem, actionId: string, showti
}
},
showtime: showtime,
timestamp: formatTimestamp(Date.now() * 1000),
};
return item;
}
Expand Down
2 changes: 2 additions & 0 deletions src/ts/typings/ytc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,7 @@ declare namespace Ytc {
message: ParsedRun[];
};
showtime: number;
timestamp?: string;
}

interface ParsedRedirect {
Expand All @@ -503,6 +504,7 @@ declare namespace Ytc {
}
};
showtime: number;
timestamp?: string;
}

interface ParsedPoll {
Expand Down