Skip to content

Commit 2048699

Browse files
authored
feat: new extensions notice + checks (#1232)
1 parent 317291c commit 2048699

11 files changed

Lines changed: 181 additions & 25 deletions

File tree

.vscode/settings.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,9 @@
3232
},
3333
"[typescript]": {
3434
"editor.defaultFormatter": "esbenp.prettier-vscode"
35-
}
35+
},
36+
"i18n-ally.localesPaths": [
37+
"locale",
38+
"src/i18n"
39+
]
3640
}

CHANGELOG-nightly.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 3.1.21.1000
2+
3+
- Added new extension notice
4+
- Added checks to see if new extension is running
5+
16
### 3.1.20.2000
27

38
- Fixed an issue causing emote cards to not display all info

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 3.1.21
2+
3+
- Added new extension notice
4+
- Added checks to see if new extension is running
5+
16
### 3.1.20
27

38
- Fixed some lint issues

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"displayName": "7TV",
44
"description": "Improve your viewing experience on Twitch & YouTube with new features, emotes, vanity and performance.",
55
"private": true,
6-
"version": "3.1.20",
7-
"dev_version": "2.0",
6+
"version": "3.1.21",
7+
"dev_version": "1.0",
88
"scripts": {
99
"start": "cross-env NODE_ENV=dev yarn build:dev && cross-env NODE_ENV=dev vite --mode dev",
1010
"build:section:app": "vite build --config vite.config.mts",

src/app/settings/Settings.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const Store = defineAsyncComponent(() => import("@/app/store/Store.vue"));
1212
class SettingsMenuContext {
1313
open = false;
1414
view: AnyInstanceType | null = null;
15+
newExtensionNoticeDismissed = false;
16+
newExtensionNoticeSeen = false;
1517

1618
category = "";
1719
scrollpoint = "";
@@ -31,6 +33,10 @@ class SettingsMenuContext {
3133
this.seen.push(key);
3234
}
3335
}
36+
37+
this.newExtensionNoticeDismissed =
38+
localStorage.getItem(LOCAL_STORAGE_KEYS.NEW_EXTENSION_NOTICE_DISMISSED) === "true";
39+
this.newExtensionNoticeSeen = localStorage.getItem(LOCAL_STORAGE_KEYS.NEW_EXTENSION_NOTICE_SEEN) === "true";
3440
}
3541

3642
toggle(): void {
@@ -49,6 +55,18 @@ class SettingsMenuContext {
4955

5056
localStorage.setItem(LOCAL_STORAGE_KEYS.SEEN_SETTINGS, this.seen.join(","));
5157
}
58+
59+
dismissNewExtensionNotice(): void {
60+
this.newExtensionNoticeDismissed = true;
61+
localStorage.setItem(LOCAL_STORAGE_KEYS.NEW_EXTENSION_NOTICE_DISMISSED, "true");
62+
}
63+
64+
markNewExtensionNoticeSeen(): void {
65+
if (this.newExtensionNoticeSeen) return;
66+
67+
this.newExtensionNoticeSeen = true;
68+
localStorage.setItem(LOCAL_STORAGE_KEYS.NEW_EXTENSION_NOTICE_SEEN, "true");
69+
}
5270
}
5371

