Skip to content
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

feat/block-chat-phrases: Add blocked phrases feature #514

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1142762
feat/block-chat-phrases: Add blocked phrases feature
berghall Apr 15, 2023
11d27dd
feat/block-chat-phrases: Use Object.values instead of for..in
berghall Apr 15, 2023
3b46c7e
feat/block-chat-phrases: Fix CI issues
berghall Apr 15, 2023
feb3fba
feat/block-chat-phrases: Remove unnecessary loop keys
berghall Apr 15, 2023
30d9dac
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 17, 2023
94e5bda
feat/block-chat-phrases: A highlight can now be blocked
berghall Apr 17, 2023
b7d9264
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 17, 2023
1056671
feat/block-chat-phrases: make format
berghall Apr 17, 2023
5bccbeb
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 18, 2023
3365c30
feat/block-chat-phrases: Untracked .github issue templates
berghall Apr 18, 2023
57a282a
feat/block-chat-phrases: Change terminology from blocked to ignore
berghall Apr 18, 2023
b380930
feat/block-chat-phrases: make format
berghall Apr 18, 2023
7d57472
feat/block-chat-phrases: Move ignores into their own settings section
berghall Apr 19, 2023
d8937ea
feat/block-chat-phrases: make format
berghall Apr 19, 2023
faf5544
feat/block-chat-phrases: fix js lints
berghall Apr 19, 2023
617b76e
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 19, 2023
9cee1eb
feat/block-chat-phrases: Fix build and update changelog
berghall Apr 19, 2023
c50e09c
feat/block-chat-phrases: Remove unused import
berghall Apr 19, 2023
f9de628
feat/block-chat-phrases: Re-use highlight template and composable for…
berghall Apr 20, 2023
04252a8
feat/block-chat-phrases: make format and lint
berghall Apr 20, 2023
5725559
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 22, 2023
f25d427
feat/block-chat-phrases: Add wrapper for ignores
berghall Apr 22, 2023
50b4a1d
feat/block-chat-phrases: make format
berghall Apr 22, 2023
5df40d2
feat/block-chat-phrases: fix types
berghall Apr 22, 2023
fc39a41
feat/block-chat-phrases: Update CHANGELOG
berghall Apr 24, 2023
fe04601
Merge branch 'master' into feat/block-chat-phrases
berghall Apr 27, 2023
9ef161d
Update CHANGELOG
berghall May 9, 2023
94ed48d
Merge branch 'master' into feat/block-chat-phrases
berghall May 12, 2023
8d03aae
Merge master
berghall May 18, 2023
e9d0976
Merge branch 'master' into feat/block-chat-phrases
berghall May 20, 2023
09f7872
Merge branch 'master' into feat/block-chat-phrases
berghall Jul 20, 2023
8be7ad4
Merge branch 'feat/block-chat-phrases' of github.com:berghall/Extensi…
berghall Jul 20, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG-nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
- Added icons for emoji sets in the Emote Menu
- Added an option to choose chat timestamp format
- Fixed tooltips of nametag paints appearing even if they are disabled
- Added an option to ignore messages in chat settings
- Reinstated functionality on youtube.com

### Version 3.0.6.1000
Expand Down
79 changes: 52 additions & 27 deletions src/app/settings/SettingsConfigHighlights.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<div class="item heading">
<div>Pattern</div>
<div>Label</div>
<div class="centered">Flash Title</div>
<div class="centered">RegExp</div>
<div>Case Sensitive</div>
<div>Color</div>
<div v-if="!useIgnores" class="centered">Flash Title</div>
<div v-if="!useIgnores">Color</div>
</div>

<UiScrollable>
Expand All @@ -34,11 +34,6 @@
/>
</div>

<!-- Checkbox: Flash Title -->
<div name="flash-title" class="centered">
<FormCheckbox :checked="!!h.flashTitle" @update:checked="onFlashTitleChange(h, $event)" />
</div>

<!-- Checkbox: RegExp -->
<div name="is-regexp" class="centered">
<FormCheckbox :checked="!!h.regexp" @update:checked="onRegExpStateChange(h, $event)" />
Expand All @@ -52,12 +47,27 @@
/>
</div>

<!-- Checkbox: Flash Title -->
<div name="flash-title" class="centered">
<FormCheckbox
v-if="!useIgnores && isHighlight(h)"
:checked="!!h.flashTitle"
@update:checked="onFlashTitleChange(h, $event)"
/>
</div>

<div name="color">
<input v-model="h.color" type="color" @input="onColorChange(h, $event as InputEvent)" />
<input
v-if="!useIgnores && isHighlight(h)"
v-model="h.color"
type="color"
@input="onColorChange(h, $event as InputEvent)"
/>
</div>

