2019-02-15 10:02:34 +01:00
|
|
|
// @flow
|
2019-09-16 22:12:43 +02:00
|
|
|
import type { Dispatch } from 'flow-typed/Redux';
|
2019-02-15 10:02:34 +01:00
|
|
|
import * as ACTIONS from 'constants/action_types';
|
|
|
|
import {
|
|
|
|
DOWNLOADED,
|
|
|
|
DOWNLOADING,
|
|
|
|
NOTIFY_ONLY,
|
|
|
|
VIEW_ALL,
|
|
|
|
VIEW_LATEST_FIRST,
|
|
|
|
SUGGESTED_TOP_BID,
|
|
|
|
SUGGESTED_TOP_SUBSCRIBED,
|
|
|
|
SUGGESTED_FEATURED,
|
|
|
|
} from 'constants/subscriptions';
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type Subscription = {
|
2019-02-15 10:02:34 +01:00
|
|
|
channelName: string, // @CryptoCandor,
|
|
|
|
uri: string, // lbry://@CryptoCandor#9152f3b054f692076a6882d1b58a30e8781cc8e6
|
|
|
|
latest?: string, // substratum#b0ab143243020e7831fd070d9f871e1fda948620
|
|
|
|
};
|
|
|
|
|
|
|
|
// 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-09-16 22:12:43 +02:00
|
|
|
declare type SubscriptionNotificationType = DOWNLOADED | DOWNLOADING | NOTIFY_ONLY;
|
2019-02-15 10:02:34 +01:00
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type UnreadSubscription = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: SubscriptionNotificationType,
|
|
|
|
uris: Array<string>,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type UnreadSubscriptions = {
|
2019-02-15 10:02:34 +01:00
|
|
|
[string]: UnreadSubscription,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type ViewMode = VIEW_LATEST_FIRST | VIEW_ALL;
|
2019-02-15 10:02:34 +01:00
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SuggestedType = SUGGESTED_TOP_BID | SUGGESTED_TOP_SUBSCRIBED | SUGGESTED_FEATURED;
|
2019-02-15 10:02:34 +01:00
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SuggestedSubscriptions = {
|
2019-02-15 10:02:34 +01:00
|
|
|
[SuggestedType]: string,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SubscriptionState = {
|
2019-02-15 10:02:34 +01:00
|
|
|
enabledChannelNotifications: Array<string>,
|
|
|
|
subscriptions: Array<Subscription>,
|
|
|
|
unread: UnreadSubscriptions,
|
|
|
|
loading: boolean,
|
|
|
|
viewMode: ViewMode,
|
|
|
|
suggested: SuggestedSubscriptions,
|
|
|
|
loadingSuggested: boolean,
|
|
|
|
firstRunCompleted: boolean,
|
|
|
|
showSuggestedSubs: boolean,
|
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Action types
|
|
|
|
//
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoChannelSubscriptionEnableNotifications = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS,
|
|
|
|
data: string,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoChannelSubscriptionDisableNotifications = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS,
|
|
|
|
data: string,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoChannelSubscribe = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHANNEL_SUBSCRIBE,
|
|
|
|
data: Subscription,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoChannelUnsubscribe = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHANNEL_UNSUBSCRIBE,
|
|
|
|
data: Subscription,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoUpdateSubscriptionUnreads = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.UPDATE_SUBSCRIPTION_UNREADS,
|
|
|
|
data: {
|
|
|
|
channel: string,
|
|
|
|
uris: Array<string>,
|
|
|
|
type?: SubscriptionNotificationType,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type DoRemoveSubscriptionUnreads = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.REMOVE_SUBSCRIPTION_UNREADS,
|
|
|
|
data: {
|
|
|
|
channel: string,
|
|
|
|
uris: Array<string>,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SetSubscriptionLatest = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.SET_SUBSCRIPTION_LATEST,
|
|
|
|
data: {
|
|
|
|
subscription: Subscription,
|
|
|
|
uri: string,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type CheckSubscriptionStarted = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHECK_SUBSCRIPTION_STARTED,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type CheckSubscriptionCompleted = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.CHECK_SUBSCRIPTION_COMPLETED,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type FetchedSubscriptionsSucess = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.FETCH_SUBSCRIPTIONS_SUCCESS,
|
|
|
|
data: Array<Subscription>,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SetViewMode = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.SET_VIEW_MODE,
|
|
|
|
data: ViewMode,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type GetSuggestedSubscriptionsSuccess = {
|
2019-02-15 10:02:34 +01:00
|
|
|
type: ACTIONS.GET_SUGGESTED_SUBSCRIPTIONS_START,
|
|
|
|
data: SuggestedSubscriptions,
|
|
|
|
};
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SubscriptionAction =
|
2019-02-15 10:02:34 +01:00
|
|
|
| DoChannelSubscribe
|
|
|
|
| DoChannelUnsubscribe
|
|
|
|
| DoUpdateSubscriptionUnreads
|
|
|
|
| DoRemoveSubscriptionUnreads
|
|
|
|
| SetSubscriptionLatest
|
|
|
|
| CheckSubscriptionStarted
|
|
|
|
| CheckSubscriptionCompleted
|
|
|
|
| SetViewMode
|
|
|
|
| Function;
|
|
|
|
|
2019-09-16 22:12:43 +02:00
|
|
|
declare type SubscriptionDispatch = Dispatch<SubscriptionAction>;
|