2018-05-07 06:50:55 +02:00
|
|
|
// @flow
|
2018-10-19 22:38:07 +02:00
|
|
|
import * as ACTIONS from 'constants/action_types';
|
|
|
|
import {
|
|
|
|
DOWNLOADED,
|
|
|
|
DOWNLOADING,
|
|
|
|
NOTIFY_ONLY,
|
|
|
|
VIEW_ALL,
|
|
|
|
VIEW_LATEST_FIRST,
|
2018-11-21 22:20:55 +01:00
|
|
|
SUGGESTED_TOP_BID,
|
|
|
|
SUGGESTED_TOP_SUBSCRIBED,
|
|
|
|
SUGGESTED_FEATURED,
|
2018-10-19 22:38:07 +02:00
|
|
|
} from 'constants/subscriptions';
|
2018-05-07 06:50:55 +02:00
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type Subscription = {
|
2018-05-07 06:50:55 +02:00
|
|
|
channelName: string, // @CryptoCandor,
|
|
|
|
uri: string, // lbry://@CryptoCandor#9152f3b054f692076a6882d1b58a30e8781cc8e6
|
2018-10-19 22:38:07 +02:00
|
|
|
latest?: string, // substratum#b0ab143243020e7831fd070d9f871e1fda948620
|
2018-05-07 06:50:55 +02:00
|
|
|
};
|
2018-10-19 22:38:07 +02:00
|
|
|
|
|
|
|
// Tracking for new content
|
|
|
|
// i.e. If a subscription has a DOWNLOADING type, we will trigger an OS notification
|
|
|
|
// to tell users there is new content from their subscriptions
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SubscriptionNotificationType = DOWNLOADED | DOWNLOADING | NOTIFY_ONLY;
|
2018-10-19 22:38:07 +02:00
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type UnreadSubscription = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: SubscriptionNotificationType,
|
|
|
|
uris: Array<string>,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type UnreadSubscriptions = {
|
2018-10-19 22:38:07 +02:00
|
|
|
[string]: UnreadSubscription,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type ViewMode = VIEW_LATEST_FIRST | VIEW_ALL;
|
2018-10-19 22:38:07 +02:00
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SuggestedType = SUGGESTED_TOP_BID | SUGGESTED_TOP_SUBSCRIBED | SUGGESTED_FEATURED;
|
2018-11-21 22:20:55 +01:00
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SuggestedSubscriptions = {
|
2018-11-21 22:20:55 +01:00
|
|
|
[SuggestedType]: string,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SubscriptionState = {
|
2018-10-19 22:38:07 +02:00
|
|
|
subscriptions: Array<Subscription>,
|
|
|
|
unread: UnreadSubscriptions,
|
|
|
|
loading: boolean,
|
|
|
|
viewMode: ViewMode,
|
2018-11-21 22:20:55 +01:00
|
|
|
suggested: SuggestedSubscriptions,
|
|
|
|
loadingSuggested: boolean,
|
|
|
|
firstRunCompleted: boolean,
|
|
|
|
showSuggestedSubs: boolean,
|
2018-10-19 22:38:07 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Action types
|
|
|
|
//
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type DoChannelSubscribe = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.CHANNEL_SUBSCRIBE,
|
|
|
|
data: Subscription,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type DoChannelUnsubscribe = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.CHANNEL_UNSUBSCRIBE,
|
|
|
|
data: Subscription,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type DoUpdateSubscriptionUnreads = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.UPDATE_SUBSCRIPTION_UNREADS,
|
|
|
|
data: {
|
|
|
|
channel: string,
|
|
|
|
uris: Array<string>,
|
|
|
|
type?: SubscriptionNotificationType,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type DoRemoveSubscriptionUnreads = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.REMOVE_SUBSCRIPTION_UNREADS,
|
|
|
|
data: {
|
|
|
|
channel: string,
|
|
|
|
uris: Array<string>,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SetSubscriptionLatest = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
|
|
|
data: {
|
|
|
|
subscription: Subscription,
|
|
|
|
uri: string,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type CheckSubscriptionStarted = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type CheckSubscriptionCompleted = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type FetchedSubscriptionsSucess = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.FETCH_SUBSCRIPTIONS_SUCCESS,
|
|
|
|
data: Array<Subscription>,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type SetViewMode = {
|
2018-10-19 22:38:07 +02:00
|
|
|
type: ACTIONS.SET_VIEW_MODE,
|
|
|
|
data: ViewMode,
|
|
|
|
};
|
|
|
|
|
2019-04-24 16:02:08 +02:00
|
|
|
declare type GetSuggestedSubscriptionsSuccess = {
|
2018-11-21 22:20:55 +01:00
|
|
|
type: ACTIONS.GET_SUGGESTED_SUBSCRIPTIONS_START,
|
|
|
|
data: SuggestedSubscriptions,
|
|
|
|
};
|