<div ref="interactRef" name="interact">
<button
v-if="!useIgnores && isHighlight(h)"
ref="soundEffectButton"
class="sound-button"
:class="{ 'has-sound': !!h.soundFile }"
Expand Down Expand Up @@ -96,7 +106,7 @@
<!-- New -->
<div class="item create-new">
<div name="pattern">
<FormInput v-model="newInput" label="New Highlight..."> hi </FormInput>
<FormInput v-model="newInput" :label="newLabel"></FormInput>
</div>
</div>
</div>
Expand All @@ -106,7 +116,13 @@
<script setup lang="ts">
import { nextTick, reactive, ref, watch } from "vue";
import { useChannelContext } from "@/composable/channel/useChannelContext";
import { HighlightDef, useChatHighlights } from "@/composable/chat/useChatHighlights";
import {
HighlightDef,
HighlightType,
IgnoreDef,
isHighlight,
useChatHighlights,
} from "@/composable/chat/useChatHighlights";
import FormCheckbox from "@/site/global/components/FormCheckbox.vue";
import FormInput from "@/site/global/components/FormInput.vue";
import CloseIcon from "@/assets/svg/icons/CloseIcon.vue";
Expand All @@ -115,29 +131,33 @@ import UiFloating from "@/ui/UiFloating.vue";
import UiScrollable from "@/ui/UiScrollable.vue";
import { v4 as uuid } from "uuid";

const ctx = useChannelContext(); // this will be an empty context, as config is not tied to channel
const highlights = useChatHighlights(ctx);
const props = defineProps<{
useIgnores?: boolean;
}>();

const ctx = useChannelContext(); // this will be an empty context, as config is not tied to channel
const highlights = useChatHighlights(ctx, props.useIgnores);
const newInput = ref("");
const inputs = reactive({
pattern: new WeakMap<HighlightDef, InstanceType<typeof FormInput>>(),
label: new WeakMap<HighlightDef, InstanceType<typeof FormInput>>(),
pattern: new WeakMap<HighlightType, InstanceType<typeof FormInput>>(),
label: new WeakMap<HighlightType, InstanceType<typeof FormInput>>(),
});
const interactRef = ref<HTMLElement[]>();
const newLabel = `New ${props.useIgnores ? "Ignore" : "Highlight"}`;

function onInputFocus(h: HighlightDef, inputName: keyof typeof inputs): void {
function onInputFocus(h: HighlightType, inputName: keyof typeof inputs): void {
const input = inputs[inputName].get(h);
if (!input) return;

input.focus();
}

function onInputBlur(h: HighlightDef, inputName: keyof typeof inputs): void {
function onInputBlur(h: HighlightType, inputName: keyof typeof inputs): void {
const input = inputs[inputName].get(h);
if (!input) return;

const id = uuid();
highlights.updateId("new-highlight", id);
highlights.updateId(props.useIgnores ? "new-ignore" : "new-highlight", id);
highlights.save();
}

Expand All @@ -147,12 +167,12 @@ function onFlashTitleChange(h: HighlightDef, checked: boolean): void {
highlights.save();
}

function onRegExpStateChange(h: HighlightDef, checked: boolean): void {
function onRegExpStateChange(h: HighlightType, checked: boolean): void {
h.regexp = checked;
highlights.save();
}

function onCaseSensitiveChange(h: HighlightDef, checked: boolean): void {
function onCaseSensitiveChange(h: HighlightType, checked: boolean): void {
h.caseSensitive = checked;
highlights.save();
}
Expand Down Expand Up @@ -210,7 +230,7 @@ function onRemoveSound(h: HighlightDef): void {
highlights.save();
}

function onDeleteHighlight(h: HighlightDef): void {
function onDeleteHighlight(h: HighlightType): void {
highlights.remove(h.id);
highlights.save();
}
Expand All @@ -220,13 +240,18 @@ function onDeleteHighlight(h: HighlightDef): void {
watch(newInput, (val, old) => {
if (!val || old) return;

const ignoreDef: Omit<IgnoreDef, "id"> = {
label: "",
pattern: val,
};
const highlightDef: Omit<HighlightDef, "id"> = {
...ignoreDef,
color: "#8803fc",
};

const h = highlights.define(
"new-highlight",
{
color: "#8803fc",
label: "",
pattern: val,
},
props.useIgnores ? "new-ignore" : "new-highlight",
props.useIgnores ? ignoreDef : highlightDef,
true,
);

Expand Down Expand Up @@ -265,7 +290,7 @@ main.seventv-settings-custom-highlights {
.item {
display: grid;
grid-auto-flow: row dense;
grid-template-columns: 20% 9rem 1fr 1fr 1fr 1fr 1fr;
grid-template-columns: 20% 9rem repeat(6, 1fr);
column-gap: 3rem;
padding: 1rem;

Expand Down
7 changes: 7 additions & 0 deletions src/app/settings/SettingsConfigIgnoresWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<SettingsConfigHighlights :use-ignores="true" />
</template>

<script setup lang="ts">
import SettingsConfigHighlights from "./SettingsConfigHighlights.vue";
</script>
Loading
Loading