diff --git a/src/components/FollowButton.vue b/src/components/FollowButton.vue index 3aa5347..3728a0a 100644 --- a/src/components/FollowButton.vue +++ b/src/components/FollowButton.vue @@ -26,7 +26,7 @@ export default { const index = parsedFollows.indexOf(username) console.log(index) if (index === -1) return - parsedFollows = parsedFollows.splice(index, 1) + parsedFollows.splice(index, 1) console.log(parsedFollows) this.isFollowing = false } else { diff --git a/src/mixins.ts b/src/mixins.ts index 5ef1471..a523827 100644 --- a/src/mixins.ts +++ b/src/mixins.ts @@ -45,6 +45,34 @@ export async function getEndpoint(endpoint: string) { return data } + +/** + * Gets the response from an endpoint from the backend + * @param endpoint The endpoint to get data from + * @returns The data from the enpoint + */ +export async function postEndpoint(endpoint: string, data: any) { + const res = await fetch(rootBackendUrl + endpoint, { + method: 'POST', + headers: { + 'Accept-Language': language + }, + body: JSON.stringify(data) + }) + const rawData = await res.json() + + if (!res.ok) { + throw res + } + if (rawData.status !== 'ok') { + throw rawData + } + + const finalData = rawData.data + + return finalData +} + /** * Converts a twitch timestamp (0h0m0s) to seconds * @param query 0h0m0s diff --git a/src/router/index.ts b/src/router/index.ts index 2306f46..edba497 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -8,6 +8,7 @@ const SearchPageView = () => import('../views/SearchPageView.vue') const VodView = () => import('../views/VodView.vue') const SettingsView = () => import('../views/SettingsView.vue') const ClipView = () => import('../views/ClipView.vue') +const FollowingView = () => import('../views/FollowingView.vue') const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -33,6 +34,10 @@ const router = createRouter({ name: 'about', component: PrivacyPageView }, + { + path: "/following", + component: FollowingView + }, { path: '/:username', component: UserView diff --git a/src/settingsManager.ts b/src/settingsManager.ts index b2553a3..ad91a26 100644 --- a/src/settingsManager.ts +++ b/src/settingsManager.ts @@ -189,6 +189,13 @@ export function getSetting(key: string): boolean | string { return parsed.settings[key].selected } +export function getFollows(): string[] { + const follows = localStorage.getItem('following') || '[]' + let parsedFollows: string[] = JSON.parse(follows) + + return parsedFollows +} + /** * Gets the current theme * @returns the name of the current theme @@ -245,3 +252,4 @@ export const themeList = [ } } ] + diff --git a/src/views/FollowingView.vue b/src/views/FollowingView.vue new file mode 100644 index 0000000..f6774a9 --- /dev/null +++ b/src/views/FollowingView.vue @@ -0,0 +1,66 @@ + + \ No newline at end of file