Skip to content

Commit 0d1af91

Browse files
committed
feat(settings): add emote settings
1 parent 3b37d3d commit 0d1af91

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

src/lib/components/settings/chat/Chat.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { settings } from "$lib/settings";
44
import Switch from "../../ui/Switch.svelte";
55
import Group from "../Group.svelte";
6+
import Emotes from "./Emotes.svelte";
67
import Messages from "./Messages.svelte";
78
89
const mentionStyles = [
@@ -62,6 +63,7 @@
6263
</Group>
6364
</Group>
6465

66+
<Emotes />
6567
<Messages />
6668
</div>
6769
</div>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script lang="ts">
2+
import Switch from "$lib/components/ui/Switch.svelte";
3+
import { settings } from "$lib/settings";
4+
import Group from "../Group.svelte";
5+
</script>
6+
7+
<Group title="Emotes">
8+
<Switch bind:checked={settings.state.chat.emotes.ffz}>
9+
<span class="font-medium">
10+
Show <a class="text-twitch-link" href="https://www.frankerfacez.com/">FrankerFaceZ</a> emotes
11+
</span>
12+
</Switch>
13+
14+
<Switch bind:checked={settings.state.chat.emotes.bttv}>
15+
<span class="font-medium">
16+
Show <a class="text-twitch-link" href="https://betterttv.com/">BetterTTV</a> emotes
17+
</span>
18+
</Switch>
19+
20+
<Switch bind:checked={settings.state.chat.emotes.seventv}>
21+
<span class="font-medium">
22+
Show <a class="text-twitch-link" href="https://7tv.app/">7TV</a> emotes
23+
</span>
24+
</Switch>
25+
</Group>

src/lib/managers/base-emote-manager.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
import { SvelteMap } from "svelte/reactivity";
22
import type { Emote } from "$lib/emotes";
3-
4-
export interface EmoteProviderOptions {
5-
ffz?: boolean;
6-
bttv?: boolean;
7-
seventv?: boolean;
8-
}
3+
import { settings } from "$lib/settings";
94

105
export abstract class BaseEmoteManager extends SvelteMap<string, Emote> {
116
public abstract fetchFfz(): Promise<Emote[]>;
127
public abstract fetchBttv(): Promise<Emote[]>;
138
public abstract fetch7tv(): Promise<Emote[]>;
149

1510
/**
16-
* Retrieves the list of emotes from the specified providers and caches them
17-
* for later use.
11+
* Retrieves the list of emotes from the providers enabled in the settings and
12+
* caches them for later use.
1813
*/
19-
public async fetch(options: EmoteProviderOptions = { ffz: true, bttv: true, seventv: true }) {
14+
public async fetch() {
2015
const promises: Promise<Emote[]>[] = [];
2116

22-
if (options.ffz) {
17+
if (settings.state.chat.emotes.ffz) {
2318
promises.push(this.fetchFfz());
2419
}
2520

26-
if (options.bttv) {
21+
if (settings.state.chat.emotes.bttv) {
2722
promises.push(this.fetchBttv());
2823
}
2924

30-
if (options.seventv) {
25+
if (settings.state.chat.emotes.seventv) {
3126
promises.push(this.fetch7tv());
3227
}
3328

src/lib/settings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ export interface AppearanceSettings {
1010
timestamps: TimestampSettings;
1111
}
1212

13+
export interface EmoteSettings {
14+
ffz: boolean;
15+
bttv: boolean;
16+
seventv: boolean;
17+
}
18+
1319
export interface MessageHistorySettings {
1420
enabled: boolean;
1521
limit: number;
@@ -20,6 +26,7 @@ export interface ChatSettings {
2026
mentionStyle: "none" | "colored" | "painted";
2127
localizedNames: boolean;
2228
readableColors: boolean;
29+
emotes: EmoteSettings;
2330
history: MessageHistorySettings;
2431
}
2532

@@ -91,6 +98,11 @@ export const settings = new RuneStore<Settings>("settings", {
9198
mentionStyle: "painted",
9299
localizedNames: true,
93100
readableColors: true,
101+
emotes: {
102+
ffz: true,
103+
bttv: true,
104+
seventv: true,
105+
},
94106
history: {
95107
enabled: true,
96108
limit: 250,

0 commit comments

Comments
 (0)