-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bugfix wip flow fix cleaning clean
- Loading branch information
Showing
419 changed files
with
11,971 additions
and
1,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// @flow | ||
/* | ||
LBRY FIRST does not work due to api changes | ||
*/ | ||
import 'proxy-polyfill'; | ||
|
||
const CHECK_LBRYFIRST_STARTED_TRY_NUMBER = 200; | ||
// | ||
// Basic LBRYFIRST connection config | ||
// Offers a proxy to call LBRYFIRST methods | ||
|
||
// | ||
const LbryFirst: LbryFirstTypes = { | ||
isConnected: false, | ||
connectPromise: null, | ||
lbryFirstConnectionString: 'http://localhost:1337/rpc', | ||
apiRequestHeaders: { 'Content-Type': 'application/json' }, | ||
|
||
// Allow overriding lbryFirst connection string (e.g. to `/api/proxy` for lbryweb) | ||
setLbryFirstConnectionString: (value: string) => { | ||
LbryFirst.lbryFirstConnectionString = value; | ||
}, | ||
|
||
setApiHeader: (key: string, value: string) => { | ||
LbryFirst.apiRequestHeaders = Object.assign(LbryFirst.apiRequestHeaders, { [key]: value }); | ||
}, | ||
|
||
unsetApiHeader: key => { | ||
Object.keys(LbryFirst.apiRequestHeaders).includes(key) && | ||
delete LbryFirst.apiRequestHeaders['key']; | ||
}, | ||
// Allow overriding Lbry methods | ||
overrides: {}, | ||
setOverride: (methodName, newMethod) => { | ||
LbryFirst.overrides[methodName] = newMethod; | ||
}, | ||
getApiRequestHeaders: () => LbryFirst.apiRequestHeaders, | ||
|
||
// LbryFirst Methods | ||
status: (params = {}) => lbryFirstCallWithResult('status', params), | ||
stop: () => lbryFirstCallWithResult('stop', {}), | ||
version: () => lbryFirstCallWithResult('version', {}), | ||
|
||
// Upload to youtube | ||
upload: (params: { title: string, description: string, file_path: ?string } = {}) => { | ||
// Only upload when originally publishing for now | ||
if (!params.file_path) { | ||
return Promise.resolve(); | ||
} | ||
|
||
const uploadParams: { | ||
Title: string, | ||
Description: string, | ||
FilePath: string, | ||
Category: string, | ||
Keywords: string, | ||
} = { | ||
Title: params.title, | ||
Description: params.description, | ||
FilePath: params.file_path, | ||
Category: '', | ||
Keywords: '', | ||
}; | ||
|
||
return lbryFirstCallWithResult('youtube.Upload', uploadParams); | ||
}, | ||
|
||
hasYTAuth: (token: string) => { | ||
const hasYTAuthParams = {}; | ||
hasYTAuthParams.AuthToken = token; | ||
return lbryFirstCallWithResult('youtube.HasAuth', hasYTAuthParams); | ||
}, | ||
|
||
ytSignup: () => { | ||
const emptyParams = {}; | ||
return lbryFirstCallWithResult('youtube.Signup', emptyParams); | ||
}, | ||
|
||
remove: () => { | ||
const emptyParams = {}; | ||
return lbryFirstCallWithResult('youtube.Remove', emptyParams); | ||
}, | ||
|
||
// Connect to lbry-first | ||
connect: () => { | ||
if (LbryFirst.connectPromise === null) { | ||
LbryFirst.connectPromise = new Promise((resolve, reject) => { | ||
let tryNum = 0; | ||
// Check every half second to see if the lbryFirst is accepting connections | ||
function checkLbryFirstStarted() { | ||
tryNum += 1; | ||
LbryFirst.status() | ||
.then(resolve) | ||
.catch(() => { | ||
if (tryNum <= CHECK_LBRYFIRST_STARTED_TRY_NUMBER) { | ||
setTimeout(checkLbryFirstStarted, tryNum < 50 ? 400 : 1000); | ||
} else { | ||
reject(new Error('Unable to connect to LBRY')); | ||
} | ||
}); | ||
} | ||
|
||
checkLbryFirstStarted(); | ||
}); | ||
} | ||
|
||
// Flow thinks this could be empty, but it will always return a promise | ||
// $FlowFixMe | ||
return LbryFirst.connectPromise; | ||
}, | ||
}; | ||
|
||
function checkAndParse(response) { | ||
if (response.status >= 200 && response.status < 300) { | ||
return response.json(); | ||
} | ||
return response.json().then(json => { | ||
let error; | ||
if (json.error) { | ||
const errorMessage = typeof json.error === 'object' ? json.error.message : json.error; | ||
error = new Error(errorMessage); | ||
} else { | ||
error = new Error('Protocol error with unknown response signature'); | ||
} | ||
return Promise.reject(error); | ||
}); | ||
} | ||
|
||
export function apiCall(method: string, params: ?{}, resolve: Function, reject: Function) { | ||
const counter = new Date().getTime(); | ||
const paramsArray = [params]; | ||
const options = { | ||
method: 'POST', | ||
headers: LbryFirst.apiRequestHeaders, | ||
body: JSON.stringify({ | ||
jsonrpc: '2.0', | ||
method, | ||
params: paramsArray, | ||
id: counter, | ||
}), | ||
}; | ||
|
||
return fetch(LbryFirst.lbryFirstConnectionString, options) | ||
.then(checkAndParse) | ||
.then(response => { | ||
const error = response.error || (response.result && response.result.error); | ||
|
||
if (error) { | ||
return reject(error); | ||
} | ||
return resolve(response.result); | ||
}) | ||
.catch(reject); | ||
} | ||
|
||
function lbryFirstCallWithResult(name: string, params: ?{} = {}) { | ||
return new Promise((resolve, reject) => { | ||
apiCall( | ||
name, | ||
params, | ||
result => { | ||
resolve(result); | ||
}, | ||
reject | ||
); | ||
}); | ||
} | ||
|
||
// This is only for a fallback | ||
// If there is a LbryFirst method that is being called by an app, it should be added to /flow-typed/LbryFirst.js | ||
const lbryFirstProxy = new Proxy(LbryFirst, { | ||
get(target: LbryFirstTypes, name: string) { | ||
if (name in target) { | ||
return target[name]; | ||
} | ||
|
||
return (params = {}) => | ||
new Promise((resolve, reject) => { | ||
apiCall(name, params, resolve, reject); | ||
}); | ||
}, | ||
}); | ||
|
||
export default lbryFirstProxy; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Claims | ||
export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED'; | ||
export const FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED'; | ||
export const FETCH_TRENDING_CONTENT_STARTED = 'FETCH_TRENDING_CONTENT_STARTED'; | ||
export const FETCH_TRENDING_CONTENT_COMPLETED = 'FETCH_TRENDING_CONTENT_COMPLETED'; | ||
export const RESOLVE_URIS_STARTED = 'RESOLVE_URIS_STARTED'; | ||
export const RESOLVE_URIS_COMPLETED = 'RESOLVE_URIS_COMPLETED'; | ||
export const FETCH_CHANNEL_CLAIMS_STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED'; | ||
export const FETCH_CHANNEL_CLAIMS_COMPLETED = 'FETCH_CHANNEL_CLAIMS_COMPLETED'; | ||
export const FETCH_CHANNEL_CLAIM_COUNT_STARTED = 'FETCH_CHANNEL_CLAIM_COUNT_STARTED'; | ||
export const FETCH_CHANNEL_CLAIM_COUNT_COMPLETED = 'FETCH_CHANNEL_CLAIM_COUNT_COMPLETED'; | ||
export const FETCH_CLAIM_LIST_MINE_STARTED = 'FETCH_CLAIM_LIST_MINE_STARTED'; | ||
export const FETCH_CLAIM_LIST_MINE_COMPLETED = 'FETCH_CLAIM_LIST_MINE_COMPLETED'; | ||
export const ABANDON_CLAIM_STARTED = 'ABANDON_CLAIM_STARTED'; | ||
export const ABANDON_CLAIM_SUCCEEDED = 'ABANDON_CLAIM_SUCCEEDED'; | ||
export const FETCH_CHANNEL_LIST_STARTED = 'FETCH_CHANNEL_LIST_STARTED'; | ||
export const FETCH_CHANNEL_LIST_COMPLETED = 'FETCH_CHANNEL_LIST_COMPLETED'; | ||
export const CREATE_CHANNEL_STARTED = 'CREATE_CHANNEL_STARTED'; | ||
export const CREATE_CHANNEL_COMPLETED = 'CREATE_CHANNEL_COMPLETED'; | ||
export const PUBLISH_STARTED = 'PUBLISH_STARTED'; | ||
export const PUBLISH_COMPLETED = 'PUBLISH_COMPLETED'; | ||
export const PUBLISH_FAILED = 'PUBLISH_FAILED'; | ||
export const SET_PLAYING_URI = 'SET_PLAYING_URI'; | ||
export const SET_CONTENT_POSITION = 'SET_CONTENT_POSITION'; | ||
export const SET_CONTENT_LAST_VIEWED = 'SET_CONTENT_LAST_VIEWED'; | ||
export const CLEAR_CONTENT_HISTORY_URI = 'CLEAR_CONTENT_HISTORY_URI'; | ||
export const CLEAR_CONTENT_HISTORY_ALL = 'CLEAR_CONTENT_HISTORY_ALL'; | ||
|
||
// Subscriptions | ||
export const CHANNEL_SUBSCRIBE = 'CHANNEL_SUBSCRIBE'; | ||
export const CHANNEL_UNSUBSCRIBE = 'CHANNEL_UNSUBSCRIBE'; | ||
export const CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS = | ||
'CHANNEL_SUBSCRIPTION_ENABLE_NOTIFICATIONS'; | ||
export const CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS = | ||
'CHANNEL_SUBSCRIPTION_DISABLE_NOTIFICATIONS'; | ||
export const HAS_FETCHED_SUBSCRIPTIONS = 'HAS_FETCHED_SUBSCRIPTIONS'; | ||
export const SET_SUBSCRIPTION_LATEST = 'SET_SUBSCRIPTION_LATEST'; | ||
export const UPDATE_SUBSCRIPTION_UNREADS = 'UPDATE_SUBSCRIPTION_UNREADS'; | ||
export const REMOVE_SUBSCRIPTION_UNREADS = 'REMOVE_SUBSCRIPTION_UNREADS'; | ||
export const CHECK_SUBSCRIPTION_STARTED = 'CHECK_SUBSCRIPTION_STARTED'; | ||
export const CHECK_SUBSCRIPTION_COMPLETED = 'CHECK_SUBSCRIPTION_COMPLETED'; | ||
export const CHECK_SUBSCRIPTIONS_SUBSCRIBE = 'CHECK_SUBSCRIPTIONS_SUBSCRIBE'; | ||
export const FETCH_SUBSCRIPTIONS_START = 'FETCH_SUBSCRIPTIONS_START'; | ||
export const FETCH_SUBSCRIPTIONS_FAIL = 'FETCH_SUBSCRIPTIONS_FAIL'; | ||
export const FETCH_SUBSCRIPTIONS_SUCCESS = 'FETCH_SUBSCRIPTIONS_SUCCESS'; | ||
export const SET_VIEW_MODE = 'SET_VIEW_MODE'; | ||
export const GET_SUGGESTED_SUBSCRIPTIONS_START = 'GET_SUGGESTED_SUBSCRIPTIONS_START'; | ||
export const GET_SUGGESTED_SUBSCRIPTIONS_SUCCESS = 'GET_SUGGESTED_SUBSCRIPTIONS_SUCCESS'; | ||
export const GET_SUGGESTED_SUBSCRIPTIONS_FAIL = 'GET_SUGGESTED_SUBSCRIPTIONS_FAIL'; | ||
export const SUBSCRIPTION_FIRST_RUN_COMPLETED = 'SUBSCRIPTION_FIRST_RUN_COMPLETED'; | ||
export const VIEW_SUGGESTED_SUBSCRIPTIONS = 'VIEW_SUGGESTED_SUBSCRIPTIONS'; | ||
|
||
// Blacklist | ||
export const FETCH_BLACK_LISTED_CONTENT_STARTED = 'FETCH_BLACK_LISTED_CONTENT_STARTED'; | ||
export const FETCH_BLACK_LISTED_CONTENT_COMPLETED = 'FETCH_BLACK_LISTED_CONTENT_COMPLETED'; | ||
export const FETCH_BLACK_LISTED_CONTENT_FAILED = 'FETCH_BLACK_LISTED_CONTENT_FAILED'; | ||
export const BLACK_LISTED_CONTENT_SUBSCRIBE = 'BLACK_LISTED_CONTENT_SUBSCRIBE'; | ||
|
||
// Filtered list | ||
export const FETCH_FILTERED_CONTENT_STARTED = 'FETCH_FILTERED_CONTENT_STARTED'; | ||
export const FETCH_FILTERED_CONTENT_COMPLETED = 'FETCH_FILTERED_CONTENT_COMPLETED'; | ||
export const FETCH_FILTERED_CONTENT_FAILED = 'FETCH_FILTERED_CONTENT_FAILED'; | ||
export const FILTERED_CONTENT_SUBSCRIBE = 'FILTERED_CONTENT_SUBSCRIBE'; | ||
|
||
// Cost Info | ||
export const FETCH_COST_INFO_STARTED = 'FETCH_COST_INFO_STARTED'; | ||
export const FETCH_COST_INFO_COMPLETED = 'FETCH_COST_INFO_COMPLETED'; | ||
|
||
// Stats | ||
export const FETCH_VIEW_COUNT_STARTED = 'FETCH_VIEW_COUNT_STARTED'; | ||
export const FETCH_VIEW_COUNT_FAILED = 'FETCH_VIEW_COUNT_FAILED'; | ||
export const FETCH_VIEW_COUNT_COMPLETED = 'FETCH_VIEW_COUNT_COMPLETED'; | ||
export const FETCH_SUB_COUNT_STARTED = 'FETCH_SUB_COUNT_STARTED'; | ||
export const FETCH_SUB_COUNT_FAILED = 'FETCH_SUB_COUNT_FAILED'; | ||
export const FETCH_SUB_COUNT_COMPLETED = 'FETCH_SUB_COUNT_COMPLETED'; | ||
|
||
// Cross-device Sync | ||
export const GET_SYNC_STARTED = 'GET_SYNC_STARTED'; | ||
export const GET_SYNC_COMPLETED = 'GET_SYNC_COMPLETED'; | ||
export const GET_SYNC_FAILED = 'GET_SYNC_FAILED'; | ||
export const SET_SYNC_STARTED = 'SET_SYNC_STARTED'; | ||
export const SET_SYNC_FAILED = 'SET_SYNC_FAILED'; | ||
export const SET_SYNC_COMPLETED = 'SET_SYNC_COMPLETED'; | ||
export const SET_DEFAULT_ACCOUNT = 'SET_DEFAULT_ACCOUNT'; | ||
export const SYNC_APPLY_STARTED = 'SYNC_APPLY_STARTED'; | ||
export const SYNC_APPLY_COMPLETED = 'SYNC_APPLY_COMPLETED'; | ||
export const SYNC_APPLY_FAILED = 'SYNC_APPLY_FAILED'; | ||
export const SYNC_APPLY_BAD_PASSWORD = 'SYNC_APPLY_BAD_PASSWORD'; | ||
export const SYNC_RESET = 'SYNC_RESET'; | ||
|
||
// Lbry.tv | ||
export const UPDATE_UPLOAD_PROGRESS = 'UPDATE_UPLOAD_PROGRESS'; | ||
|
||
// User | ||
export const GENERATE_AUTH_TOKEN_FAILURE = 'GENERATE_AUTH_TOKEN_FAILURE'; | ||
export const GENERATE_AUTH_TOKEN_STARTED = 'GENERATE_AUTH_TOKEN_STARTED'; | ||
export const GENERATE_AUTH_TOKEN_SUCCESS = 'GENERATE_AUTH_TOKEN_SUCCESS'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const MINIMUM_PUBLISH_BID = 0.00000001; | ||
|
||
export const CHANNEL_ANONYMOUS = 'anonymous'; | ||
export const CHANNEL_NEW = 'new'; | ||
export const PAGE_SIZE = 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const ALREADY_CLAIMED = | ||
'once the invite reward has been claimed the referrer cannot be changed'; | ||
export const REFERRER_NOT_FOUND = | ||
'A lbry.tv account could not be found for the referrer you provided.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const YOUTUBE_SYNC_NOT_TRANSFERRED = 'not_transferred'; | ||
export const YOUTUBE_SYNC_PENDING = 'pending'; | ||
export const YOUTUBE_SYNC_PENDING_EMAIL = 'pendingemail'; | ||
export const YOUTUBE_SYNC_PENDING_TRANSFER = 'pending_transfer'; | ||
export const YOUTUBE_SYNC_COMPLETED_TRANSFER = 'completed_transfer'; | ||
export const YOUTUBE_SYNC_QUEUED = 'queued'; | ||
export const YOUTUBE_SYNC_SYNCING = 'syncing'; | ||
export const YOUTUBE_SYNC_SYNCED = 'synced'; | ||
export const YOUTUBE_SYNC_FAILED = 'failed'; | ||
export const YOUTUBE_SYNC_PENDINGUPGRADE = 'pendingupgrade'; | ||
export const YOUTUBE_SYNC_ABANDONDED = 'abandoned'; |
Oops, something went wrong.