0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2025-04-12 21:31:19 -05:00

function to import all the followed channels

This commit is contained in:
Max Ebert 2024-09-27 16:14:56 +02:00
parent 32ecf26ccd
commit a416a0599d

View file

@ -0,0 +1,44 @@
<template>
<div>
<h2>{{ $t('auth.processing') }}</h2>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { getFollowedChannels } from '@/api/twitchAuth';
import { syncUserSettings } from '@/settingsManager';
const router = useRouter();
onMounted(async () => {
const hash = window.location.hash.substring(1);
const params = new URLSearchParams(hash);
const accessToken = params.get('access_token');
if (accessToken) {
try {
const followedChannels = await getFollowedChannels(accessToken);
const currentSettings = JSON.parse(localStorage.getItem('settings') || '{}');
currentSettings.followers = followedChannels.map((channel: any) => ({
username: channel.to_name,
login: channel.to_login,
}));
const { settings } = syncUserSettings(currentSettings);
localStorage.setItem('settings', JSON.stringify(settings));
router.push('/following');
} catch (error) {
console.error('Error processing authentication:', error);
router.push('/');
}
} else {
console.error('No access token found in URL');
router.push('/');
}
});
</script>