From 6e68ba3cbdf3d7e9e7fd70cd3467df2a4d23821d Mon Sep 17 00:00:00 2001 From: Rauno Tegelmann Date: Tue, 8 Oct 2024 19:52:28 +0300 Subject: [PATCH 1/4] feat(config): add option to anonymize other users --- src/app/dashboard/users/page.tsx | 7 ++- .../general/_actions/updateGeneralSettings.ts | 2 + .../_components/GeneralSettingsForm.tsx | 11 ++++ src/components/MediaItem/MediaItem.tsx | 6 +- src/types/settings.d.ts | 1 + src/utils/constants.ts | 1 + src/utils/helpers.ts | 57 ++++++++++++++++++- 7 files changed, 81 insertions(+), 4 deletions(-) diff --git a/src/app/dashboard/users/page.tsx b/src/app/dashboard/users/page.tsx index 7973a767..f7af27aa 100644 --- a/src/app/dashboard/users/page.tsx +++ b/src/app/dashboard/users/page.tsx @@ -10,6 +10,7 @@ import fetchTautulli, { getLibrariesByType } from '@/utils/fetchTautulli' import { secondsToTime, timeToSeconds } from '@/utils/formatting' import getPeriod from '@/utils/getPeriod' import getSettings from '@/utils/getSettings' +import { anonymizeUsers } from '@/utils/helpers' import { Metadata } from 'next' import { getServerSession } from 'next-auth' import { notFound } from 'next/navigation' @@ -51,7 +52,7 @@ async function getUsers( const allUsersCount = await getUsersCount(settings) if (!allUsersCount) { - console.error('[TAUTULLI] - Could not determine the number of users.') + console.error('Could not determine the number of users!') return } @@ -165,6 +166,10 @@ async function getUsers( user.audio_plays_count = usersPlaysAndDurations[i].audio_plays_count }) + if (settings.general.isAnonymized) { + return anonymizeUsers(listedUsers, loggedInUserId) + } + return listedUsers } diff --git a/src/app/settings/general/_actions/updateGeneralSettings.ts b/src/app/settings/general/_actions/updateGeneralSettings.ts index ebb44115..e4896f95 100644 --- a/src/app/settings/general/_actions/updateGeneralSettings.ts +++ b/src/app/settings/general/_actions/updateGeneralSettings.ts @@ -9,6 +9,7 @@ const schema = z.object({ isPostersTmdbOnly: z.boolean(), googleAnalyticsId: z.string(), isOutsideAccess: z.boolean(), + isAnonymized: z.boolean(), complete: z.boolean(), }) @@ -21,6 +22,7 @@ export default async function saveGeneralSettings( isPostersTmdbOnly: formData.get('isPostersTmdbOnly') === 'on', googleAnalyticsId: formData.get('googleAnalyticsId') as string, isOutsideAccess: formData.get('isOutsideAccess') === 'on', + isAnonymized: formData.get('isAnonymized') === 'on', complete: true, } diff --git a/src/app/settings/general/_components/GeneralSettingsForm.tsx b/src/app/settings/general/_components/GeneralSettingsForm.tsx index bda91bb5..b3a3b570 100644 --- a/src/app/settings/general/_components/GeneralSettingsForm.tsx +++ b/src/app/settings/general/_components/GeneralSettingsForm.tsx @@ -120,6 +120,17 @@ export default function GeneralSettingsForm({ settings, libraries }: Props) { Access without login. + +
+ + Anonymize + Hide usernames for other users. + +

Analytics

diff --git a/src/components/MediaItem/MediaItem.tsx b/src/components/MediaItem/MediaItem.tsx index 43f041a5..eb0a89db 100644 --- a/src/components/MediaItem/MediaItem.tsx +++ b/src/components/MediaItem/MediaItem.tsx @@ -89,7 +89,11 @@ export default function MediaItem({ {isUserDashboard setImageSrc(placeholderSvg)} diff --git a/src/types/settings.d.ts b/src/types/settings.d.ts index cc341cb9..dfd19ca1 100644 --- a/src/types/settings.d.ts +++ b/src/types/settings.d.ts @@ -18,6 +18,7 @@ export type GeneralSettings = { isPostersTmdbOnly: boolean googleAnalyticsId: string isOutsideAccess: boolean + isAnonymized: boolean complete: boolean } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index 27e11011..2f3d7ff3 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -51,6 +51,7 @@ export const DEFAULT_SETTINGS: Settings = { isPostersTmdbOnly: false, googleAnalyticsId: '', isOutsideAccess: false, + isAnonymized: false, complete: false, }, rewind: { diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 3db3f533..702c225e 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,7 +1,8 @@ import { Settings } from '@/types/settings' +import { TautulliItemRow } from '@/types/tautulli' import { PERIODS, SETTINGS_PAGES } from './constants' -const requiredSettings = [ +const REQUIRED_SETTINGS = [ 'connection.tautulliUrl', 'connection.tautulliApiKey', 'connection.plexUrl', @@ -12,9 +13,41 @@ const requiredSettings = [ 'dashboard.startDate', 'dashboard.complete', ] +const ANONYMIZED_USERS = [ + 'Swift Falcon', + 'Wise Owl', + 'Sly Fox', + 'Brave Wolf', + 'Silent Lynx', + 'Mighty Panther', + 'Cunning Coyote', + 'Gentle Deer', + 'Quick Hare', + 'Stealthy Tiger', + 'Fierce Lion', + 'Nimble Squirrel', + 'Proud Eagle', + 'Calm Dolphin', + 'Playful Otter', + 'Bold Hawk', + 'Shy Tortoise', + 'Loyal Dog', + 'Curious Cat', + 'Elegant Swan', + 'Strong Bear', + 'Graceful Gazelle', + 'Fearless Shark', + 'Sneaky Raccoon', + 'Vigilant Falcon', + 'Cheerful Penguin', + 'Wild Stallion', + 'Clever Raven', + 'Majestic Whale', + 'Swift Antelope', +] export function checkRequiredSettings(settings: Settings): string | null { - for (const key of requiredSettings) { + for (const key of REQUIRED_SETTINGS) { const keys = key.split('.') // @ts-expect-error - TODO: we know this is safe, but should still look to resolve without exception const settingValue = keys.reduce((acc, curr) => acc && acc[curr], settings) @@ -39,3 +72,23 @@ export function getRewindDateRange(settings: Settings) { return { startDate, endDate } } + +export function anonymizeUsers( + users: TautulliItemRow[], + loggedInUserId: string, +) { + return users.map((user) => { + const isLoggedIn = user.user_id === Number(loggedInUserId) + const anonName = isLoggedIn + ? user.friendly_name + : ANONYMIZED_USERS[Math.floor(Math.random() * ANONYMIZED_USERS.length)] + + return { + ...user, + user: anonName, + friendly_name: anonName, + user_thumb: isLoggedIn ? user.user_thumb : '', + user_id: isLoggedIn ? user.user_id : 0, + } + }) +} From 728948f5211311476c4642f8b99ef0fea9b555e1 Mon Sep 17 00:00:00 2001 From: Rauno Tegelmann Date: Wed, 9 Oct 2024 08:44:29 +0300 Subject: [PATCH 2/4] fix: improve anon name handling --- src/utils/helpers.ts | 48 ++++++++++---------------------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 702c225e..23dfae92 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -13,37 +13,13 @@ const REQUIRED_SETTINGS = [ 'dashboard.startDate', 'dashboard.complete', ] -const ANONYMIZED_USERS = [ - 'Swift Falcon', - 'Wise Owl', - 'Sly Fox', - 'Brave Wolf', - 'Silent Lynx', - 'Mighty Panther', - 'Cunning Coyote', - 'Gentle Deer', - 'Quick Hare', - 'Stealthy Tiger', - 'Fierce Lion', - 'Nimble Squirrel', - 'Proud Eagle', - 'Calm Dolphin', - 'Playful Otter', - 'Bold Hawk', - 'Shy Tortoise', - 'Loyal Dog', - 'Curious Cat', - 'Elegant Swan', - 'Strong Bear', - 'Graceful Gazelle', - 'Fearless Shark', - 'Sneaky Raccoon', - 'Vigilant Falcon', - 'Cheerful Penguin', - 'Wild Stallion', - 'Clever Raven', - 'Majestic Whale', - 'Swift Antelope', +const ANONYMIZED_BIRDS = [ + 'Ferocious Falcon', + 'Observant Owl', + 'Resourceful Raven', + 'Serene Swan', + 'Playful Parrot', + 'Mischievous Magpie', ] export function checkRequiredSettings(settings: Settings): string | null { @@ -77,16 +53,14 @@ export function anonymizeUsers( users: TautulliItemRow[], loggedInUserId: string, ) { - return users.map((user) => { + return users.map((user, i) => { const isLoggedIn = user.user_id === Number(loggedInUserId) - const anonName = isLoggedIn - ? user.friendly_name - : ANONYMIZED_USERS[Math.floor(Math.random() * ANONYMIZED_USERS.length)] + const anonName = ANONYMIZED_BIRDS[i] return { ...user, - user: anonName, - friendly_name: anonName, + user: isLoggedIn ? user.user : anonName, + friendly_name: isLoggedIn ? user.friendly_name : anonName, user_thumb: isLoggedIn ? user.user_thumb : '', user_id: isLoggedIn ? user.user_id : 0, } From 2a8cd3d8ffcd72f8a1c0b67b4329faeba174eb99 Mon Sep 17 00:00:00 2001 From: Rauno Tegelmann Date: Wed, 9 Oct 2024 11:20:13 +0300 Subject: [PATCH 3/4] feat: add profile images for anon users --- src/assets/profiles/bat.svg | 91 +++++++++ src/assets/profiles/butterfly.svg | 68 +++++++ src/assets/profiles/cat.svg | 175 +++++++++++++++++ src/assets/profiles/duck.svg | 48 +++++ src/assets/profiles/giraffe.svg | 143 ++++++++++++++ src/assets/profiles/hippo.svg | 182 ++++++++++++++++++ src/assets/profiles/kangaroo.svg | 67 +++++++ src/assets/profiles/lion.svg | 83 ++++++++ src/assets/profiles/monkey.svg | 115 ++++++++++++ src/assets/profiles/moose.svg | 76 ++++++++ src/assets/profiles/octopus.svg | 115 ++++++++++++ src/assets/profiles/ostrich.svg | 56 ++++++ src/assets/profiles/rabbit.svg | 78 ++++++++ src/assets/profiles/racoon.svg | 139 ++++++++++++++ src/assets/profiles/shark.svg | 65 +++++++ src/assets/profiles/snake.svg | 143 ++++++++++++++ src/assets/profiles/tiger.svg | 250 +++++++++++++++++++++++++ src/assets/profiles/turtle.svg | 116 ++++++++++++ src/components/MediaItem/MediaItem.tsx | 22 ++- src/utils/constants.ts | 21 +++ src/utils/helpers.ts | 94 ++++++++-- 21 files changed, 2126 insertions(+), 21 deletions(-) create mode 100644 src/assets/profiles/bat.svg create mode 100644 src/assets/profiles/butterfly.svg create mode 100644 src/assets/profiles/cat.svg create mode 100644 src/assets/profiles/duck.svg create mode 100644 src/assets/profiles/giraffe.svg create mode 100644 src/assets/profiles/hippo.svg create mode 100644 src/assets/profiles/kangaroo.svg create mode 100644 src/assets/profiles/lion.svg create mode 100644 src/assets/profiles/monkey.svg create mode 100644 src/assets/profiles/moose.svg create mode 100644 src/assets/profiles/octopus.svg create mode 100644 src/assets/profiles/ostrich.svg create mode 100644 src/assets/profiles/rabbit.svg create mode 100644 src/assets/profiles/racoon.svg create mode 100644 src/assets/profiles/shark.svg create mode 100644 src/assets/profiles/snake.svg create mode 100644 src/assets/profiles/tiger.svg create mode 100644 src/assets/profiles/turtle.svg diff --git a/src/assets/profiles/bat.svg b/src/assets/profiles/bat.svg new file mode 100644 index 00000000..9c33f358 --- /dev/null +++ b/src/assets/profiles/bat.svg @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/butterfly.svg b/src/assets/profiles/butterfly.svg new file mode 100644 index 00000000..c1829c21 --- /dev/null +++ b/src/assets/profiles/butterfly.svg @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/cat.svg b/src/assets/profiles/cat.svg new file mode 100644 index 00000000..72ba109f --- /dev/null +++ b/src/assets/profiles/cat.svg @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/duck.svg b/src/assets/profiles/duck.svg new file mode 100644 index 00000000..1d26b177 --- /dev/null +++ b/src/assets/profiles/duck.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/src/assets/profiles/giraffe.svg b/src/assets/profiles/giraffe.svg new file mode 100644 index 00000000..92b00a8c --- /dev/null +++ b/src/assets/profiles/giraffe.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/hippo.svg b/src/assets/profiles/hippo.svg new file mode 100644 index 00000000..8eac83d8 --- /dev/null +++ b/src/assets/profiles/hippo.svg @@ -0,0 +1,182 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/kangaroo.svg b/src/assets/profiles/kangaroo.svg new file mode 100644 index 00000000..13e864ac --- /dev/null +++ b/src/assets/profiles/kangaroo.svg @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/lion.svg b/src/assets/profiles/lion.svg new file mode 100644 index 00000000..9c4f1830 --- /dev/null +++ b/src/assets/profiles/lion.svg @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/monkey.svg b/src/assets/profiles/monkey.svg new file mode 100644 index 00000000..7fe32c5a --- /dev/null +++ b/src/assets/profiles/monkey.svg @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/moose.svg b/src/assets/profiles/moose.svg new file mode 100644 index 00000000..5f242855 --- /dev/null +++ b/src/assets/profiles/moose.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/octopus.svg b/src/assets/profiles/octopus.svg new file mode 100644 index 00000000..19b17937 --- /dev/null +++ b/src/assets/profiles/octopus.svg @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/ostrich.svg b/src/assets/profiles/ostrich.svg new file mode 100644 index 00000000..7b216660 --- /dev/null +++ b/src/assets/profiles/ostrich.svg @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + diff --git a/src/assets/profiles/rabbit.svg b/src/assets/profiles/rabbit.svg new file mode 100644 index 00000000..f8878c39 --- /dev/null +++ b/src/assets/profiles/rabbit.svg @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/racoon.svg b/src/assets/profiles/racoon.svg new file mode 100644 index 00000000..59c54baf --- /dev/null +++ b/src/assets/profiles/racoon.svg @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/shark.svg b/src/assets/profiles/shark.svg new file mode 100644 index 00000000..24e4e28b --- /dev/null +++ b/src/assets/profiles/shark.svg @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/snake.svg b/src/assets/profiles/snake.svg new file mode 100644 index 00000000..61bbc8bf --- /dev/null +++ b/src/assets/profiles/snake.svg @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/tiger.svg b/src/assets/profiles/tiger.svg new file mode 100644 index 00000000..171ea9d2 --- /dev/null +++ b/src/assets/profiles/tiger.svg @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/profiles/turtle.svg b/src/assets/profiles/turtle.svg new file mode 100644 index 00000000..a02a16f2 --- /dev/null +++ b/src/assets/profiles/turtle.svg @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/MediaItem/MediaItem.tsx b/src/components/MediaItem/MediaItem.tsx index eb0a89db..52be3a22 100644 --- a/src/components/MediaItem/MediaItem.tsx +++ b/src/components/MediaItem/MediaItem.tsx @@ -2,7 +2,9 @@ import { Settings } from '@/types/settings' import { TautulliItemRow } from '@/types/tautulli' +import { ANONYMIZED_ANIMALS } from '@/utils/constants' import { pluralize, secondsToTime } from '@/utils/formatting' +import { getAnimalIcon } from '@/utils/helpers' import { slideDown } from '@/utils/motion' import { CalendarDaysIcon, @@ -19,8 +21,8 @@ import { motion } from 'framer-motion' import Image from 'next/image' import { useEffect, useRef, useState } from 'react' import MediaItemTitle from './MediaItemTitle' -import PlexDeeplink from './PlexDeeplink' import placeholderSvg from './placeholder.svg' +import PlexDeeplink from './PlexDeeplink' type Props = { data: TautulliItemRow @@ -53,16 +55,19 @@ export default function MediaItem({ isUserDashboard ? data.user_thumb : data.thumb }&width=300`, )}` + const isAnonymized = ANONYMIZED_ANIMALS.includes(data.user_thumb) + const initialImageSrc = + isUserDashboard && isAnonymized ? getAnimalIcon(data.user_thumb) : posterSrc + const [imageSrc, setImageSrc] = useState(initialImageSrc) const [dataKey, setDataKey] = useState(0) const titleContainerRef = useRef(null) const isOverseerrActive = settings.connection.overseerrUrl && settings.connection.overseerrApiKey - const [imageSrc, setImageSrc] = useState(posterSrc) useEffect(() => { setDataKey((prevDataKey) => prevDataKey + 1) - setImageSrc(posterSrc) - }, [data, type, posterSrc]) + setImageSrc(initialImageSrc) + }, [data, type, initialImageSrc]) return ( -
+
{ { +): TautulliItemRow[] { + const usedNames = new Set() + + return users.map((user) => { const isLoggedIn = user.user_id === Number(loggedInUserId) - const anonName = ANONYMIZED_BIRDS[i] + + let anonName + + do { + anonName = + ANONYMIZED_ANIMALS[ + Math.floor(Math.random() * ANONYMIZED_ANIMALS.length) + ] + } while (usedNames.has(anonName)) + + usedNames.add(anonName) return { ...user, - user: isLoggedIn ? user.user : anonName, - friendly_name: isLoggedIn ? user.friendly_name : anonName, - user_thumb: isLoggedIn ? user.user_thumb : '', + user: isLoggedIn ? user.user : 'Anonymous ' + anonName, + friendly_name: isLoggedIn ? user.friendly_name : 'Anonymous ' + anonName, + user_thumb: isLoggedIn ? user.user_thumb : anonName, user_id: isLoggedIn ? user.user_id : 0, } }) } + +export function getAnimalIcon(animal: string) { + switch (animal) { + case 'Bat': + return batSvg + case 'Butterfly': + return butterflySvg + case 'Cat': + return catSvg + case 'Duck': + return duckSvg + case 'Giraffe': + return giraffeSvg + case 'Hippo': + return hippoSvg + case 'Kangaroo': + return kangarooSvg + case 'Lion': + return lionSvg + case 'Monkey': + return monkeySvg + case 'Moose': + return mooseSvg + case 'Octopus': + return octopusSvg + case 'Ostrich': + return ostrichSvg + case 'Rabbit': + return rabbitSvg + case 'Racoon': + return racoonSvg + case 'Shark': + return sharkSvg + case 'Snake': + return snakeSvg + case 'Tiger': + return tigerSvg + case 'Turtle': + return turtleSvg + } +} From 5f4429d7dc94486aa127a59df5697ccff129ae51 Mon Sep 17 00:00:00 2001 From: Rauno Tegelmann Date: Wed, 9 Oct 2024 11:40:00 +0300 Subject: [PATCH 4/4] feat: simplify anon logic --- src/assets/profiles/bat.svg | 91 --------- src/assets/profiles/butterfly.svg | 68 ------- src/assets/profiles/cat.svg | 175 ----------------- src/assets/profiles/duck.svg | 48 ----- src/assets/profiles/giraffe.svg | 143 -------------- src/assets/profiles/hippo.svg | 182 ------------------ src/assets/profiles/kangaroo.svg | 67 ------- src/assets/profiles/lion.svg | 83 -------- src/assets/profiles/monkey.svg | 115 ------------ src/assets/profiles/moose.svg | 76 -------- src/assets/profiles/octopus.svg | 115 ------------ src/assets/profiles/ostrich.svg | 56 ------ src/assets/profiles/rabbit.svg | 78 -------- src/assets/profiles/racoon.svg | 139 -------------- src/assets/profiles/shark.svg | 65 ------- src/assets/profiles/snake.svg | 143 -------------- src/assets/profiles/tiger.svg | 250 ------------------------- src/assets/profiles/turtle.svg | 116 ------------ src/components/MediaItem/MediaItem.tsx | 16 +- src/components/MediaItem/anonymous.svg | 8 + src/utils/constants.ts | 21 --- src/utils/helpers.ts | 81 +------- 22 files changed, 17 insertions(+), 2119 deletions(-) delete mode 100644 src/assets/profiles/bat.svg delete mode 100644 src/assets/profiles/butterfly.svg delete mode 100644 src/assets/profiles/cat.svg delete mode 100644 src/assets/profiles/duck.svg delete mode 100644 src/assets/profiles/giraffe.svg delete mode 100644 src/assets/profiles/hippo.svg delete mode 100644 src/assets/profiles/kangaroo.svg delete mode 100644 src/assets/profiles/lion.svg delete mode 100644 src/assets/profiles/monkey.svg delete mode 100644 src/assets/profiles/moose.svg delete mode 100644 src/assets/profiles/octopus.svg delete mode 100644 src/assets/profiles/ostrich.svg delete mode 100644 src/assets/profiles/rabbit.svg delete mode 100644 src/assets/profiles/racoon.svg delete mode 100644 src/assets/profiles/shark.svg delete mode 100644 src/assets/profiles/snake.svg delete mode 100644 src/assets/profiles/tiger.svg delete mode 100644 src/assets/profiles/turtle.svg create mode 100644 src/components/MediaItem/anonymous.svg diff --git a/src/assets/profiles/bat.svg b/src/assets/profiles/bat.svg deleted file mode 100644 index 9c33f358..00000000 --- a/src/assets/profiles/bat.svg +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/butterfly.svg b/src/assets/profiles/butterfly.svg deleted file mode 100644 index c1829c21..00000000 --- a/src/assets/profiles/butterfly.svg +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/cat.svg b/src/assets/profiles/cat.svg deleted file mode 100644 index 72ba109f..00000000 --- a/src/assets/profiles/cat.svg +++ /dev/null @@ -1,175 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/duck.svg b/src/assets/profiles/duck.svg deleted file mode 100644 index 1d26b177..00000000 --- a/src/assets/profiles/duck.svg +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - diff --git a/src/assets/profiles/giraffe.svg b/src/assets/profiles/giraffe.svg deleted file mode 100644 index 92b00a8c..00000000 --- a/src/assets/profiles/giraffe.svg +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/hippo.svg b/src/assets/profiles/hippo.svg deleted file mode 100644 index 8eac83d8..00000000 --- a/src/assets/profiles/hippo.svg +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/kangaroo.svg b/src/assets/profiles/kangaroo.svg deleted file mode 100644 index 13e864ac..00000000 --- a/src/assets/profiles/kangaroo.svg +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/lion.svg b/src/assets/profiles/lion.svg deleted file mode 100644 index 9c4f1830..00000000 --- a/src/assets/profiles/lion.svg +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/monkey.svg b/src/assets/profiles/monkey.svg deleted file mode 100644 index 7fe32c5a..00000000 --- a/src/assets/profiles/monkey.svg +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/moose.svg b/src/assets/profiles/moose.svg deleted file mode 100644 index 5f242855..00000000 --- a/src/assets/profiles/moose.svg +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/octopus.svg b/src/assets/profiles/octopus.svg deleted file mode 100644 index 19b17937..00000000 --- a/src/assets/profiles/octopus.svg +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/ostrich.svg b/src/assets/profiles/ostrich.svg deleted file mode 100644 index 7b216660..00000000 --- a/src/assets/profiles/ostrich.svg +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/assets/profiles/rabbit.svg b/src/assets/profiles/rabbit.svg deleted file mode 100644 index f8878c39..00000000 --- a/src/assets/profiles/rabbit.svg +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/racoon.svg b/src/assets/profiles/racoon.svg deleted file mode 100644 index 59c54baf..00000000 --- a/src/assets/profiles/racoon.svg +++ /dev/null @@ -1,139 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/shark.svg b/src/assets/profiles/shark.svg deleted file mode 100644 index 24e4e28b..00000000 --- a/src/assets/profiles/shark.svg +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/snake.svg b/src/assets/profiles/snake.svg deleted file mode 100644 index 61bbc8bf..00000000 --- a/src/assets/profiles/snake.svg +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/tiger.svg b/src/assets/profiles/tiger.svg deleted file mode 100644 index 171ea9d2..00000000 --- a/src/assets/profiles/tiger.svg +++ /dev/null @@ -1,250 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/assets/profiles/turtle.svg b/src/assets/profiles/turtle.svg deleted file mode 100644 index a02a16f2..00000000 --- a/src/assets/profiles/turtle.svg +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/components/MediaItem/MediaItem.tsx b/src/components/MediaItem/MediaItem.tsx index 52be3a22..5122cca9 100644 --- a/src/components/MediaItem/MediaItem.tsx +++ b/src/components/MediaItem/MediaItem.tsx @@ -2,9 +2,7 @@ import { Settings } from '@/types/settings' import { TautulliItemRow } from '@/types/tautulli' -import { ANONYMIZED_ANIMALS } from '@/utils/constants' import { pluralize, secondsToTime } from '@/utils/formatting' -import { getAnimalIcon } from '@/utils/helpers' import { slideDown } from '@/utils/motion' import { CalendarDaysIcon, @@ -20,6 +18,7 @@ import clsx from 'clsx' import { motion } from 'framer-motion' import Image from 'next/image' import { useEffect, useRef, useState } from 'react' +import anonymousSvg from './anonymous.svg' import MediaItemTitle from './MediaItemTitle' import placeholderSvg from './placeholder.svg' import PlexDeeplink from './PlexDeeplink' @@ -55,9 +54,9 @@ export default function MediaItem({ isUserDashboard ? data.user_thumb : data.thumb }&width=300`, )}` - const isAnonymized = ANONYMIZED_ANIMALS.includes(data.user_thumb) + const isAnonymized = data.user === 'Anonymous' const initialImageSrc = - isUserDashboard && isAnonymized ? getAnimalIcon(data.user_thumb) : posterSrc + isUserDashboard && isAnonymized ? anonymousSvg : posterSrc const [imageSrc, setImageSrc] = useState(initialImageSrc) const [dataKey, setDataKey] = useState(0) const titleContainerRef = useRef(null) @@ -90,15 +89,10 @@ export default function MediaItem({ animate='show' transition={{ delay: i * 0.075 }} > -
+
{ + + + diff --git a/src/utils/constants.ts b/src/utils/constants.ts index b770a6e7..2f3d7ff3 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -88,24 +88,3 @@ export const SETTINGS_PAGES = [ ] export const TMDB_API_KEY = '4675b5b5d8cd1463ff16adca2680157b' - -export const ANONYMIZED_ANIMALS = [ - 'Bat', - 'Butterfly', - 'Cat', - 'Duck', - 'Giraffe', - 'Hippo', - 'Kangaroo', - 'Lion', - 'Monkey', - 'Moose', - 'Octopus', - 'Ostrich', - 'Rabbit', - 'Racoon', - 'Shark', - 'Snake', - 'Tiger', - 'Turtle', -] diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 1eaa5daa..24a3849f 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,25 +1,6 @@ -import batSvg from '@/assets/profiles/bat.svg' -import butterflySvg from '@/assets/profiles/butterfly.svg' -import catSvg from '@/assets/profiles/cat.svg' -import duckSvg from '@/assets/profiles/duck.svg' -import giraffeSvg from '@/assets/profiles/giraffe.svg' -import hippoSvg from '@/assets/profiles/hippo.svg' -import kangarooSvg from '@/assets/profiles/kangaroo.svg' -import lionSvg from '@/assets/profiles/lion.svg' -import monkeySvg from '@/assets/profiles/monkey.svg' -import mooseSvg from '@/assets/profiles/moose.svg' -import octopusSvg from '@/assets/profiles/octopus.svg' -import ostrichSvg from '@/assets/profiles/ostrich.svg' -import rabbitSvg from '@/assets/profiles/rabbit.svg' -import racoonSvg from '@/assets/profiles/racoon.svg' -import sharkSvg from '@/assets/profiles/shark.svg' -import snakeSvg from '@/assets/profiles/snake.svg' -import tigerSvg from '@/assets/profiles/tiger.svg' -import turtleSvg from '@/assets/profiles/turtle.svg' - import { Settings } from '@/types/settings' import { TautulliItemRow } from '@/types/tautulli' -import { ANONYMIZED_ANIMALS, PERIODS, SETTINGS_PAGES } from './constants' +import { PERIODS, SETTINGS_PAGES } from './constants' const REQUIRED_SETTINGS = [ 'connection.tautulliUrl', @@ -64,69 +45,15 @@ export function anonymizeUsers( users: TautulliItemRow[], loggedInUserId: string, ): TautulliItemRow[] { - const usedNames = new Set() - return users.map((user) => { const isLoggedIn = user.user_id === Number(loggedInUserId) - let anonName - - do { - anonName = - ANONYMIZED_ANIMALS[ - Math.floor(Math.random() * ANONYMIZED_ANIMALS.length) - ] - } while (usedNames.has(anonName)) - - usedNames.add(anonName) - return { ...user, - user: isLoggedIn ? user.user : 'Anonymous ' + anonName, - friendly_name: isLoggedIn ? user.friendly_name : 'Anonymous ' + anonName, - user_thumb: isLoggedIn ? user.user_thumb : anonName, + user: isLoggedIn ? user.user : 'Anonymous', + friendly_name: isLoggedIn ? user.friendly_name : 'Anonymous', + user_thumb: isLoggedIn ? user.user_thumb : '', user_id: isLoggedIn ? user.user_id : 0, } }) } - -export function getAnimalIcon(animal: string) { - switch (animal) { - case 'Bat': - return batSvg - case 'Butterfly': - return butterflySvg - case 'Cat': - return catSvg - case 'Duck': - return duckSvg - case 'Giraffe': - return giraffeSvg - case 'Hippo': - return hippoSvg - case 'Kangaroo': - return kangarooSvg - case 'Lion': - return lionSvg - case 'Monkey': - return monkeySvg - case 'Moose': - return mooseSvg - case 'Octopus': - return octopusSvg - case 'Ostrich': - return ostrichSvg - case 'Rabbit': - return rabbitSvg - case 'Racoon': - return racoonSvg - case 'Shark': - return sharkSvg - case 'Snake': - return snakeSvg - case 'Tiger': - return tigerSvg - case 'Turtle': - return turtleSvg - } -}