Skip to content

Commit

Permalink
add sort time option + minor ui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KentoNishi committed Jun 9, 2024
1 parent ce0208b commit c6e8530
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
63 changes: 48 additions & 15 deletions src/components/Hyperchat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,27 @@
el.value = 'export';
};
const sortMessagesByShowtime = () => {
messageActions = messageActions.sort((a, b) => {
if (isWelcome(a)) return -1;
if (isWelcome(b)) return 1;
return a.message.showtime - b.message.showtime;
});
};
const executeActions = (e: any) => {
const el = (e.target as HTMLSelectElement);
switch (el.value) {
case 'sort':
sortMessagesByShowtime();
break;
case 'clear':
clearMessages();
break;
}
el.value = 'actions';
};
let archiveEmbedFrame = '';
const executeImport = async (e: any) => {
Expand Down Expand Up @@ -639,18 +660,20 @@
$: showWelcome = $initialized && (messageActions.length === 0 && !paramsArchiveKey);
const clearMessages = () => {
$confirmDialog = {
action: {
callback: () => {
messageKeys.clear();
messageActions = [];
},
text: 'Clear'
},
message: UNDONE_MSG,
title: 'Clear Messages?'
};
scrollToBottom();
// $confirmDialog = {
// action: {
// callback: () => {
// messageKeys.clear();
// messageActions = [];
// },
// text: 'Clear'
// },
// message: UNDONE_MSG,
// title: 'Clear Messages?'
// };
// scrollToBottom();
messageKeys.clear();
messageActions = [];
};
let key = '';
const initMessageStorage = async () => {
Expand Down Expand Up @@ -802,26 +825,36 @@
<option value="textfile">TXT</option>
<option value="jsondump">JSON</option>
</select>
<button use:exioButton on:click={clearMessages} class="whitespace-nowrap" disabled={showWelcome}>
<select use:exioDropdown style="width: 74px;" on:change={executeActions}>
<option selected disabled value="actions">Actions</option>
<option value="sort">Sort Time</option>
<option value="clear">Clear All</option>
</select>
<!-- <button use:exioButton on:click={clearMessages} class="whitespace-nowrap" disabled={showWelcome}>
Clear
<div use:exioIcon class="shifted-icon inline-block" style="color: inherit;">
close
</div>
</button>
</button> -->
{#if isPopout}
<button use:exioButton on:click={openSettings} class="inline-flex gap-1 items-center">
Settings
<div use:exioIcon class="inline-block" style="color: inherit;">
settings
</div>
</button>
{:else}
{:else if !paramsArchiveKey}
<button use:exioButton on:click={toggleTopBar} class="inline-flex gap-1 items-center">
Menu
<div use:exioIcon class="inline-block" style="color: inherit;">
unfold_{topBarVisible ? 'less' : 'more'}_double
</div>
</button>
<!-- <button use:exioButton on:click={toggleTopBar} class="inline-flex gap-1 items-center">
<div use:exioIcon class="inline-block text-error-500 dark:text-error-200">
close
</div>
</button> -->
{/if}
</div>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/MembershipItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
>
{#if $showProfileIcons}
<img
class="h-5 w-5 inline align-middle rounded-full flex-none mr-1"
class="h-5 w-5 inline align-middle rounded-full flex-none whitespace-nowrap overflow-hidden mr-1"
style="text-indent: 100%; max-width: 1.25rem;"
src={message.author.profileIcon.src}
alt={message.author.profileIcon.alt}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Message.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@
target="_blank"
>
<img
class="h-5 w-5 inline align-middle rounded-full flex-none"
class="h-5 w-5 inline align-middle rounded-full flex-none whitespace-nowrap overflow-hidden"
style="text-indent: 100%; max-width: 1.25rem;"
src={message.author.profileIcon.src}
alt={message.author.profileIcon.alt}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/components/TickerChip.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
>
{#if $showProfileIcons}
<img
class="h-5 w-5 inline align-middle rounded-full flex-none mr-1"
class="h-5 w-5 inline align-middle rounded-full flex-none whitespace-nowrap overflow-hidden mr-1"
style="text-indent: 100%; max-width: 1.25rem;"
src={item.author.profileIcon.src}
alt={item.author.profileIcon.alt}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/scripts/chat-injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ const chatLoaded = async (): Promise<void> => {
if (forceClose || ytcfilterElement.style.display === 'block') {
activatorText.textContent = 'Embed';
activatorIcon.textContent = 'expand';
// activatorButton.disabled = false;
ytcfilterElement.style.display = 'none';
resizeBar.style.display = 'none';
ytcfilterElement.style.display = 'none';
Expand All @@ -156,6 +157,7 @@ const chatLoaded = async (): Promise<void> => {
}
activatorText.textContent = 'Hide';
activatorIcon.textContent = 'cancel_presentation';
// activatorButton.disabled = true;
ytcfilterElement.style.display = 'block';
resizeBar.style.display = 'flex';
if (frame && frame.src !== source) {
Expand Down

0 comments on commit c6e8530

Please sign in to comment.