11import axios from 'axios' ;
22import React , { useEffect , useState } from 'react' ;
33import ClipLoader from 'react-spinners/ClipLoader' ;
4- import { vtuberInfo } from './DisplayMyLivers' ;
54import LiveStatus from './DisplayedLiver/LiveStatus' ;
65
76import { BookmarkIcon , BookmarkSlashIcon } from '@heroicons/react/24/solid' ;
@@ -19,9 +18,10 @@ export function DisplayedLiver({
1918 const [ showLiveStatus , setShowLiveStatus ] = useState ( false ) ;
2019 const [ customList , setCustomList ] = useState < any > ( { } ) ;
2120 const [ fetchingVTuber , setFetchingVTuber ] = useState ( false ) ;
21+ let test : any ;
2222
2323 function checkMyLivers ( ) {
24- chrome . storage . local . get ( [ 'myLivers' , ' customList'] , function ( data ) {
24+ chrome . storage . local . get ( ' customList', function ( data ) {
2525 setCustomList ( data . customList ) ;
2626 } ) ;
2727 }
@@ -30,15 +30,21 @@ export function DisplayedLiver({
3030 if ( path === 'viewAll' ) checkMyLivers ( ) ;
3131 } , [ ] ) ;
3232
33+ useEffect ( ( ) => {
34+ chrome . storage . local . get ( 'customList' , function ( data ) { } ) ;
35+ } , [ customList ] ) ;
36+
3337 const deleteFromMyLivers = ( channelID : string ) => {
34- let tempCustomList = customList ;
35- delete tempCustomList [ channelID ] ;
36- chrome . storage . local . set ( { customList : tempCustomList } ) ;
37- setCustomList ( tempCustomList ) ;
38+ chrome . storage . local . get ( 'customList' , function ( data ) {
39+ let tempCustomList : any ;
40+ tempCustomList = data . customList ;
41+ delete tempCustomList [ channelID ] ;
42+ chrome . storage . local . set ( { customList : tempCustomList } ) ;
43+ setCustomList ( tempCustomList ) ;
44+ } ) ;
3845 } ;
3946
4047 const addToMyLivers = async ( channelID : string ) => {
41- let vtuberTwitter = '' ;
4248 setFetchingVTuber ( true ) ;
4349 const config = {
4450 url : `https://holodex.net/api/v2/channels/${ channelID } ` ,
@@ -49,30 +55,30 @@ export function DisplayedLiver({
4955 } ;
5056 try {
5157 const { data } = await axios . request ( config ) ;
52- vtuberTwitter = data . twitter ;
58+ const twitter = data . twitter ;
59+ chrome . storage . local . get ( 'customList' , function ( data ) {
60+ let tempCustomList = data . customList ;
61+ tempCustomList = {
62+ ...tempCustomList ,
63+ [ channelID ] : {
64+ name : member . channel . english_name ,
65+ imageURL : member . channel . photo ,
66+ channelID : member . channel . id ,
67+ twitter : twitter ,
68+ status : member . status ,
69+ title : member . title ,
70+ started : member . start_actual ,
71+ org : member . channel . org ,
72+ viewers : member . live_viewers ,
73+ } ,
74+ } ;
75+ chrome . storage . local . set ( { customList : tempCustomList } ) ;
76+ setCustomList ( tempCustomList ) ;
77+ } ) ;
5378 setFetchingVTuber ( false ) ;
5479 } catch ( error ) {
5580 console . log ( error ) ;
5681 }
57-
58- let tempCustomList = customList ;
59-
60- tempCustomList = {
61- ...tempCustomList ,
62- [ channelID ] : {
63- name : member . channel . english_name ,
64- imageURL : member . channel . photo ,
65- channelID : member . channel . id ,
66- twitter : vtuberTwitter ,
67- status : member . status ,
68- title : member . title ,
69- started : member . start_actual ,
70- org : member . channel . org ,
71- viewers : member . live_viewers ,
72- } ,
73- } ;
74- chrome . storage . local . set ( { customList : tempCustomList } ) ;
75- setCustomList ( tempCustomList ) ;
7682 } ;
7783
7884 function handleTwitter ( twitterID : string ) {
@@ -86,7 +92,7 @@ export function DisplayedLiver({
8692 const isLive = member . status === 'live' ;
8793
8894 return (
89- < div className = "fade-in" >
95+ < div className = "fade-in " >
9096 { showLiveStatus && isLive && < LiveStatus member = { member } /> }
9197 < div
9298 className = "relative bg-green-"
@@ -100,7 +106,7 @@ export function DisplayedLiver({
100106 < img
101107 src = { member . imageURL || member . channel . photo }
102108 alt = { member . name || member . channel . english_name }
103- className = { `rounded-full h-20 liver border-4 ${
109+ className = { `rounded-full h-20 liver border-4 shadow-md ${
104110 isLive
105111 ? 'border-red-500'
106112 : 'border-white dark:border-slate-700 bg-slate-200 dark:bg-slate-800'
@@ -136,7 +142,7 @@ export function DisplayedLiver({
136142 ) : (
137143 < BookmarkIcon
138144 onClick = { ( ) => addToMyLivers ( member . channel . id ) }
139- className = "h-5 w-5 p-0.5 text-black hover:text-neutral-800 bg-white border-2 border-red-500 rounded-full cursor-pointer"
145+ className = "h-5 w-5 p-0.5 text-black hover:text-neutral-500 bg-white border-2 border-red-500 rounded-full cursor-pointer"
140146 />
141147 ) }
142148 </ div >
0 commit comments