@@ -35,12 +35,6 @@ type TimelineHeaderItemsDef = {
3535 iconOnly ?: boolean ; // わからん
3636} ;
3737
38- const lists = await userListsCache . fetch ( ) ;
39- const userChannels = await userChannelsCache . fetch ( ) ;
40- const userChannelFollowings = await userChannelFollowingsCache . fetch ( ) ;
41- const userFavoriteLists = await userFavoriteListsCache . fetch ( ) ;
42- const antenna = await antennasCache . fetch ( ) ;
43-
4438export const timelineHeaderItemDef = reactive < Partial < Record < TimelineHeaderItem , TimelineHeaderItemsDef > > > ( {
4539 home : {
4640 title : i18n . ts . _timelines . home ,
@@ -83,45 +77,82 @@ export const timelineHeaderItemDef = reactive<Partial<Record<TimelineHeaderItem,
8377 title : i18n . ts . channel ,
8478 iconOnly : false ,
8579 } ,
86- ...lists . reduce ( ( acc , l ) => {
87- acc [ 'list:' + l . id ] = {
88- title : i18n . ts . lists + ':' + l . name ,
89- icon : 'ti ti-star' ,
90- iconOnly : false ,
91- } ;
92- return acc ;
93- } , { } ) ,
94- ...userChannels . reduce ( ( acc , l ) => {
95- acc [ 'channel:' + l . id ] = {
96- title : i18n . ts . channel + ':' + l . name ,
97- icon : 'ti ti-star' ,
98- iconOnly : false ,
99- } ;
100- return acc ;
101- } , { } ) ,
102- ...userChannelFollowings . reduce ( ( acc , l ) => {
103- acc [ 'channel:' + l . id ] = {
104- title : i18n . ts . channel + ':' + l . name ,
105- icon : 'ti ti-star' ,
106- iconOnly : false ,
107- } ;
108- return acc ;
109- } , { } ) ,
110- ...userFavoriteLists . reduce ( ( acc , l ) => {
111- acc [ 'channel:' + l . id ] = {
112- title : i18n . ts . channel + ':' + l . name ,
113- icon : 'ti ti-star' ,
114- iconOnly : false ,
115- } ;
116- return acc ;
117- } , { } ) ,
118- ...antenna . reduce ( ( acc , l ) => {
119- acc [ 'antenna:' + l . id ] = {
120- title : i18n . ts . antennas + ':' + l . name ,
121- icon : 'ti ti-star' ,
122- iconOnly : false ,
123- } ;
124- return acc ;
125- } , { } ) ,
12680} ) ;
12781
82+ export async function updateTimelineHeaderItems ( ) {
83+ try {
84+ const [ lists , userChannels , userChannelFollowings , userFavoriteLists , antenna ] = await Promise . all ( [
85+ userListsCache . fetch ( ) ,
86+ userChannelsCache . fetch ( ) ,
87+ userChannelFollowingsCache . fetch ( ) ,
88+ userFavoriteListsCache . fetch ( ) ,
89+ antennasCache . fetch ( ) ,
90+ ] ) ;
91+
92+ // Clear existing dynamic items
93+ for ( const key in timelineHeaderItemDef ) {
94+ if ( key . startsWith ( 'list:' ) || key . startsWith ( 'channel:' ) || key . startsWith ( 'antenna:' ) ) {
95+ delete timelineHeaderItemDef [ key ] ;
96+ }
97+ }
98+
99+ // Add lists
100+ lists . forEach ( l => {
101+ timelineHeaderItemDef [ `list:${ l . id } ` ] = {
102+ title : `${ i18n . ts . lists } :${ l . name } ` ,
103+ icon : 'ti ti-star' ,
104+ iconOnly : false ,
105+ } ;
106+ } ) ;
107+
108+ // Add user channels
109+ userChannels . forEach ( l => {
110+ timelineHeaderItemDef [ `channel:${ l . id } ` ] = {
111+ title : `${ i18n . ts . channel } :${ l . name } ` ,
112+ icon : 'ti ti-device-tv' ,
113+ iconOnly : false ,
114+ } ;
115+ } ) ;
116+
117+ // Add channel followings
118+ userChannelFollowings . forEach ( l => {
119+ // Only add if not already added by userChannels
120+ if ( ! timelineHeaderItemDef [ `channel:${ l . id } ` ] ) {
121+ timelineHeaderItemDef [ `channel:${ l . id } ` ] = {
122+ title : `${ i18n . ts . channel } :${ l . name } ` ,
123+ icon : 'ti ti-device-tv' ,
124+ iconOnly : false ,
125+ } ;
126+ }
127+ } ) ;
128+
129+ // Add favorite lists (these should probably be lists, not channels)
130+ userFavoriteLists . forEach ( l => {
131+ // This seems like a bug - favorite lists should use 'list:' prefix
132+ if ( ! timelineHeaderItemDef [ `list:${ l . id } ` ] ) {
133+ timelineHeaderItemDef [ `list:${ l . id } ` ] = {
134+ title : `${ i18n . ts . lists } :${ l . name } ` ,
135+ icon : 'ti ti-star' ,
136+ iconOnly : false ,
137+ } ;
138+ }
139+ } ) ;
140+
141+ // Add antennas
142+ antenna . forEach ( l => {
143+ timelineHeaderItemDef [ `antenna:${ l . id } ` ] = {
144+ title : `${ i18n . ts . antennas } :${ l . name } ` ,
145+ icon : 'ti ti-antenna' ,
146+ iconOnly : false ,
147+ } ;
148+ } ) ;
149+ } catch ( error ) {
150+ console . error ( 'Failed to update timeline header items:' , error ) ;
151+ }
152+ }
153+
154+ // Initialize on first load if user is logged in
155+ if ( $i ) {
156+ updateTimelineHeaderItems ( ) ;
157+ }
158+
0 commit comments