Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Jul 22, 2023
1 parent 526f8c4 commit f723402
Show file tree
Hide file tree
Showing 23 changed files with 120 additions and 82 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en" data-seventv-app>
<head>
<meta charset="utf-8" />
Expand Down
4 changes: 3 additions & 1 deletion src/app/chat/RichEmbed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ defineProps<{
<style scoped lang="scss">
.seventv-chat-message-rich-embed {
border-radius: 0.25rem;
box-shadow: 0 0.25rem 0.5rem var(--seventv-embed-border), 0 0 0.5rem var(--seventv-embed-border);
box-shadow:
0 0.25rem 0.5rem var(--seventv-embed-border),
0 0 0.5rem var(--seventv-embed-border);
background-color: var(--seventv-embed-background);
&:hover {
Expand Down
4 changes: 3 additions & 1 deletion src/app/emote-menu/EmoteMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ onClickOutside(containerRef, (ev) => {
font-size: 1.5em;
}
transition: width 120ms ease-in-out, background 150ms ease-in-out;
transition:
width 120ms ease-in-out,
background 150ms ease-in-out;
&[selected="true"] {
background: var(--seventv-highlight-neutral-1);
Expand Down
21 changes: 12 additions & 9 deletions src/app/emote-menu/EmoteMenuTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,18 @@ const filterSets = debounceFn(() => {
}
if (props.provider === "PLATFORM") {
const res = ary.reduce((accu, cur) => {
const p = accu[cur.name];
if (p) {
p.emotes.push(...cur.emotes);
} else {
accu[cur.name] = { set: cur, emotes: [...cur.emotes] };
}
return accu;
}, {} as Record<string, { set: SevenTV.EmoteSet; emotes: SevenTV.ActiveEmote[] }>);
const res = ary.reduce(
(accu, cur) => {
const p = accu[cur.name];
if (p) {
p.emotes.push(...cur.emotes);
} else {
accu[cur.name] = { set: cur, emotes: [...cur.emotes] };
}
return accu;
},
{} as Record<string, { set: SevenTV.EmoteSet; emotes: SevenTV.ActiveEmote[] }>,
);
ary.splice(0, ary.length, ...Object.values(res).map((e) => ({ ...e.set, emotes: e.emotes })));
}
Expand Down
6 changes: 4 additions & 2 deletions src/app/options/views/Onboarding/Onboarding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div v-if="ctx.activeStep" class="active-content">
<Transition name="step-animation" mode="out-in">
<KeepAlive>
<component :is="(ctx.activeStep.component as AnyInstanceType)" @completed="toStep(1)" />
<component :is="ctx.activeStep.component as AnyInstanceType" @completed="toStep(1)" />
</KeepAlive>
</Transition>
</div>
Expand Down Expand Up @@ -189,7 +189,9 @@ main.onboarding {
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
background: var(--seventv-muted);
margin: 0 0.25vw;
transition: background 0.25s ease, transform 140ms ease;
transition:
background 0.25s ease,
transform 140ms ease;
&:hover {
cursor: pointer;
Expand Down
4 changes: 3 additions & 1 deletion src/app/options/views/Onboarding/OnboardingConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ export const step: OnboardingStepRoute = {
// q animation
.question-enter-active,
.question-leave-active {
transition: transform 270ms cubic-bezier(0.48, 1.29, 0, -1.57), opacity 300ms;
transition:
transform 270ms cubic-bezier(0.48, 1.29, 0, -1.57),
opacity 300ms;
}
.question-enter-from,
Expand Down
2 changes: 1 addition & 1 deletion src/app/options/views/Onboarding/OnboardingPlatforms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
:selected="platform.selected"
@click="toggle(platform)"
>
<component :is="(platform.icon as AnyInstanceType)" />
<component :is="platform.icon as AnyInstanceType" />
</div>
</div>
<div v-t="'onboarding.platforms_mutable_note'" class="data" />
Expand Down
4 changes: 2 additions & 2 deletions src/app/paint-tool/PaintToolMaker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@
:component-type="PaintToolGradient"
grid-area="gradients"
:data="data.gradients"
@update="(d) => data.gradients = (d as SevenTV.CosmeticPaintGradient[])"
@update="(d) => (data.gradients = d as SevenTV.CosmeticPaintGradient[])"
/>
<PaintToolList
color="#f5e6ce"
:component-type="PaintToolShadow"
grid-area="shadows"
:data="data.shadows"
@update="(d) => data.shadows = (d as SevenTV.CosmeticPaintShadow[])"
@update="(d) => (data.shadows = d as SevenTV.CosmeticPaintShadow[])"
/>
<div class="text-mod"></div>
<div class="text"></div>
Expand Down
4 changes: 3 additions & 1 deletion src/app/settings/SettingsUpdateButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ function doUpdateCheck(): void {
border-radius: 0.25rem;
background: var(--seventv-background-shade-1);
color: var(--seventv-accent);
transition: background 0.25s ease-in-out, color 0.25s ease-in-out;
transition:
background 0.25s ease-in-out,
color 0.25s ease-in-out;
&:hover {
background: var(--seventv-accent);
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/egvault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const useEgVault = defineStore("egvault", {
products: [],
currentProduct: null,
currentPlan: null,
} as StoreState),
}) as StoreState,
getters: {
subscribed: (state) => state.subscription?.active ?? false,
subEndDate: (state) => (state.subscription?.end_at ? new Date(state.subscription.end_at) : new Date(0)),
Expand Down
2 changes: 1 addition & 1 deletion src/assets/svg/icons/IconForSettings.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<component :is="(c as AnyInstanceType)" />
<component :is="c as AnyInstanceType" />
</template>

<script setup lang="ts">
Expand Down
5 changes: 4 additions & 1 deletion src/common/Flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export const ActiveEmoteFlags = {
};

class BitFieldOps<T extends Record<string, number>> {
constructor(private e: T, public sum: number) {}
constructor(
private e: T,
public sum: number,
) {}

has(bit: keyof T): boolean {
return (this.sum & this.e[bit]) === this.e[bit];
Expand Down
2 changes: 1 addition & 1 deletion src/common/Tokenize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function tokenize(opt: TokenizeOptions) {
kind: "VOID",
range: [start, end],
content: void 0,
} as VoidToken);
}) as VoidToken;

for (const part of textParts) {
const next = cursor + (part.length + 1);
Expand Down
11 changes: 7 additions & 4 deletions src/common/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,10 +347,13 @@ export function convertTwitchMessage(d: TwTypeMessage): ChatMessage {
msg.author = d.sender ? convertTwitchUser(d.sender) : null;
msg.badges =
d.sender && Array.isArray(d.sender.displayBadges)
? d.sender.displayBadges.reduce((con, badge) => {
con[badge.setID] = badge.version;
return con;
}, {} as Record<string, string>)
? d.sender.displayBadges.reduce(
(con, badge) => {
con[badge.setID] = badge.version;
return con;
},
{} as Record<string, string>,
)
: {};
msg.timestamp = new Date(d.sentAt).getTime();

Expand Down
2 changes: 1 addition & 1 deletion src/common/chat/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Tokenizer {
kind: "VOID",
range: [start, end],
content: void 0,
} as VoidToken);
}) as VoidToken;

for (const part of textParts) {
const next = cursor + (part.length + 1);
Expand Down
86 changes: 46 additions & 40 deletions src/composable/chat/useChatMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,47 +166,53 @@ export function useChatMessages(ctx: ChannelContext) {
function flush(force?: boolean): void {
if (flushTimeout) return;

flushTimeout = window.setTimeout(() => {
if (scroller.paused) {
flushTimeout = undefined;
return;
}

if (scroller.init == true) scroller.init = false;

// push new messages
if (data.buffer.length > 0) {
const unbuf = data.buffer.splice(0, data.buffer.length);

// push to the render queue all unbuffered messages
data.displayed.push(...unbuf);
}

// scroll to the bottom on the next tick
nextTick(() => scroller.scrollToLive(scrollDuration.value));

// remove messages beyond the buffer
const overflowLimit = lineLimit.value * 1.25;
if (data.displayed.length > overflowLimit) {
flushTimeout = window.setTimeout(() => {
const removed = data.displayed.splice(0, data.displayed.length - lineLimit.value);
for (const msg of removed) {
if (!msg.author) continue;

// retrieve the user's message map
const umap = data.displayedByUser[msg.author.username];
if (!umap) continue;

// delete this specific message from the user's message map
delete umap[msg.id];
}

flushTimeout = window.setTimeout(
() => {
if (scroller.paused) {
flushTimeout = undefined;
}, (force ? 5 : batchTimeMs.value) / 1.5);
} else {
flushTimeout = undefined;
}
}, (force ? 5 : batchTimeMs.value) / 2);
return;
}

if (scroller.init == true) scroller.init = false;

// push new messages
if (data.buffer.length > 0) {
const unbuf = data.buffer.splice(0, data.buffer.length);

// push to the render queue all unbuffered messages
data.displayed.push(...unbuf);
}

// scroll to the bottom on the next tick
nextTick(() => scroller.scrollToLive(scrollDuration.value));

// remove messages beyond the buffer
const overflowLimit = lineLimit.value * 1.25;
if (data.displayed.length > overflowLimit) {
flushTimeout = window.setTimeout(
() => {
const removed = data.displayed.splice(0, data.displayed.length - lineLimit.value);
for (const msg of removed) {
if (!msg.author) continue;

// retrieve the user's message map
const umap = data.displayedByUser[msg.author.username];
if (!umap) continue;

// delete this specific message from the user's message map
delete umap[msg.id];
}

flushTimeout = undefined;
},
(force ? 5 : batchTimeMs.value) / 1.5,
);
} else {
flushTimeout = undefined;
}
},
(force ? 5 : batchTimeMs.value) / 2,
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/site/twitch.tv/modules/chat-input/ChatInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function findMatchingTokens(str: string, mode: "tab" | "colon" = "tab", limit?:
({
0: token.toLowerCase().startsWith(prefix),
1: token.toLowerCase().includes(prefix),
}[testMode]);
})[testMode];
for (const [token, ae] of Object.entries(cosmetics.emotes)) {
if (usedTokens.has(token) || !test(token)) continue;
Expand Down
7 changes: 5 additions & 2 deletions src/site/twitch.tv/modules/chat/components/mod/ModSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,11 @@ const update = (e: PointerEvent): void => {
white-space: nowrap;
width: 100%;
text-align: center;
text-shadow: 0.1em 0 0.2rem var(--color-background-body), 0 0.1em 0.2rem var(--color-background-body),
-0.1em 0 0.2rem var(--color-background-body), 0 -0.1em 0.2rem var(--color-background-body);
text-shadow:
0.1em 0 0.2rem var(--color-background-body),
0 0.1em 0.2rem var(--color-background-body),
-0.1em 0 0.2rem var(--color-background-body),
0 -0.1em 0.2rem var(--color-background-body);
transition: opacity 0.2s ease;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/site/twitch.tv/modules/mod-logs/ModLogs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<component :is="activeTab.icon" />
<span>{{ activeTab.name }}</span>
</p>
<component :is="(activeTab.com as AnyInstanceType)" />
<component :is="activeTab.com as AnyInstanceType" />
</template>
</div>
</UiScrollable>
Expand Down
2 changes: 1 addition & 1 deletion src/site/twitch.tv/modules/mod-logs/ModLogsModule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-for="con of chatController.instance?.chatController.instances ?? []"
:key="con.component.props.channelID"
:handle="com?.handle"
:initial-anchor="(buttonRef.current as HTMLDivElement)"
:initial-anchor="buttonRef.current as HTMLDivElement"
:initial-middleware="[shift({ padding: { bottom: 96, right: 8 }, crossAxis: true })]"
>
<ModLogs ref="com" :channel-id="con.component.props.channelID" @close="open = false" />
Expand Down
2 changes: 1 addition & 1 deletion src/store/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useStore = defineStore("main", {
workers: {
net: null,
},
} as State),
}) as State,

actions: {
setIdentity<T extends Platform>(platform: T, identity: PlatformIdentity<T> | null) {
Expand Down
21 changes: 14 additions & 7 deletions src/worker/worker.driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ export class WorkerDriver extends EventTarget {
this.ports.set(p.id, p);

// Do DB cleanup for unused data
setTimeout(() => {
const exemptions = Array.from(this.ports.values())
.filter((p) => p.channels.size)
.flatMap((p) => p.channelIds);
setTimeout(
() => {
const exemptions = Array.from(this.ports.values())
.filter((p) => p.channels.size)
.flatMap((p) => p.channelIds);

db.expireDocuments(exemptions);
}, getRandomInt(2500, 15000));
db.expireDocuments(exemptions);
},
getRandomInt(2500, 15000),
);

// Fetch config anew
this.http
Expand Down Expand Up @@ -148,7 +151,11 @@ type WorkerTypedEvent<EVN extends WorkerEventName> = {
}[EVN];

export class WorkerEvent<T extends WorkerEventName> extends CustomEvent<WorkerTypedEvent<T>> {
constructor(type: T, data: WorkerTypedEvent<T>, public port?: WorkerPort) {
constructor(
type: T,
data: WorkerTypedEvent<T>,
public port?: WorkerPort,
) {
super(type, { detail: data });
}
}
5 changes: 4 additions & 1 deletion src/worker/worker.port.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export class WorkerPort {
user: SevenTV.User | null = null;
imageFormat: SevenTV.ImageFormat | null = null;

constructor(private driver: WorkerDriver, private port: MessagePort) {
constructor(
private driver: WorkerDriver,
private port: MessagePort,
) {
this.id = Symbol("seventv-worker-port");
this.seq = driver.portSeq++ + 1;
this.driver.log.debug(`Port opened: #${this.seq.toString()}`);
Expand Down

0 comments on commit f723402

Please sign in to comment.