Fix floating promises in ts files
This commit is contained in:
parent
aaac4883e3
commit
eedd40159c
25 changed files with 250 additions and 47 deletions
|
@ -101,6 +101,8 @@ const Home: FunctionComponent = () => {
|
||||||
|
|
||||||
controller.refreshed = true;
|
controller.refreshed = true;
|
||||||
tabController.current = controller;
|
tabController.current = controller;
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[Home] failed to get tab controller', err);
|
||||||
});
|
});
|
||||||
}, [ getTabController ]);
|
}, [ getTabController ]);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,8 @@ const GenresView: FC<LibraryViewProps> = ({ topParentId }) => {
|
||||||
).then((result) => {
|
).then((result) => {
|
||||||
setItemsResult(result);
|
setItemsResult(result);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[GenresView] failed to fetch genres', err);
|
||||||
});
|
});
|
||||||
}, [topParentId]);
|
}, [topParentId]);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ const SuggestionsView: FC<LibraryViewProps> = ({ topParentId }) => {
|
||||||
const autoFocus = useCallback((page) => {
|
const autoFocus = useCallback((page) => {
|
||||||
import('../../../../components/autoFocuser').then(({ default: autoFocuser }) => {
|
import('../../../../components/autoFocuser').then(({ default: autoFocuser }) => {
|
||||||
autoFocuser.autoFocus(page);
|
autoFocuser.autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[SuggestionsView] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -55,6 +57,8 @@ const SuggestionsView: FC<LibraryViewProps> = ({ topParentId }) => {
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
autoFocus(page);
|
autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[SuggestionsView] failed to fetch items', err);
|
||||||
});
|
});
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
|
@ -72,6 +76,8 @@ const SuggestionsView: FC<LibraryViewProps> = ({ topParentId }) => {
|
||||||
setLatestItems(items);
|
setLatestItems(items);
|
||||||
|
|
||||||
autoFocus(page);
|
autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[SuggestionsView] failed to fetch latest items', err);
|
||||||
});
|
});
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
|
@ -95,6 +101,8 @@ const SuggestionsView: FC<LibraryViewProps> = ({ topParentId }) => {
|
||||||
setRecommendations(result);
|
setRecommendations(result);
|
||||||
|
|
||||||
autoFocus(page);
|
autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[SuggestionsView] failed to fetch recommendations', err);
|
||||||
});
|
});
|
||||||
}, [autoFocus]);
|
}, [autoFocus]);
|
||||||
|
|
||||||
|
|
|
@ -114,6 +114,8 @@ const Movies: FC = () => {
|
||||||
window.ApiClient.getItem(window.ApiClient.getCurrentUserId(), parentId).then((item) => {
|
window.ApiClient.getItem(window.ApiClient.getCurrentUserId(), parentId).then((item) => {
|
||||||
page.setAttribute('data-title', item.Name as string);
|
page.setAttribute('data-title', item.Name as string);
|
||||||
libraryMenu.setTitle(item.Name);
|
libraryMenu.setTitle(item.Name);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[movies] failed to fetch library', err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
page.setAttribute('data-title', globalize.translate('Movies'));
|
page.setAttribute('data-title', globalize.translate('Movies'));
|
||||||
|
|
|
@ -32,7 +32,10 @@ const getCheckedElementDataIds = (elements: NodeListOf<Element>) => (
|
||||||
);
|
);
|
||||||
|
|
||||||
function onSaveComplete() {
|
function onSaveComplete() {
|
||||||
Dashboard.navigate('userprofiles.html');
|
Dashboard.navigate('userprofiles.html')
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[useredit] failed to navigate to user profile', err);
|
||||||
|
});
|
||||||
loading.hide();
|
loading.hide();
|
||||||
toast(globalize.translate('SettingsSaved'));
|
toast(globalize.translate('SettingsSaved'));
|
||||||
}
|
}
|
||||||
|
@ -133,6 +136,8 @@ const UserEdit: FunctionComponent = () => {
|
||||||
const chkEnableDeleteAllFolders = page.querySelector('.chkEnableDeleteAllFolders') as HTMLInputElement;
|
const chkEnableDeleteAllFolders = page.querySelector('.chkEnableDeleteAllFolders') as HTMLInputElement;
|
||||||
chkEnableDeleteAllFolders.checked = user.Policy.EnableContentDeletion;
|
chkEnableDeleteAllFolders.checked = user.Policy.EnableContentDeletion;
|
||||||
triggerChange(chkEnableDeleteAllFolders);
|
triggerChange(chkEnableDeleteAllFolders);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to fetch channels', err);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
@ -146,14 +151,20 @@ const UserEdit: FunctionComponent = () => {
|
||||||
|
|
||||||
window.ApiClient.getJSON(window.ApiClient.getUrl('Auth/Providers')).then(function (providers) {
|
window.ApiClient.getJSON(window.ApiClient.getUrl('Auth/Providers')).then(function (providers) {
|
||||||
loadAuthProviders(user, providers);
|
loadAuthProviders(user, providers);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to fetch auth providers', err);
|
||||||
});
|
});
|
||||||
window.ApiClient.getJSON(window.ApiClient.getUrl('Auth/PasswordResetProviders')).then(function (providers) {
|
window.ApiClient.getJSON(window.ApiClient.getUrl('Auth/PasswordResetProviders')).then(function (providers) {
|
||||||
loadPasswordResetProviders(user, providers);
|
loadPasswordResetProviders(user, providers);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to fetch password reset providers', err);
|
||||||
});
|
});
|
||||||
window.ApiClient.getJSON(window.ApiClient.getUrl('Library/MediaFolders', {
|
window.ApiClient.getJSON(window.ApiClient.getUrl('Library/MediaFolders', {
|
||||||
IsHidden: false
|
IsHidden: false
|
||||||
})).then(function (folders) {
|
})).then(function (folders) {
|
||||||
loadDeleteFolders(user, folders.Items);
|
loadDeleteFolders(user, folders.Items);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to fetch media folders', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
const disabledUserBanner = page.querySelector('.disabledUserBanner') as HTMLDivElement;
|
const disabledUserBanner = page.querySelector('.disabledUserBanner') as HTMLDivElement;
|
||||||
|
@ -197,6 +208,8 @@ const UserEdit: FunctionComponent = () => {
|
||||||
loading.show();
|
loading.show();
|
||||||
getUser().then(function (user) {
|
getUser().then(function (user) {
|
||||||
loadUser(user);
|
loadUser(user);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, [loadUser]);
|
}, [loadUser]);
|
||||||
|
|
||||||
|
@ -240,18 +253,21 @@ const UserEdit: FunctionComponent = () => {
|
||||||
user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : getCheckedElementDataIds(page.querySelectorAll('.chkFolder'));
|
user.Policy.EnableContentDeletionFromFolders = user.Policy.EnableContentDeletion ? [] : getCheckedElementDataIds(page.querySelectorAll('.chkFolder'));
|
||||||
user.Policy.SyncPlayAccess = (page.querySelector('#selectSyncPlayAccess') as HTMLSelectElement).value as SyncPlayUserAccessType;
|
user.Policy.SyncPlayAccess = (page.querySelector('#selectSyncPlayAccess') as HTMLSelectElement).value as SyncPlayUserAccessType;
|
||||||
|
|
||||||
window.ApiClient.updateUser(user)
|
window.ApiClient.updateUser(user).then(() => (
|
||||||
.then(() => (
|
window.ApiClient.updateUserPolicy(user.Id || '', user.Policy || {})
|
||||||
window.ApiClient.updateUserPolicy(user.Id || '', user.Policy || {})
|
)).then(() => {
|
||||||
)).then(() => {
|
onSaveComplete();
|
||||||
onSaveComplete();
|
}).catch(err => {
|
||||||
});
|
console.error('[useredit] failed to update user', err);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = (e: Event) => {
|
const onSubmit = (e: Event) => {
|
||||||
loading.show();
|
loading.show();
|
||||||
getUser().then(function (result) {
|
getUser().then(function (result) {
|
||||||
saveUser(result);
|
saveUser(result);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to fetch user', err);
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -264,6 +280,8 @@ const UserEdit: FunctionComponent = () => {
|
||||||
|
|
||||||
window.ApiClient.getNamedConfiguration('network').then(function (config) {
|
window.ApiClient.getNamedConfiguration('network').then(function (config) {
|
||||||
(page.querySelector('.fldRemoteAccess') as HTMLDivElement).classList.toggle('hide', !config.EnableRemoteAccess);
|
(page.querySelector('.fldRemoteAccess') as HTMLDivElement).classList.toggle('hide', !config.EnableRemoteAccess);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[useredit] failed to load network config', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
(page.querySelector('.editUserProfileForm') as HTMLFormElement).addEventListener('submit', onSubmit);
|
(page.querySelector('.editUserProfileForm') as HTMLFormElement).addEventListener('submit', onSubmit);
|
||||||
|
|
|
@ -148,6 +148,8 @@ const UserLibraryAccess: FunctionComponent = () => {
|
||||||
const promise4 = window.ApiClient.getJSON(window.ApiClient.getUrl('Devices'));
|
const promise4 = window.ApiClient.getJSON(window.ApiClient.getUrl('Devices'));
|
||||||
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
|
Promise.all([promise1, promise2, promise3, promise4]).then(function (responses) {
|
||||||
loadUser(responses[0], responses[1].Items, responses[2].Items, responses[3].Items);
|
loadUser(responses[0], responses[1].Items, responses[2].Items, responses[3].Items);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userlibraryaccess] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, [loadUser]);
|
}, [loadUser]);
|
||||||
|
|
||||||
|
@ -166,6 +168,8 @@ const UserLibraryAccess: FunctionComponent = () => {
|
||||||
const userId = getParameterByName('userId');
|
const userId = getParameterByName('userId');
|
||||||
window.ApiClient.getUser(userId).then(function (result) {
|
window.ApiClient.getUser(userId).then(function (result) {
|
||||||
saveUser(result);
|
saveUser(result);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userlibraryaccess] failed to fetch user', err);
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -203,6 +207,8 @@ const UserLibraryAccess: FunctionComponent = () => {
|
||||||
user.Policy.BlockedMediaFolders = null;
|
user.Policy.BlockedMediaFolders = null;
|
||||||
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
||||||
onSaveComplete();
|
onSaveComplete();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userlibraryaccess] failed to update user policy', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ const UserNew: FunctionComponent = () => {
|
||||||
loadMediaFolders(responses[0].Items);
|
loadMediaFolders(responses[0].Items);
|
||||||
loadChannels(responses[1].Items);
|
loadChannels(responses[1].Items);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[usernew] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, [loadChannels, loadMediaFolders]);
|
}, [loadChannels, loadMediaFolders]);
|
||||||
|
|
||||||
|
@ -138,7 +140,12 @@ const UserNew: FunctionComponent = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
||||||
Dashboard.navigate('useredit.html?userId=' + user.Id);
|
Dashboard.navigate('useredit.html?userId=' + user.Id)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[usernew] failed to navigate to edit user page', err);
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[usernew] failed to update user policy', err);
|
||||||
});
|
});
|
||||||
}, function () {
|
}, function () {
|
||||||
toast(globalize.translate('ErrorDefault'));
|
toast(globalize.translate('ErrorDefault'));
|
||||||
|
|
|
@ -197,6 +197,8 @@ const UserParentalControl: FunctionComponent = () => {
|
||||||
const promise2 = window.ApiClient.getParentalRatings();
|
const promise2 = window.ApiClient.getParentalRatings();
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
loadUser(responses[0], responses[1]);
|
loadUser(responses[0], responses[1]);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userparentalcontrol] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, [loadUser]);
|
}, [loadUser]);
|
||||||
|
|
||||||
|
@ -231,6 +233,8 @@ const UserParentalControl: FunctionComponent = () => {
|
||||||
user.Policy.BlockedTags = getBlockedTagsFromPage();
|
user.Policy.BlockedTags = getBlockedTagsFromPage();
|
||||||
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
window.ApiClient.updateUserPolicy(user.Id, user.Policy).then(function () {
|
||||||
onSaveComplete();
|
onSaveComplete();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userparentalcontrol] failed to update user policy', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,7 +252,11 @@ const UserParentalControl: FunctionComponent = () => {
|
||||||
|
|
||||||
schedules[index] = updatedSchedule;
|
schedules[index] = updatedSchedule;
|
||||||
renderAccessSchedule(schedules);
|
renderAccessSchedule(schedules);
|
||||||
|
}).catch(() => {
|
||||||
|
// access schedule closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userparentalcontrol] failed to load access schedule', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -279,7 +287,11 @@ const UserParentalControl: FunctionComponent = () => {
|
||||||
tags.push(value);
|
tags.push(value);
|
||||||
loadBlockedTags(tags);
|
loadBlockedTags(tags);
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// prompt closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userparentalcontrol] failed to load prompt', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -288,6 +300,8 @@ const UserParentalControl: FunctionComponent = () => {
|
||||||
const userId = getParameterByName('userId');
|
const userId = getParameterByName('userId');
|
||||||
window.ApiClient.getUser(userId).then(function (result) {
|
window.ApiClient.getUser(userId).then(function (result) {
|
||||||
saveUser(result);
|
saveUser(result);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userparentalcontrol] failed to fetch user', err);
|
||||||
});
|
});
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
|
@ -19,6 +19,8 @@ const UserPassword: FunctionComponent = () => {
|
||||||
}
|
}
|
||||||
setUserName(user.Name);
|
setUserName(user.Name);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userpassword] failed to fetch user', err);
|
||||||
});
|
});
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -59,8 +59,12 @@ const UserProfile: FunctionComponent = () => {
|
||||||
(page.querySelector('#btnDeleteImage') as HTMLButtonElement).classList.add('hide');
|
(page.querySelector('#btnDeleteImage') as HTMLButtonElement).classList.add('hide');
|
||||||
(page.querySelector('#btnAddImage') as HTMLButtonElement).classList.remove('hide');
|
(page.querySelector('#btnAddImage') as HTMLButtonElement).classList.remove('hide');
|
||||||
}
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofile] failed to get current user', err);
|
||||||
});
|
});
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofile] failed to load data', err);
|
||||||
});
|
});
|
||||||
}, [userId]);
|
}, [userId]);
|
||||||
|
|
||||||
|
@ -110,6 +114,8 @@ const UserProfile: FunctionComponent = () => {
|
||||||
window.ApiClient.uploadUserImage(userId, ImageType.Primary, file).then(function () {
|
window.ApiClient.uploadUserImage(userId, ImageType.Primary, file).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
reloadUser();
|
reloadUser();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofile] failed to upload image', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -125,7 +131,11 @@ const UserProfile: FunctionComponent = () => {
|
||||||
window.ApiClient.deleteUserImage(userId, ImageType.Primary).then(function () {
|
window.ApiClient.deleteUserImage(userId, ImageType.Primary).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
reloadUser();
|
reloadUser();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofile] failed to delete image', err);
|
||||||
});
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
// confirm dialog closed
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,8 @@ const UserProfiles: FunctionComponent = () => {
|
||||||
window.ApiClient.getUsers().then(function (result) {
|
window.ApiClient.getUsers().then(function (result) {
|
||||||
setUsers(result);
|
setUsers(result);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofiles] failed to fetch users', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,22 +85,35 @@ const UserProfiles: FunctionComponent = () => {
|
||||||
callback: function (id: string) {
|
callback: function (id: string) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'open':
|
case 'open':
|
||||||
Dashboard.navigate('useredit.html?userId=' + userId);
|
Dashboard.navigate('useredit.html?userId=' + userId)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[userprofiles] failed to navigate to user edit page', err);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'access':
|
case 'access':
|
||||||
Dashboard.navigate('userlibraryaccess.html?userId=' + userId);
|
Dashboard.navigate('userlibraryaccess.html?userId=' + userId)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[userprofiles] failed to navigate to user library page', err);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'parentalcontrol':
|
case 'parentalcontrol':
|
||||||
Dashboard.navigate('userparentalcontrol.html?userId=' + userId);
|
Dashboard.navigate('userparentalcontrol.html?userId=' + userId)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[userprofiles] failed to navigate to parental control page', err);
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
deleteUser(userId);
|
deleteUser(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
// action sheet closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofiles] failed to load action sheet', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,7 +129,11 @@ const UserProfiles: FunctionComponent = () => {
|
||||||
loading.show();
|
loading.show();
|
||||||
window.ApiClient.deleteUser(id).then(function () {
|
window.ApiClient.deleteUser(id).then(function () {
|
||||||
loadData();
|
loadData();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[userprofiles] failed to delete user', err);
|
||||||
});
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
// confirm dialog closed
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -127,7 +146,10 @@ const UserProfiles: FunctionComponent = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
(page.querySelector('#btnAddUser') as HTMLButtonElement).addEventListener('click', function() {
|
(page.querySelector('#btnAddUser') as HTMLButtonElement).addEventListener('click', function() {
|
||||||
Dashboard.navigate('usernew.html');
|
Dashboard.navigate('usernew.html')
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[userprofiles] failed to navigate to new user page', err);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounce to the correct page in the login flow
|
// Bounce to the correct page in the login flow
|
||||||
bounce(firstConnection);
|
bounce(firstConnection)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[ConnectionRequired] failed to bounce', err);
|
||||||
|
});
|
||||||
}, [bounce, navigate]);
|
}, [bounce, navigate]);
|
||||||
|
|
||||||
const validateUserAccess = useCallback(async () => {
|
const validateUserAccess = useCallback(async () => {
|
||||||
|
@ -109,7 +112,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
if ((isAdminRequired || isUserRequired) && !client?.isLoggedIn()) {
|
if ((isAdminRequired || isUserRequired) && !client?.isLoggedIn()) {
|
||||||
try {
|
try {
|
||||||
console.warn('[ConnectionRequired] unauthenticated user attempted to access user route');
|
console.warn('[ConnectionRequired] unauthenticated user attempted to access user route');
|
||||||
bounce(await ServerConnections.connect());
|
bounce(await ServerConnections.connect())
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[ConnectionRequired] failed to bounce', err);
|
||||||
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
console.warn('[ConnectionRequired] error bouncing from user route', ex);
|
console.warn('[ConnectionRequired] error bouncing from user route', ex);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +128,10 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
const user = await client?.getCurrentUser();
|
const user = await client?.getCurrentUser();
|
||||||
if (!user?.Policy?.IsAdministrator) {
|
if (!user?.Policy?.IsAdministrator) {
|
||||||
console.warn('[ConnectionRequired] normal user attempted to access admin route');
|
console.warn('[ConnectionRequired] normal user attempted to access admin route');
|
||||||
bounce(await ServerConnections.connect());
|
bounce(await ServerConnections.connect())
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[ConnectionRequired] failed to bounce', err);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
@ -143,9 +152,15 @@ const ConnectionRequired: FunctionComponent<ConnectionRequiredProps> = ({
|
||||||
appRouter.firstConnectionResult = null;
|
appRouter.firstConnectionResult = null;
|
||||||
|
|
||||||
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
|
if (firstConnection && firstConnection.State !== ConnectionState.SignedIn) {
|
||||||
handleIncompleteWizard(firstConnection);
|
handleIncompleteWizard(firstConnection)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[ConnectionRequired] failed to start wizard', err);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
validateUserAccess();
|
validateUserAccess()
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[ConnectionRequired] failed to validate user access', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [handleIncompleteWizard, validateUserAccess]);
|
}, [handleIncompleteWizard, validateUserAccess]);
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,11 @@ const Filter: FC<FilterProps> = ({
|
||||||
serverId: window.ApiClient.serverId(),
|
serverId: window.ApiClient.serverId(),
|
||||||
filterMenuOptions: getFilterMenuOptions(),
|
filterMenuOptions: getFilterMenuOptions(),
|
||||||
setfilters: setViewQuerySettings
|
setfilters: setViewQuerySettings
|
||||||
|
}).catch(() => {
|
||||||
|
// filter menu closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[Filter] failed to load filter menu', err);
|
||||||
});
|
});
|
||||||
}, [viewQuerySettings, getVisibleFilters, topParentId, getItemTypes, getFilterMenuOptions, setViewQuerySettings]);
|
}, [viewQuerySettings, getVisibleFilters, topParentId, getItemTypes, getFilterMenuOptions, setViewQuerySettings]);
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ const GenresItemsContainer: FC<GenresItemsContainerProps> = ({
|
||||||
centerText: true,
|
centerText: true,
|
||||||
showYear: true
|
showYear: true
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[GenresItemsContainer] failed to fetch items', err);
|
||||||
});
|
});
|
||||||
}, [getPortraitShape, topParentId]);
|
}, [getPortraitShape, topParentId]);
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,11 @@ const NewCollection: FC = () => {
|
||||||
collectionEditor.show({
|
collectionEditor.show({
|
||||||
items: [],
|
items: [],
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
|
}).catch(() => {
|
||||||
|
// closed collection editor
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[NewCollection] failed to load collection editor', err);
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,11 @@ const SelectView: FC<SelectViewProps> = ({
|
||||||
settings: viewQuerySettings,
|
settings: viewQuerySettings,
|
||||||
visibleSettings: getVisibleViewSettings(),
|
visibleSettings: getVisibleViewSettings(),
|
||||||
setviewsettings: setViewQuerySettings
|
setviewsettings: setViewQuerySettings
|
||||||
|
}).catch(() => {
|
||||||
|
// view settings closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[SelectView] failed to load view settings', err);
|
||||||
});
|
});
|
||||||
}, [getVisibleViewSettings, viewQuerySettings, setViewQuerySettings]);
|
}, [getVisibleViewSettings, viewQuerySettings, setViewQuerySettings]);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,8 @@ const Shuffle: FC<ShuffleProps> = ({ itemsResult = {}, topParentId }) => {
|
||||||
topParentId as string
|
topParentId as string
|
||||||
).then((item) => {
|
).then((item) => {
|
||||||
playbackManager.shuffle(item);
|
playbackManager.shuffle(item);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[Shuffle] failed to fetch items', err);
|
||||||
});
|
});
|
||||||
}, [topParentId]);
|
}, [topParentId]);
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,11 @@ const Sort: FC<SortProps> = ({
|
||||||
settings: viewQuerySettings,
|
settings: viewQuerySettings,
|
||||||
sortOptions: getSortMenuOptions(),
|
sortOptions: getSortMenuOptions(),
|
||||||
setSortValues: setViewQuerySettings
|
setSortValues: setViewQuerySettings
|
||||||
|
}).catch(() => {
|
||||||
|
// sort menu closed
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[Sort] failed to load sort menu', err);
|
||||||
});
|
});
|
||||||
}, [getSortMenuOptions, viewQuerySettings, setViewQuerySettings]);
|
}, [getSortMenuOptions, viewQuerySettings, setViewQuerySettings]);
|
||||||
|
|
||||||
|
|
|
@ -335,9 +335,13 @@ const ViewItemsContainer: FC<ViewItemsContainerProps> = ({
|
||||||
|
|
||||||
import('../../components/autoFocuser').then(({ default: autoFocuser }) => {
|
import('../../components/autoFocuser').then(({ default: autoFocuser }) => {
|
||||||
autoFocuser.autoFocus(page);
|
autoFocuser.autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[ViewItemsContainer] failed to load autofocuser', err);
|
||||||
});
|
});
|
||||||
loading.hide();
|
loading.hide();
|
||||||
setisLoading(true);
|
setisLoading(true);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[ViewItemsContainer] failed to fetch data', err);
|
||||||
});
|
});
|
||||||
}, [fetchData]);
|
}, [fetchData]);
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,8 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
|
|
||||||
import('../../autoFocuser').then(({ default: autoFocuser }) => {
|
import('../../autoFocuser').then(({ default: autoFocuser }) => {
|
||||||
autoFocuser.autoFocus(page);
|
autoFocuser.autoFocus(page);
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load autofocuser', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
(page.querySelector('#txtCurrentPassword') as HTMLInputElement).value = '';
|
(page.querySelector('#txtCurrentPassword') as HTMLInputElement).value = '';
|
||||||
|
@ -81,7 +83,9 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUser();
|
loadUser().catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load user', err);
|
||||||
|
});
|
||||||
|
|
||||||
const onSubmit = (e: Event) => {
|
const onSubmit = (e: Event) => {
|
||||||
if ((page.querySelector('#txtNewPassword') as HTMLInputElement).value != (page.querySelector('#txtNewPasswordConfirm') as HTMLInputElement).value) {
|
if ((page.querySelector('#txtNewPassword') as HTMLInputElement).value != (page.querySelector('#txtNewPasswordConfirm') as HTMLInputElement).value) {
|
||||||
|
@ -109,7 +113,9 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
toast(globalize.translate('PasswordSaved'));
|
toast(globalize.translate('PasswordSaved'));
|
||||||
|
|
||||||
loadUser();
|
loadUser().catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load user', err);
|
||||||
|
});
|
||||||
}, function () {
|
}, function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
Dashboard.alert({
|
Dashboard.alert({
|
||||||
|
@ -132,6 +138,8 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
if (easyPassword) {
|
if (easyPassword) {
|
||||||
window.ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
|
window.ApiClient.updateEasyPassword(userId, easyPassword).then(function () {
|
||||||
onEasyPasswordSaved();
|
onEasyPasswordSaved();
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to update easy password', err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
onEasyPasswordSaved();
|
onEasyPasswordSaved();
|
||||||
|
@ -153,8 +161,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
toast(globalize.translate('SettingsSaved'));
|
toast(globalize.translate('SettingsSaved'));
|
||||||
|
|
||||||
loadUser();
|
loadUser().catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load user', err);
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to update user configuration', err);
|
||||||
});
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to fetch user', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -169,8 +183,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
message: globalize.translate('PinCodeResetComplete'),
|
message: globalize.translate('PinCodeResetComplete'),
|
||||||
title: globalize.translate('HeaderPinCodeReset')
|
title: globalize.translate('HeaderPinCodeReset')
|
||||||
});
|
});
|
||||||
loadUser();
|
loadUser().catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load user', err);
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to reset easy password', err);
|
||||||
});
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
// confirm dialog was closed
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -184,8 +204,14 @@ const UserPasswordForm: FunctionComponent<IProps> = ({ userId }: IProps) => {
|
||||||
message: globalize.translate('PasswordResetComplete'),
|
message: globalize.translate('PasswordResetComplete'),
|
||||||
title: globalize.translate('ResetPassword')
|
title: globalize.translate('ResetPassword')
|
||||||
});
|
});
|
||||||
loadUser();
|
loadUser().catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to load user', err);
|
||||||
|
});
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('[UserPasswordForm] failed to reset user password', err);
|
||||||
});
|
});
|
||||||
|
}).catch(() => {
|
||||||
|
// confirm dialog was closed
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,9 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
IsMovie: true
|
IsMovie: true
|
||||||
}).then(result => setMovies(result.Items || []));
|
})
|
||||||
|
.then(result => setMovies(result.Items || []))
|
||||||
|
.catch(() => setMovies([]));
|
||||||
// Episodes row
|
// Episodes row
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
|
@ -88,22 +90,30 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
||||||
IsSports: false,
|
IsSports: false,
|
||||||
IsKids: false,
|
IsKids: false,
|
||||||
IsNews: false
|
IsNews: false
|
||||||
}).then(result => setEpisodes(result.Items || []));
|
})
|
||||||
|
.then(result => setEpisodes(result.Items || []))
|
||||||
|
.catch(() => setEpisodes([]));
|
||||||
// Sports row
|
// Sports row
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
IsSports: true
|
IsSports: true
|
||||||
}).then(result => setSports(result.Items || []));
|
})
|
||||||
|
.then(result => setSports(result.Items || []))
|
||||||
|
.catch(() => setSports([]));
|
||||||
// Kids row
|
// Kids row
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
IsKids: true
|
IsKids: true
|
||||||
}).then(result => setKids(result.Items || []));
|
})
|
||||||
|
.then(result => setKids(result.Items || []))
|
||||||
|
.catch(() => setKids([]));
|
||||||
// News row
|
// News row
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
IsNews: true
|
IsNews: true
|
||||||
}).then(result => setNews(result.Items || []));
|
})
|
||||||
|
.then(result => setNews(result.Items || []))
|
||||||
|
.catch(() => setNews([]));
|
||||||
// Programs row
|
// Programs row
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
IncludeItemTypes: 'LiveTvProgram',
|
IncludeItemTypes: 'LiveTvProgram',
|
||||||
|
@ -112,10 +122,13 @@ const LiveTVSearchResults: FunctionComponent<LiveTVSearchResultsProps> = ({ serv
|
||||||
IsSports: false,
|
IsSports: false,
|
||||||
IsKids: false,
|
IsKids: false,
|
||||||
IsNews: false
|
IsNews: false
|
||||||
}).then(result => setPrograms(result.Items || []));
|
})
|
||||||
|
.then(result => setPrograms(result.Items || []))
|
||||||
|
.catch(() => setPrograms([]));
|
||||||
// Channels row
|
// Channels row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
||||||
.then(result => setChannels(result.Items || []));
|
.then(result => setChannels(result.Items || []))
|
||||||
|
.catch(() => setChannels([]));
|
||||||
}
|
}
|
||||||
}, [collectionType, parentId, query, serverId]);
|
}, [collectionType, parentId, query, serverId]);
|
||||||
|
|
||||||
|
|
|
@ -123,38 +123,48 @@ const SearchResults: FunctionComponent<SearchResultsProps> = ({ serverId = windo
|
||||||
if (!collectionType || isMovies(collectionType)) {
|
if (!collectionType || isMovies(collectionType)) {
|
||||||
// Movies row
|
// Movies row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Movie' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Movie' })
|
||||||
.then(result => setMovies(result.Items));
|
.then(result => setMovies(result.Items))
|
||||||
|
.catch(() => setMovies([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TV Show libraries
|
// TV Show libraries
|
||||||
if (!collectionType || isTVShows(collectionType)) {
|
if (!collectionType || isTVShows(collectionType)) {
|
||||||
// Shows row
|
// Shows row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Series' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Series' })
|
||||||
.then(result => setShows(result.Items));
|
.then(result => setShows(result.Items))
|
||||||
|
.catch(() => setShows([]));
|
||||||
// Episodes row
|
// Episodes row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Episode' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Episode' })
|
||||||
.then(result => setEpisodes(result.Items));
|
.then(result => setEpisodes(result.Items))
|
||||||
|
.catch(() => setEpisodes([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// People are included for Movies and TV Shows
|
// People are included for Movies and TV Shows
|
||||||
if (!collectionType || isMovies(collectionType) || isTVShows(collectionType)) {
|
if (!collectionType || isMovies(collectionType) || isTVShows(collectionType)) {
|
||||||
// People row
|
// People row
|
||||||
fetchPeople(apiClient).then(result => setPeople(result.Items));
|
fetchPeople(apiClient)
|
||||||
|
.then(result => setPeople(result.Items))
|
||||||
|
.catch(() => setPeople([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Music libraries
|
// Music libraries
|
||||||
if (!collectionType || isMusic(collectionType)) {
|
if (!collectionType || isMusic(collectionType)) {
|
||||||
// Playlists row
|
// Playlists row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Playlist' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Playlist' })
|
||||||
.then(results => setPlaylists(results.Items));
|
.then(results => setPlaylists(results.Items))
|
||||||
|
.catch(() => setPlaylists([]));
|
||||||
// Artists row
|
// Artists row
|
||||||
fetchArtists(apiClient).then(result => setArtists(result.Items));
|
fetchArtists(apiClient)
|
||||||
|
.then(result => setArtists(result.Items))
|
||||||
|
.catch(() => setArtists([]));
|
||||||
// Albums row
|
// Albums row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'MusicAlbum' })
|
fetchItems(apiClient, { IncludeItemTypes: 'MusicAlbum' })
|
||||||
.then(result => setAlbums(result.Items));
|
.then(result => setAlbums(result.Items))
|
||||||
|
.catch(() => setAlbums([]));
|
||||||
// Songs row
|
// Songs row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Audio' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Audio' })
|
||||||
.then(result => setSongs(result.Items));
|
.then(result => setSongs(result.Items))
|
||||||
|
.catch(() => setSongs([]));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other libraries do not support in-library search currently
|
// Other libraries do not support in-library search currently
|
||||||
|
@ -163,28 +173,37 @@ const SearchResults: FunctionComponent<SearchResultsProps> = ({ serverId = windo
|
||||||
fetchItems(apiClient, {
|
fetchItems(apiClient, {
|
||||||
MediaTypes: 'Video',
|
MediaTypes: 'Video',
|
||||||
ExcludeItemTypes: 'Movie,Episode,TvChannel'
|
ExcludeItemTypes: 'Movie,Episode,TvChannel'
|
||||||
}).then(result => setVideos(result.Items));
|
})
|
||||||
|
.then(result => setVideos(result.Items))
|
||||||
|
.catch(() => setVideos([]));
|
||||||
// Programs row
|
// Programs row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'LiveTvProgram' })
|
fetchItems(apiClient, { IncludeItemTypes: 'LiveTvProgram' })
|
||||||
.then(result => setPrograms(result.Items));
|
.then(result => setPrograms(result.Items))
|
||||||
|
.catch(() => setPrograms([]));
|
||||||
// Channels row
|
// Channels row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
fetchItems(apiClient, { IncludeItemTypes: 'TvChannel' })
|
||||||
.then(result => setChannels(result.Items));
|
.then(result => setChannels(result.Items))
|
||||||
|
.catch(() => setChannels([]));
|
||||||
// Photo Albums row
|
// Photo Albums row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'PhotoAlbum' })
|
fetchItems(apiClient, { IncludeItemTypes: 'PhotoAlbum' })
|
||||||
.then(result => setPhotoAlbums(result.Items));
|
.then(result => setPhotoAlbums(result.Items))
|
||||||
|
.catch(() => setPhotoAlbums([]));
|
||||||
// Photos row
|
// Photos row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Photo' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Photo' })
|
||||||
.then(result => setPhotos(result.Items));
|
.then(result => setPhotos(result.Items))
|
||||||
|
.catch(() => setPhotos([]));
|
||||||
// Audio Books row
|
// Audio Books row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'AudioBook' })
|
fetchItems(apiClient, { IncludeItemTypes: 'AudioBook' })
|
||||||
.then(result => setAudioBooks(result.Items));
|
.then(result => setAudioBooks(result.Items))
|
||||||
|
.catch(() => setAudioBooks([]));
|
||||||
// Books row
|
// Books row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'Book' })
|
fetchItems(apiClient, { IncludeItemTypes: 'Book' })
|
||||||
.then(result => setBooks(result.Items));
|
.then(result => setBooks(result.Items))
|
||||||
|
.catch(() => setBooks([]));
|
||||||
// Collections row
|
// Collections row
|
||||||
fetchItems(apiClient, { IncludeItemTypes: 'BoxSet' })
|
fetchItems(apiClient, { IncludeItemTypes: 'BoxSet' })
|
||||||
.then(result => setCollections(result.Items));
|
.then(result => setCollections(result.Items))
|
||||||
|
.catch(() => setCollections([]));
|
||||||
}
|
}
|
||||||
}, [collectionType, fetchArtists, fetchItems, fetchPeople, query, serverId]);
|
}, [collectionType, fetchArtists, fetchItems, fetchPeople, query, serverId]);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,11 @@ const SearchSuggestions: FunctionComponent<SearchSuggestionsProps> = ({ parentId
|
||||||
parentId: parentId || undefined,
|
parentId: parentId || undefined,
|
||||||
enableTotalRecordCount: false
|
enableTotalRecordCount: false
|
||||||
})
|
})
|
||||||
.then(result => setSuggestions(result.data.Items || []));
|
.then(result => setSuggestions(result.data.Items || []))
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[SearchSuggestions] failed to fetch search suggestions', err);
|
||||||
|
setSuggestions([]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [ api, parentId, user ]);
|
}, [ api, parentId, user ]);
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,10 @@ const LinkButton: React.FC<LinkButtonProps> = ({
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
appRouter.show(url);
|
appRouter.show(url)
|
||||||
|
.catch(err => {
|
||||||
|
console.error('[LinkButton] failed to show url', url, err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -107,6 +107,12 @@ export function getConfigurationResourceUrl(name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigate to a url.
|
||||||
|
* @param {string} url - The url to navigate to.
|
||||||
|
* @param {boolean} [preserveQueryString] - A flag to indicate the current query string should be appended to the new url.
|
||||||
|
* @returns {Promise<any>}
|
||||||
|
*/
|
||||||
export function navigate(url, preserveQueryString) {
|
export function navigate(url, preserveQueryString) {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
throw new Error('url cannot be null or empty');
|
throw new Error('url cannot be null or empty');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue