import { defaultSubChannels } from './lib/defaults' ; import Subscription from './lib/Subscription' ; import { fApi } from './lib/FloatplaneAPI' ; import { settings } from './lib/helpers' ; export const fetchSubscriptions = async ( ) : Promise < Subscription [ ] > => ( await fApi . user . subscriptions ( ) ) . map ( ( subscription ) => { const titleAlias = settings . channelAliases [ subscription . plan . title . toLowerCase ( ) ] || subscription . plan . title ; settings . subscriptions [ subscription . creator ] ??= { creatorId : subscription . creator , plan : subscription . plan . title , skip : false , channels : defaultSubChannels [ titleAlias ] , } ; settings . subscriptions [ subscription . creator ] . channels = { ... defaultSubChannels [ titleAlias ] , ... settings . subscriptions [ subscription . creator ] . channels , } ; if ( settings . subscriptions [ subscription . creator ] . channels . _default === undefined ) settings . subscriptions [ subscription . creator ] . channels . _default = { title : titleAlias , skip : false , identifiers : false , } ; return new Subscription ( settings . subscriptions [ subscription . creator ] ) ; } ) . filter ( ( subscription ) => settings . subscriptions [ subscription . creatorId ] . skip !== true ) ;