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:
parent
32ecf26ccd
commit
a416a0599d
1 changed files with 44 additions and 0 deletions
44
src/views/AuthCallback.vue
Normal file
44
src/views/AuthCallback.vue
Normal 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>
|
||||
|
Loading…
Add table
Reference in a new issue