Skip to content

Commit

Permalink
fixed messages bug & added cmd + c shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashwagandhae committed Nov 9, 2022
1 parent 85c870f commit ec9143e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Evidencer",
"description": "Lets you scrape, highlight/underline, and export articles you see online as debate cards. ",
"version": "1.0",
"version": "1.1.1",
"manifest_version": 3,
"icons": {
"16": "/icons/app16.png",
Expand Down
18 changes: 11 additions & 7 deletions src/components/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@
) {
return;
}
if (e.key == 'c' && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
e.stopPropagation();
copyAndMessage();
}
if (e.key == 'p' && !(e.metaKey || e.ctrlKey || e.shiftKey)) {
e.preventDefault();
e.stopPropagation();
Expand Down Expand Up @@ -156,6 +161,10 @@
}
);
}
function copyAndMessage() {
copyCard($card, shrunk);
messenger.addMessage('Copied to clipboard!');
}
</script>

<svelte:window on:keydown={handleKeydown} />
Expand All @@ -169,12 +178,8 @@
><Icon name="popout" /></Button
>
{/if}
<Button
tooltip={'Copy card'}
on:click={() => {
copyCard($card, shrunk);
messenger.addMessage('Copied to clipboard!');
}}><Icon name="copy" /></Button
<Button tooltip={'Copy card'} on:click={copyAndMessage}
><Icon name="copy" /></Button
>
<Button on:click={animateReload} tooltip={'Reset card'}
><Icon name="reload" /></Button
Expand All @@ -185,7 +190,6 @@
<div class="card" on:scroll={handleScroll} bind:this={cardElement}>
<div class="tag" class:moreWidth={context != 'popup'}>
<Text
autofocus
bind:this={tagText}
bind:text={$card.tag}
placeholder="Type tag here..."
Expand Down
18 changes: 12 additions & 6 deletions src/components/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export let tooltipState = writable({

class Messenger {
messages: Writable<IMessage[]>;
timeouts: NodeJS.Timeout[];
constructor() {
this.messages = writable([]);
this.timeouts = [];
}
addMessage(text: string) {
// add message and removes them after 5 seconds
Expand All @@ -19,13 +21,17 @@ class Messenger {
// trim if longer than 5 seconds
if (messages.length > 3) {
messages.shift();
clearTimeout(this.timeouts.shift());
}
setTimeout(() => {
this.messages.update((messages) => {
messages.shift();
return messages;
});
}, 5000);
this.timeouts.push(
setTimeout(() => {
this.messages.update((messages) => {
messages.shift();
return messages;
});
this.timeouts.shift();
}, 5000)
);
return messages;
});
}
Expand Down

0 comments on commit ec9143e

Please sign in to comment.