diff --git a/.dockerignore b/.dockerignore index 3ddaa574..7d669c86 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,6 +10,7 @@ .gitconfig .github .gitignore +.husky .next .prettierignore config/db/* diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ea4a77a..ec9692c4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: container: node:14.18-alpine steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Install dependencies env: HUSKY_SKIP_INSTALL: 1 @@ -32,31 +32,31 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Set up QEMU uses: docker/setup-qemu-action@v1.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.3.0 + uses: docker/setup-buildx-action@v1.6.0 - name: Cache Docker layers - uses: actions/cache@v2.1.6 + uses: actions/cache@v2.1.7 with: path: /tmp/.buildx-cache key: ${{ runner.os }}-buildx-${{ github.sha }} restore-keys: | ${{ runner.os }}-buildx- - name: Log in to Docker Hub - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2.5.0 + uses: docker/build-push-action@v2.8.0 with: context: . file: ./Dockerfile @@ -86,7 +86,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Get Build Job Status - uses: technote-space/workflow-conclusion-action@v2.1.6 + uses: technote-space/workflow-conclusion-action@v2.2.2 - name: Combine Job Status id: status run: | diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml index 809d4706..dc6987cd 100644 --- a/.github/workflows/deploy_docs.yml +++ b/.github/workflows/deploy_docs.yml @@ -11,7 +11,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Generate Swagger UI - uses: Legion2/swagger-ui-action@v1.1.2 + uses: Legion2/swagger-ui-action@v1.1.3 with: output: swagger-ui spec-file: overseerr-api.yml diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index a4246428..9633e901 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -11,27 +11,27 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Get the version id: get_version run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} - name: Set up QEMU uses: docker/setup-qemu-action@v1.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.3.0 + uses: docker/setup-buildx-action@v1.6.0 - name: Log in to Docker Hub - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v2.5.0 + uses: docker/build-push-action@v2.8.0 with: context: . file: ./Dockerfile diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c3b40e3e..a8db8fee 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,7 +12,7 @@ jobs: container: node:14.18-alpine steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Install dependencies env: HUSKY_SKIP_INSTALL: 1 @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 with: fetch-depth: 0 - name: Set up Node.js @@ -38,14 +38,14 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v1.2.0 - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1.3.0 + uses: docker/setup-buildx-action@v1.6.0 - name: Log in to Docker Hub - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} - name: Log in to GitHub Container Registry - uses: docker/login-action@v1.9.0 + uses: docker/login-action@v1.12.0 with: registry: ghcr.io username: ${{ github.repository_owner }} @@ -72,7 +72,7 @@ jobs: - armhf steps: - name: Checkout Code - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 with: fetch-depth: 0 - name: Switch to master branch @@ -120,7 +120,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Get Build Job Status - uses: technote-space/workflow-conclusion-action@v2.1.6 + uses: technote-space/workflow-conclusion-action@v2.2.2 - name: Combine Job Status id: status run: | diff --git a/.github/workflows/snap.yaml b/.github/workflows/snap.yaml index ce1e1d24..43d0ac50 100644 --- a/.github/workflows/snap.yaml +++ b/.github/workflows/snap.yaml @@ -12,7 +12,7 @@ jobs: if: "!contains(github.event.head_commit.message, '[skip ci]')" steps: - name: Cancel Previous Runs - uses: styfle/cancel-workflow-action@0.9.0 + uses: styfle/cancel-workflow-action@0.9.1 with: access_token: ${{ secrets.GITHUB_TOKEN }} @@ -23,7 +23,7 @@ jobs: container: node:14.18-alpine steps: - name: Checkout - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Install dependencies env: HUSKY_SKIP_INSTALL: 1 @@ -46,7 +46,7 @@ jobs: - armhf steps: - name: Checkout Code - uses: actions/checkout@v2.3.4 + uses: actions/checkout@v2.4.0 - name: Prepare id: prepare run: | @@ -88,7 +88,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Get Build Job Status - uses: technote-space/workflow-conclusion-action@v2.1.6 + uses: technote-space/workflow-conclusion-action@v2.2.2 - name: Combine Job Status id: status run: | diff --git a/.github/workflows/support.yml b/.github/workflows/support.yml index 09d86bc6..e316ec70 100644 --- a/.github/workflows/support.yml +++ b/.github/workflows/support.yml @@ -8,7 +8,7 @@ jobs: support: runs-on: ubuntu-20.04 steps: - - uses: dessant/support-requests@v2.0.1 + - uses: dessant/support-requests@v2.1.2 with: github-token: ${{ github.token }} support-label: 'support' diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..61e13c0e --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +[[ -n $HUSKY_BYPASS ]] || npx commitlint --edit $1 diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..36af2198 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 00000000..17e2764c --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +exec < /dev/tty && npx cz --hook || true diff --git a/next-env.d.ts b/next-env.d.ts index 9bc3dd46..4f11a03d 100644 --- a/next-env.d.ts +++ b/next-env.d.ts @@ -1,5 +1,4 @@ /// -/// /// // NOTE: This file should not be edited diff --git a/package.json b/package.json index 3f0d8654..65c3216b 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "migration:generate": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:generate", "migration:create": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:create", "migration:run": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:run", - "format": "prettier --write ." + "format": "prettier --write .", + "prepare": "husky install" }, "repository": { "type": "git", @@ -21,45 +22,45 @@ }, "license": "MIT", "dependencies": { - "@headlessui/react": "^1.4.1", - "@heroicons/react": "^1.0.4", + "@headlessui/react": "^1.4.3", + "@heroicons/react": "^1.0.5", "@supercharge/request-ip": "^1.1.2", - "@svgr/webpack": "^5.5.0", - "@tanem/react-nprogress": "^3.0.79", - "ace-builds": "^1.4.12", + "@svgr/webpack": "^6.2.0", + "@tanem/react-nprogress": "^4.0.2", + "ace-builds": "^1.4.13", "axios": "^0.21.4", "bcrypt": "^5.0.1", "bowser": "^2.11.0", "connect-typeorm": "^1.1.4", - "cookie-parser": "^1.4.5", + "cookie-parser": "^1.4.6", "copy-to-clipboard": "^3.3.1", - "country-flag-icons": "^1.4.10", + "country-flag-icons": "^1.4.19", "csurf": "^1.11.0", "email-templates": "^8.0.8", - "express": "^4.17.1", - "express-openapi-validator": "^4.13.1", - "express-rate-limit": "^5.3.0", + "express": "^4.17.2", + "express-openapi-validator": "^4.13.5", + "express-rate-limit": "^6.1.0", "express-session": "^1.17.2", "formik": "^2.2.9", - "gravatar-url": "3.1.0", + "gravatar-url": "^3.1.0", "intl": "^1.2.5", "lodash": "^4.17.21", - "next": "11.1.2", + "next": "12.0.8", "node-cache": "^5.1.2", - "node-schedule": "^2.0.0", - "nodemailer": "^6.6.3", - "openpgp": "^5.0.0-3", - "plex-api": "^5.3.1", + "node-schedule": "^2.1.0", + "nodemailer": "^6.7.2", + "openpgp": "^5.0.1", + "plex-api": "^5.3.2", "pug": "^3.0.2", "react": "17.0.2", - "react-ace": "^9.3.0", + "react-ace": "^9.5.0", "react-animate-height": "^2.0.23", "react-dom": "17.0.2", - "react-intersection-observer": "^8.32.1", - "react-intl": "5.20.10", - "react-markdown": "^6.0.2", + "react-intersection-observer": "^8.33.1", + "react-intl": "5.24.3", + "react-markdown": "^8.0.0", "react-select": "^4.3.1", - "react-spring": "^9.2.4", + "react-spring": "^9.4.2", "react-toast-notifications": "^2.5.1", "react-transition-group": "^4.4.2", "react-truncate-markup": "^5.1.0", @@ -67,93 +68,84 @@ "reflect-metadata": "^0.1.13", "secure-random-password": "^0.2.3", "sqlite3": "^5.0.2", - "swagger-ui-express": "^4.1.6", - "swr": "^0.5.6", - "typeorm": "0.2.37", + "swagger-ui-express": "^4.3.0", + "swr": "^1.1.2", + "typeorm": "0.2.41", "web-push": "^3.4.5", - "winston": "^3.3.3", + "winston": "^3.4.0", "winston-daily-rotate-file": "^4.5.5", "xml2js": "^0.4.23", "yamljs": "^0.3.0", - "yup": "^0.32.9" + "yup": "^0.32.11" }, "devDependencies": { - "@babel/cli": "^7.15.7", - "@commitlint/cli": "^13.1.0", - "@commitlint/config-conventional": "^13.1.0", - "@semantic-release/changelog": "^5.0.1", - "@semantic-release/commit-analyzer": "^9.0.1", - "@semantic-release/exec": "^5.0.0", - "@semantic-release/git": "^9.0.1", - "@tailwindcss/aspect-ratio": "^0.2.1", - "@tailwindcss/forms": "^0.3.3", - "@tailwindcss/typography": "^0.4.1", + "@babel/cli": "^7.16.8", + "@commitlint/cli": "^16.0.3", + "@commitlint/config-conventional": "^16.0.0", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/exec": "^6.0.3", + "@semantic-release/git": "^10.0.1", + "@tailwindcss/aspect-ratio": "^0.4.0", + "@tailwindcss/forms": "^0.4.0", + "@tailwindcss/typography": "^0.5.0", "@types/bcrypt": "^5.0.0", "@types/cookie-parser": "^1.4.2", "@types/country-flag-icons": "^1.2.0", "@types/csurf": "^1.11.2", "@types/email-templates": "^8.0.4", "@types/express": "^4.17.13", - "@types/express-rate-limit": "^5.1.3", - "@types/express-session": "^1.17.3", - "@types/lodash": "^4.14.173", - "@types/node": "^15.6.1", + "@types/express-session": "^1.17.4", + "@types/lodash": "^4.14.178", + "@types/node": "^17.0.10", "@types/node-schedule": "^1.3.2", "@types/nodemailer": "^6.4.4", - "@types/react": "^17.0.22", - "@types/react-dom": "^17.0.9", + "@types/react": "^17.0.38", + "@types/react-dom": "^17.0.11", "@types/react-select": "^4.0.17", - "@types/react-toast-notifications": "^2.4.1", - "@types/react-transition-group": "^4.4.3", + "@types/react-transition-group": "^4.4.4", "@types/secure-random-password": "^0.2.1", "@types/swagger-ui-express": "^4.1.3", "@types/web-push": "^3.3.2", "@types/xml2js": "^0.4.9", "@types/yamljs": "^0.2.31", "@types/yup": "^0.29.13", - "@typescript-eslint/eslint-plugin": "^4.31.1", - "@typescript-eslint/parser": "^4.31.1", - "autoprefixer": "^10.3.4", + "@typescript-eslint/eslint-plugin": "^5.10.0", + "@typescript-eslint/parser": "^5.10.0", + "autoprefixer": "^10.4.2", "babel-plugin-react-intl": "^8.2.25", "babel-plugin-react-intl-auto": "^3.3.0", "commitizen": "^4.2.4", "copyfiles": "^2.4.1", "cz-conventional-changelog": "^3.3.0", - "eslint": "^7.32.0", - "eslint-config-next": "^11.1.2", + "eslint": "^8.7.0", + "eslint-config-next": "^12.0.8", "eslint-config-prettier": "^8.3.0", - "eslint-plugin-formatjs": "^2.17.6", - "eslint-plugin-jsx-a11y": "^6.4.1", + "eslint-plugin-formatjs": "^2.20.3", + "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-prettier": "^4.0.0", - "eslint-plugin-react": "^7.25.3", - "eslint-plugin-react-hooks": "^4.2.0", + "eslint-plugin-react": "^7.28.0", + "eslint-plugin-react-hooks": "^4.3.0", "extract-react-intl-messages": "^4.1.1", - "husky": "4.3.8", - "lint-staged": "^11.1.2", - "nodemon": "^2.0.12", - "postcss": "^8.3.6", - "prettier": "^2.4.1", - "semantic-release": "^18.0.0", + "husky": "^7.0.4", + "lint-staged": "^12.2.1", + "nodemon": "^2.0.15", + "postcss": "^8.4.5", + "prettier": "^2.5.1", + "semantic-release": "^19.0.2", "semantic-release-docker-buildx": "^1.0.1", - "tailwindcss": "^2.2.15", - "ts-node": "^10.2.1", - "typescript": "^4.4.3" + "tailwindcss": "^3.0.15", + "ts-node": "^10.4.0", + "typescript": "^4.5.4" }, "resolutions": { - "sqlite3/node-gyp": "^5.1.0" + "sqlite3/node-gyp": "^8.4.1" }, "config": { "commitizen": { "path": "./node_modules/cz-conventional-changelog" } }, - "husky": { - "hooks": { - "pre-commit": "lint-staged", - "prepare-commit-msg": "exec < /dev/tty && git cz --hook || true", - "commit-msg": "[[ -n $HUSKY_BYPASS ]] || commitlint -E HUSKY_GIT_PARAMS" - } - }, "lint-staged": { "**/*.{ts,tsx,js}": [ "prettier --write", diff --git a/server/tsconfig.json b/server/tsconfig.json index eb403703..d245100d 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -1,8 +1,7 @@ { "extends": "../tsconfig.json", "compilerOptions": { - "target": "ES2019", - "lib": ["ES2019"], + "target": "ES2020", "module": "commonjs", "outDir": "../dist", "noEmit": false diff --git a/src/components/CollectionDetails/index.tsx b/src/components/CollectionDetails/index.tsx index e2952623..839f019a 100644 --- a/src/components/CollectionDetails/index.tsx +++ b/src/components/CollectionDetails/index.tsx @@ -41,13 +41,14 @@ const CollectionDetails: React.FC = ({ const [requestModal, setRequestModal] = useState(false); const [is4k, setIs4k] = useState(false); - const { data, error, revalidate } = useSWR( - `/api/v1/collection/${router.query.collectionId}`, - { - initialData: collection, - revalidateOnMount: true, - } - ); + const { + data, + error, + mutate: revalidate, + } = useSWR(`/api/v1/collection/${router.query.collectionId}`, { + fallbackData: collection, + revalidateOnMount: true, + }); const { data: genres } = useSWR<{ id: number; name: string }[]>(`/api/v1/genres/movie`); diff --git a/src/components/IssueDetails/index.tsx b/src/components/IssueDetails/index.tsx index 73728c80..443a8a5f 100644 --- a/src/components/IssueDetails/index.tsx +++ b/src/components/IssueDetails/index.tsx @@ -80,7 +80,7 @@ const IssueDetails: React.FC = () => { const intl = useIntl(); const [showDeleteModal, setShowDeleteModal] = useState(false); const { user: currentUser, hasPermission } = useUser(); - const { data: issueData, revalidate: revalidateIssue } = useSWR( + const { data: issueData, mutate: revalidateIssue } = useSWR( `/api/v1/issue/${router.query.issueId}` ); const { data, error } = useSWR( diff --git a/src/components/MediaSlider/index.tsx b/src/components/MediaSlider/index.tsx index 0e3a4fea..84c72822 100644 --- a/src/components/MediaSlider/index.tsx +++ b/src/components/MediaSlider/index.tsx @@ -1,7 +1,7 @@ import { ArrowCircleRightIcon } from '@heroicons/react/outline'; import Link from 'next/link'; import React, { useEffect } from 'react'; -import { useSWRInfinite } from 'swr'; +import useSWRInfinite from 'swr/infinite'; import { MediaStatus } from '../../../server/constants/media'; import type { MovieResult, diff --git a/src/components/MovieDetails/index.tsx b/src/components/MovieDetails/index.tsx index 44398169..46a6862d 100644 --- a/src/components/MovieDetails/index.tsx +++ b/src/components/MovieDetails/index.tsx @@ -90,12 +90,13 @@ const MovieDetails: React.FC = ({ movie }) => { const [showMoreStudios, setShowMoreStudios] = useState(false); const [showIssueModal, setShowIssueModal] = useState(false); - const { data, error, revalidate } = useSWR( - `/api/v1/movie/${router.query.movieId}`, - { - initialData: movie, - } - ); + const { + data, + error, + mutate: revalidate, + } = useSWR(`/api/v1/movie/${router.query.movieId}`, { + fallbackData: movie, + }); const { data: ratingData } = useSWR( `/api/v1/movie/${router.query.movieId}/ratings` diff --git a/src/components/RequestCard/index.tsx b/src/components/RequestCard/index.tsx index 98f41520..f2a86666 100644 --- a/src/components/RequestCard/index.tsx +++ b/src/components/RequestCard/index.tsx @@ -112,9 +112,9 @@ const RequestCard: React.FC = ({ request, onTitleData }) => { const { data: requestData, error: requestError, - revalidate, + mutate: revalidate, } = useSWR(`/api/v1/request/${request.id}`, { - initialData: request, + fallbackData: request, }); const modifyRequest = async (type: 'approve' | 'decline') => { diff --git a/src/components/RequestList/RequestItem/index.tsx b/src/components/RequestList/RequestItem/index.tsx index 35b07a8a..f3d9fb00 100644 --- a/src/components/RequestList/RequestItem/index.tsx +++ b/src/components/RequestList/RequestItem/index.tsx @@ -106,13 +106,12 @@ const RequestItem: React.FC = ({ const { data: title, error } = useSWR( inView ? url : null ); - const { - data: requestData, - revalidate, - mutate, - } = useSWR(`/api/v1/request/${request.id}`, { - initialData: request, - }); + const { data: requestData, mutate: revalidate } = useSWR( + `/api/v1/request/${request.id}`, + { + fallbackData: request, + } + ); const [isRetrying, setRetrying] = useState(false); @@ -135,7 +134,7 @@ const RequestItem: React.FC = ({ try { const result = await axios.post(`/api/v1/request/${request.id}/retry`); - mutate(result.data); + revalidate(result.data); } catch (e) { addToast(intl.formatMessage(messages.failedretry), { autoDismiss: true, diff --git a/src/components/RequestList/index.tsx b/src/components/RequestList/index.tsx index 7c1aa154..e192cb34 100644 --- a/src/components/RequestList/index.tsx +++ b/src/components/RequestList/index.tsx @@ -51,7 +51,11 @@ const RequestList: React.FC = () => { const pageIndex = page - 1; const updateQueryParams = useUpdateQueryParams({ page: page.toString() }); - const { data, error, revalidate } = useSWR( + const { + data, + error, + mutate: revalidate, + } = useSWR( `/api/v1/request?take=${currentPageSize}&skip=${ pageIndex * currentPageSize }&filter=${currentFilter}&sort=${currentSort}${ diff --git a/src/components/Settings/Notifications/NotificationsDiscord.tsx b/src/components/Settings/Notifications/NotificationsDiscord.tsx index 8c882dd6..1c4bbbc4 100644 --- a/src/components/Settings/Notifications/NotificationsDiscord.tsx +++ b/src/components/Settings/Notifications/NotificationsDiscord.tsx @@ -34,9 +34,11 @@ const NotificationsDiscord: React.FC = () => { const settings = useSettings(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/discord' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/discord'); const NotificationsDiscordSchema = Yup.object().shape({ botAvatarUrl: Yup.string() diff --git a/src/components/Settings/Notifications/NotificationsEmail.tsx b/src/components/Settings/Notifications/NotificationsEmail.tsx index ad501c69..93f22565 100644 --- a/src/components/Settings/Notifications/NotificationsEmail.tsx +++ b/src/components/Settings/Notifications/NotificationsEmail.tsx @@ -58,9 +58,11 @@ const NotificationsEmail: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/email' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/email'); const NotificationsEmailSchema = Yup.object().shape( { diff --git a/src/components/Settings/Notifications/NotificationsGotify/index.tsx b/src/components/Settings/Notifications/NotificationsGotify/index.tsx index 214cf973..5e4c895c 100644 --- a/src/components/Settings/Notifications/NotificationsGotify/index.tsx +++ b/src/components/Settings/Notifications/NotificationsGotify/index.tsx @@ -30,9 +30,11 @@ const NotificationsGotify: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/gotify' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/gotify'); const NotificationsGotifySchema = Yup.object().shape({ url: Yup.string() diff --git a/src/components/Settings/Notifications/NotificationsLunaSea/index.tsx b/src/components/Settings/Notifications/NotificationsLunaSea/index.tsx index 0c1a0b6e..28e67b07 100644 --- a/src/components/Settings/Notifications/NotificationsLunaSea/index.tsx +++ b/src/components/Settings/Notifications/NotificationsLunaSea/index.tsx @@ -31,9 +31,11 @@ const NotificationsLunaSea: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/lunasea' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/lunasea'); const NotificationsLunaSeaSchema = Yup.object().shape({ webhookUrl: Yup.string() diff --git a/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx b/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx index 32e37911..8ad30dc3 100644 --- a/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx +++ b/src/components/Settings/Notifications/NotificationsPushbullet/index.tsx @@ -31,9 +31,11 @@ const NotificationsPushbullet: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/pushbullet' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/pushbullet'); const NotificationsPushbulletSchema = Yup.object().shape({ accessToken: Yup.string().when('enabled', { diff --git a/src/components/Settings/Notifications/NotificationsPushover/index.tsx b/src/components/Settings/Notifications/NotificationsPushover/index.tsx index 4ba2757f..87eef22b 100644 --- a/src/components/Settings/Notifications/NotificationsPushover/index.tsx +++ b/src/components/Settings/Notifications/NotificationsPushover/index.tsx @@ -33,9 +33,11 @@ const NotificationsPushover: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/pushover' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/pushover'); const NotificationsPushoverSchema = Yup.object().shape({ accessToken: Yup.string() diff --git a/src/components/Settings/Notifications/NotificationsSlack/index.tsx b/src/components/Settings/Notifications/NotificationsSlack/index.tsx index 7bddf630..13a8b301 100644 --- a/src/components/Settings/Notifications/NotificationsSlack/index.tsx +++ b/src/components/Settings/Notifications/NotificationsSlack/index.tsx @@ -29,9 +29,11 @@ const NotificationsSlack: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/slack' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/slack'); const NotificationsSlackSchema = Yup.object().shape({ webhookUrl: Yup.string() diff --git a/src/components/Settings/Notifications/NotificationsTelegram.tsx b/src/components/Settings/Notifications/NotificationsTelegram.tsx index d76fdde3..f43e74f1 100644 --- a/src/components/Settings/Notifications/NotificationsTelegram.tsx +++ b/src/components/Settings/Notifications/NotificationsTelegram.tsx @@ -38,9 +38,11 @@ const NotificationsTelegram: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/telegram' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/telegram'); const NotificationsTelegramSchema = Yup.object().shape({ botAPI: Yup.string().when('enabled', { diff --git a/src/components/Settings/Notifications/NotificationsWebPush/index.tsx b/src/components/Settings/Notifications/NotificationsWebPush/index.tsx index 56aef39f..38587be7 100644 --- a/src/components/Settings/Notifications/NotificationsWebPush/index.tsx +++ b/src/components/Settings/Notifications/NotificationsWebPush/index.tsx @@ -26,9 +26,11 @@ const NotificationsWebPush: React.FC = () => { const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); const [isHttps, setIsHttps] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/webpush' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/webpush'); useEffect(() => { setIsHttps(window.location.protocol.startsWith('https')); diff --git a/src/components/Settings/Notifications/NotificationsWebhook/index.tsx b/src/components/Settings/Notifications/NotificationsWebhook/index.tsx index e36e4464..f8689599 100644 --- a/src/components/Settings/Notifications/NotificationsWebhook/index.tsx +++ b/src/components/Settings/Notifications/NotificationsWebhook/index.tsx @@ -74,9 +74,11 @@ const NotificationsWebhook: React.FC = () => { const intl = useIntl(); const { addToast, removeToast } = useToasts(); const [isTesting, setIsTesting] = useState(false); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/notifications/webhook' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/notifications/webhook'); const NotificationsWebhookSchema = Yup.object().shape({ webhookUrl: Yup.string() diff --git a/src/components/Settings/SettingsJobsCache/index.tsx b/src/components/Settings/SettingsJobsCache/index.tsx index c0e50e02..e9d23495 100644 --- a/src/components/Settings/SettingsJobsCache/index.tsx +++ b/src/components/Settings/SettingsJobsCache/index.tsx @@ -77,10 +77,14 @@ interface Job { const SettingsJobs: React.FC = () => { const intl = useIntl(); const { addToast } = useToasts(); - const { data, error, revalidate } = useSWR('/api/v1/settings/jobs', { + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/jobs', { refreshInterval: 5000, }); - const { data: cacheData, revalidate: cacheRevalidate } = useSWR( + const { data: cacheData, mutate: cacheRevalidate } = useSWR( '/api/v1/settings/cache', { refreshInterval: 10000, diff --git a/src/components/Settings/SettingsMain.tsx b/src/components/Settings/SettingsMain.tsx index a55ecb75..bb00f3de 100644 --- a/src/components/Settings/SettingsMain.tsx +++ b/src/components/Settings/SettingsMain.tsx @@ -65,9 +65,11 @@ const SettingsMain: React.FC = () => { const { user: currentUser, hasPermission: userHasPermission } = useUser(); const intl = useIntl(); const { setLocale } = useLocale(); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/main' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/main'); const { data: userData } = useSWR( currentUser ? `/api/v1/user/${currentUser.id}/settings/main` : null ); diff --git a/src/components/Settings/SettingsPlex.tsx b/src/components/Settings/SettingsPlex.tsx index 1c77c303..42172f81 100644 --- a/src/components/Settings/SettingsPlex.tsx +++ b/src/components/Settings/SettingsPlex.tsx @@ -96,10 +96,12 @@ const SettingsPlex: React.FC = ({ onComplete }) => { const [availableServers, setAvailableServers] = useState( null ); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/plex' - ); - const { data: dataSync, revalidate: revalidateSync } = useSWR( + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/plex'); + const { data: dataSync, mutate: revalidateSync } = useSWR( '/api/v1/settings/plex/sync', { refreshInterval: 1000, diff --git a/src/components/Settings/SettingsServices.tsx b/src/components/Settings/SettingsServices.tsx index 1ffbd4cf..f98f88f3 100644 --- a/src/components/Settings/SettingsServices.tsx +++ b/src/components/Settings/SettingsServices.tsx @@ -165,12 +165,12 @@ const SettingsServices: React.FC = () => { const { data: radarrData, error: radarrError, - revalidate: revalidateRadarr, + mutate: revalidateRadarr, } = useSWR('/api/v1/settings/radarr'); const { data: sonarrData, error: sonarrError, - revalidate: revalidateSonarr, + mutate: revalidateSonarr, } = useSWR('/api/v1/settings/sonarr'); const [editRadarrModal, setEditRadarrModal] = useState<{ open: boolean; diff --git a/src/components/Settings/SettingsUsers/index.tsx b/src/components/Settings/SettingsUsers/index.tsx index 327e40fc..4204ebe6 100644 --- a/src/components/Settings/SettingsUsers/index.tsx +++ b/src/components/Settings/SettingsUsers/index.tsx @@ -33,9 +33,11 @@ const messages = defineMessages({ const SettingsUsers: React.FC = () => { const { addToast } = useToasts(); const intl = useIntl(); - const { data, error, revalidate } = useSWR( - '/api/v1/settings/main' - ); + const { + data, + error, + mutate: revalidate, + } = useSWR('/api/v1/settings/main'); if (!data && !error) { return ; diff --git a/src/components/TvDetails/index.tsx b/src/components/TvDetails/index.tsx index 4de23164..99f4345b 100644 --- a/src/components/TvDetails/index.tsx +++ b/src/components/TvDetails/index.tsx @@ -83,12 +83,13 @@ const TvDetails: React.FC = ({ tv }) => { const [showManager, setShowManager] = useState(false); const [showIssueModal, setShowIssueModal] = useState(false); - const { data, error, revalidate } = useSWR( - `/api/v1/tv/${router.query.tvId}`, - { - initialData: tv, - } - ); + const { + data, + error, + mutate: revalidate, + } = useSWR(`/api/v1/tv/${router.query.tvId}`, { + fallbackData: tv, + }); const { data: ratingData } = useSWR( `/api/v1/tv/${router.query.tvId}/ratings` diff --git a/src/components/UserList/index.tsx b/src/components/UserList/index.tsx index fdf7b4b0..1a0e06c4 100644 --- a/src/components/UserList/index.tsx +++ b/src/components/UserList/index.tsx @@ -93,7 +93,11 @@ const UserList: React.FC = () => { const pageIndex = page - 1; const updateQueryParams = useUpdateQueryParams({ page: page.toString() }); - const { data, error, revalidate } = useSWR( + const { + data, + error, + mutate: revalidate, + } = useSWR( `/api/v1/user?take=${currentPageSize}&skip=${ pageIndex * currentPageSize }&sort=${currentSort}` @@ -472,7 +476,7 @@ const UserList: React.FC = () => {