5472
const views = {

src/app/settings/SettingsMenu.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,10 @@ function updateSidebarExpansionIndicator() {
246246
shouldShowSidebarExpansion.value = container.scrollTop < 3 && container.scrollHeight > container.clientHeight;
247247
}
248248
249-
onMounted(() => updateSidebarExpansionIndicator());
249+
onMounted(() => {
250+
ctx.markNewExtensionNoticeSeen();
251+
updateSidebarExpansionIndicator();
252+
});
250253
251254
function scrollSidebarToNextPage() {
252255
const container = sidebarScroller.value?.container;

src/app/settings/SettingsViewHome.vue

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22
<div class="seventv-settings-home">
33
<div class="seventv-settings-home-body">
44
<UiScrollable>
5+
<div v-if="!ctx.newExtensionNoticeDismissed" class="seventv-settings-new-extension-notice">
6+
<div class="seventv-settings-new-extension-copy">
7+
<strong>Try the new 7TV extension</strong>
8+
<span>Give the new 7TV extension a try and see what we've been working on.</span>
9+
</div>
10+
<div class="seventv-settings-new-extension-actions">
11+
<UiButton class="ui-button-important" @click="openNewExtension">Check it out</UiButton>
12+
<button
13+
v-tooltip="'Dismiss'"
14+
aria-label="Dismiss notice"
15+
class="seventv-settings-new-extension-dismiss"
16+
type="button"
17+
@click="ctx.dismissNewExtensionNotice()"
18+
>
19+
<CloseIcon />
20+
</button>
21+
</div>
22+
</div>
523
<div class="seventv-settings-home-changelog">
624
<Changelog />
725
</div>
@@ -25,8 +43,12 @@
2543
</div>
2644
</template>
2745
<script setup lang="ts">
46+
import { useUserAgent } from "@/composable/useUserAgent";
2847
import Changelog from "@/site/global/Changelog.vue";
48+
import CloseIcon from "@/assets/svg/icons/CloseIcon.vue";
2949
import CloudIcon from "@/assets/svg/icons/CloudIcon.vue";
50+
import { useSettingsMenu } from "./Settings";
51+
import UiButton from "@/ui/UiButton.vue";
3052
import UiScrollable from "@/ui/UiScrollable.vue";
3153
3254
const appName = import.meta.env.VITE_APP_NAME;
@@ -35,6 +57,18 @@ const appServer = import.meta.env.VITE_APP_API ?? "Offline";
3557
const version = import.meta.env.VITE_APP_VERSION;
3658
const isRemote = seventv.hosted || false;
3759
const remoteVersion = seventv.host_manifest?.version;
60+
61+
const ctx = useSettingsMenu();
62+
const { browser } = useUserAgent();
63+
64+
function openNewExtension(): void {
65+
const url =
66+
browser.name === "Firefox"
67+
? "https://addons.mozilla.org/en-US/firefox/addon/7tv-new/"
68+
: "https://chromewebstore.google.com/detail/7tv/lppmekppnliemjclknbagdhoocikieoi";
69+
70+
window.open(url, "_blank");
71+
}
3872
</script>
3973
<style scoped lang="scss">
4074
.seventv-settings-home {
@@ -47,6 +81,61 @@ const remoteVersion = seventv.host_manifest?.version;
4781
min-width: 30rem;
4882
overflow: auto;
4983
84+
.seventv-settings-new-extension-notice {
85+
display: grid;
86+
grid-template-columns: 1fr auto;
87+
align-items: center;
88+
column-gap: 1rem;
89+
padding: 1rem 1.25rem;
90+
border-top: 0.1rem solid var(--seventv-primary);
91+
border-bottom: 0.1rem solid var(--seventv-border-transparent-1);
92+
background-color: var(--seventv-background-shade-3);
93+
94+
.seventv-settings-new-extension-copy {
95+
display: grid;
96+
gap: 0.35rem;
97+
min-width: 0;
98+
99+
> strong {
100+
color: var(--seventv-text-color-normal);
101+
font-size: 1.3rem;
102+
}
103+
104+
> span {
105+
color: var(--seventv-text-color-secondary);
106+
line-height: 1.35;
107+
}
108+
}
109+
110+
.seventv-settings-new-extension-actions {
111+
display: flex;
112+
align-items: center;
113+
gap: 0.75rem;
114+
min-height: 3rem;
115+
}
116+
117+
.seventv-settings-new-extension-dismiss {
118+
all: unset;
119+
cursor: pointer;
120+
display: grid;
121+
place-items: center;
122+
width: 3rem;
123+
height: 3rem;
124+
border-radius: 0.25rem;
125+
color: var(--seventv-text-color-secondary);
126+
127+
&:hover {
128+
background-color: var(--seventv-highlight-neutral-1);
129+
color: var(--seventv-text-color-normal);
130+
}
131+
132+
> svg {
133+
width: 1.25rem;
134+
height: 1.25rem;
135+
}
136+
}
137+
}
138+
50139
.seventv-settings-home-changelog {
51140
flex-grow: 1;
52141
}

src/common/Constant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const LOCAL_STORAGE_KEYS = {
66
WORKER_ADDR: "seventv_worker_addr",
77
SEEN_SETTINGS: "seventv_seen_settings",
88
APP_TOKEN: "seventv_app_token",
9+
NEW_EXTENSION_NOTICE_DISMISSED: "seventv_new_extension_notice_dismissed",
10+
NEW_EXTENSION_NOTICE_SEEN: "seventv_new_extension_notice_seen",
911
};
1012

1113
export const REACT_TYPEOF_TOKEN = "$$typeof";

src/content/content.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { APP_BROADCAST_CHANNEL } from "@/common/Constant";
22
import { insertEmojiVectors } from "./emoji";
33

4+
const SEVENTV_EXTENSION_EVENT = "seventv:extension-presence";
5+
const SEVENTV_EXTENSION_LEGACY = "legacy";
6+
const SEVENTV_EXTENSION_NEXT = "next";
7+
8+
function hasNextExtension(): boolean {
9+
return document.documentElement.dataset.seventvExtension === SEVENTV_EXTENSION_NEXT;
10+
}
11+
12+
function markLegacyRunning(): void {
13+
document.documentElement.dataset.seventvExtension = SEVENTV_EXTENSION_LEGACY;
14+
window.dispatchEvent(new Event(SEVENTV_EXTENSION_EVENT));
15+
}
16+
417
// Inject extension into site
518
const inject = () => {
619
// Script
@@ -33,10 +46,14 @@ const inject = () => {
3346
}, 1e3);
3447
};
3548

36-
const bc = new BroadcastChannel(APP_BROADCAST_CHANNEL);
3749
(() => {
50+
if (hasNextExtension()) return;
51+
52+
markLegacyRunning();
3853
inject();
3954

55+
const bc = new BroadcastChannel(APP_BROADCAST_CHANNEL);
56+
4057
// Listen for requests to set up an extension permission
4158
bc.addEventListener("message", (ev) => {
4259
switch (ev.data.type) {
@@ -82,31 +99,23 @@ const bc = new BroadcastChannel(APP_BROADCAST_CHANNEL);
8299
chrome.runtime.onMessage.addListener((msg) => {
83100
switch (msg.type) {
84101
case "update-ready": {
85-
onUpdateDownloaded(msg.data.version ?? "");
102+
bc.postMessage({
103+
type: "seventv-update-ready",
104+
data: { version: msg.data.version ?? "" },
105+
});
86106
break;
87107
}
88108
case "settings-sync": {
89-
onSettingsUpdated(msg.data.settings ?? []);
109+
bc.postMessage({
110+
type: "seventv-settings-sync",
111+
data: { nodes: msg.data.settings ?? [] },
112+
});
90113
break;
91114
}
92115
}
93116
});
94117
})();
95118

96-
function onUpdateDownloaded(version: string): void {
97-
bc.postMessage({
98-
type: "seventv-update-ready",
99-
data: { version },
100-
});
101-
}
102-
103-
function onSettingsUpdated(settings: SevenTV.Setting<SevenTV.SettingNode>[]): void {
104-
bc.postMessage({
105-
type: "seventv-settings-sync",
106-
data: { nodes: settings },
107-
});
108-
}
109-
110119
interface PermissionRequestEvent {
111120
selector: string;
112121
id: string;

src/site/site.app.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ import { TooltipDirective } from "@/directive/TooltipDirective";
88
import { setupI18n } from "@/i18n";
99
import { ApolloClients } from "@vue/apollo-composable";
1010

11+
const SEVENTV_EXTENSION_EVENT = "seventv:extension-presence";
12+
const SEVENTV_EXTENSION_LEGACY = "legacy";
13+
const SEVENTV_EXTENSION_NEXT = "next";
14+
1115
if (!("seventv" in window)) {
1216
(window as Window & { seventv?: SeventvGlobalScope }).seventv = { host_manifest: null };
1317
}
1418

19+
const scr = document.querySelector("script#seventv-extension");
20+
21+
if (document.documentElement.dataset.seventvExtension === SEVENTV_EXTENSION_NEXT) {
22+
throw new Error("7TV Next running not startinng up");
23+
}
24+
25+
document.documentElement.dataset.seventvExtension = SEVENTV_EXTENSION_LEGACY;
26+
window.dispatchEvent(new Event(SEVENTV_EXTENSION_EVENT));
27+
1528
const appID = Date.now().toString();
1629

1730
// Sanity Check
@@ -48,8 +61,6 @@ root.setAttribute("data-app-id", appID);
4861

4962
document.body.append(root);
5063

51-
const scr = document.querySelector("script#seventv-extension");
52-
5364
const app = createApp({
5465
setup() {
5566
provide(ApolloClients, {

0 commit comments

Comments
 (0)