New: Server Side UI Filtering, Error Boundaries (#501)

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
Qstick 2018-09-22 23:10:50 -04:00 committed by GitHub
parent a95191dc3b
commit 64a8d02f77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
110 changed files with 1564 additions and 431 deletions

View file

@ -10,6 +10,7 @@ import createHandleActions from './Creators/createHandleActions';
// Variables
export const section = 'oAuth';
const callbackUrl = `${window.location.origin}${window.Lidarr.urlBase}/oauth.html`;
//
// State
@ -64,6 +65,19 @@ function showOAuthWindow(url) {
return deferred.promise();
}
function executeIntermediateRequest(payload, ajaxOptions) {
return $.ajax(ajaxOptions).then((data) => {
return requestAction({
action: 'continueOAuth',
queryParams: {
...data,
callbackUrl
},
...payload
});
});
}
//
// Action Handlers
@ -72,7 +86,7 @@ export const actionHandlers = handleThunks({
[START_OAUTH]: function(getState, payload, dispatch) {
const actionPayload = {
action: 'startOAuth',
queryParams: { callbackUrl: `${window.location.origin}${window.Lidarr.urlBase}/oauth.html` },
queryParams: { callbackUrl },
...payload
};
@ -85,7 +99,16 @@ export const actionHandlers = handleThunks({
const promise = requestAction(actionPayload)
.then((response) => {
startResponse = response;
return showOAuthWindow(response.oauthUrl);
if (response.oauthUrl) {
return showOAuthWindow(response.oauthUrl);
}
return executeIntermediateRequest(payload, response).then((intermediateResponse) => {
startResponse = intermediateResponse;
return showOAuthWindow(intermediateResponse.oauthUrl);
});
})
.then((queryParams) => {
return requestAction({