mirror of
https://github.com/idanoo/autobrr
synced 2025-07-23 16:59:12 +00:00
enhancement(web): modernize APIClient and improve robustness (#1093)
modernized APIClient, removed Notification type collision enhancement: APIClient now follows the recent RFC3986 (this wasn't the case previously) enhancement: improved APIClient DX by adding a queryString parameter (avoiding URLSearchParameters) fix: changed Notification type to ServiceNotification (collision with built-in browser API https://developer.mozilla.org/en-US/docs/Web/API/Notification -- so TS checks wouldn't function as necessary)
This commit is contained in:
parent
2fed48e0dd
commit
438902137b
4 changed files with 244 additions and 123 deletions
|
@ -64,7 +64,7 @@ function NotificationSettings() {
|
|||
<div className="hidden md:flex col-span-3 px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">Events</div>
|
||||
</li>
|
||||
|
||||
{data && data.map((n: Notification) => (
|
||||
{data && data.map((n: ServiceNotification) => (
|
||||
<ListItem key={n.id} notification={n} />
|
||||
))}
|
||||
</ol>
|
||||
|
@ -108,7 +108,7 @@ const iconComponentMap: componentMapType = {
|
|||
};
|
||||
|
||||
interface ListItemProps {
|
||||
notification: Notification;
|
||||
notification: ServiceNotification;
|
||||
}
|
||||
|
||||
function ListItem({ notification }: ListItemProps) {
|
||||
|
@ -117,8 +117,8 @@ function ListItem({ notification }: ListItemProps) {
|
|||
const queryClient = useQueryClient();
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: (notification: Notification) => APIClient.notifications.update(notification).then(() => notification),
|
||||
onSuccess: (notification: Notification) => {
|
||||
mutationFn: (notification: ServiceNotification) => APIClient.notifications.update(notification).then(() => notification),
|
||||
onSuccess: (notification: ServiceNotification) => {
|
||||
toast.custom(t => <Toast type="success" body={`${notification.name} was ${notification.enabled ? "enabled" : "disabled"} successfully.`} t={t} />);
|
||||
queryClient.invalidateQueries({ queryKey: notificationKeys.lists() });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue