Skip to content

Commit

Permalink
feat(usersettings): add ability to hide tags on details page
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanjones98 committed Mar 12, 2024
1 parent 107bce2 commit 2e6be33
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 2 deletions.
3 changes: 3 additions & 0 deletions server/entity/UserSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ export class UserSettings {
@Column({ nullable: true })
public watchlistSyncTv?: boolean;

@Column({ nullable: true })
public hideTags?: boolean;

@Column({
type: 'text',
nullable: true,
Expand Down
1 change: 1 addition & 0 deletions server/interfaces/api/userSettingsInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface UserSettingsGeneralResponse {
globalTvQuotaDays?: number;
watchlistSyncMovies?: boolean;
watchlistSyncTv?: boolean;
hideTags?: boolean;
}

export type NotificationAgentTypes = Record<NotificationAgentKey, number>;
Expand Down
2 changes: 2 additions & 0 deletions server/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface MainSettings {
tv: Quota;
};
hideAvailable: boolean;
hideTags: boolean;
localLogin: boolean;
newPlexLogin: boolean;
region: string;
Expand Down Expand Up @@ -293,6 +294,7 @@ class Settings {
tv: {},
},
hideAvailable: false,
hideTags: false,
localLogin: true,
newPlexLogin: true,
region: '',
Expand Down
31 changes: 31 additions & 0 deletions server/migration/1710274992992-AddHideTagsColumn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class AddHideTagsColumn1710274992992 implements MigrationInterface {
name = 'AddHideTagsColumn1710274992992';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "temporary_user_settings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar NOT NULL DEFAULT (''), "region" varchar, "originalLanguage" varchar, "pgpKey" varchar, "discordId" varchar, "pushbulletAccessToken" varchar, "pushoverApplicationToken" varchar, "pushoverUserKey" varchar, "pushoverSound" varchar, "telegramChatId" varchar, "telegramSendSilently" boolean, "watchlistSyncMovies" boolean, "watchlistSyncTv" boolean, "notificationTypes" text, "userId" integer, "hideTags" boolean, CONSTRAINT "REL_986a2b6d3c05eb4091bb8066f7" UNIQUE ("userId"), CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "temporary_user_settings"("id", "locale", "region", "originalLanguage", "pgpKey", "discordId", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "pushoverSound", "telegramChatId", "telegramSendSilently", "watchlistSyncMovies", "watchlistSyncTv", "notificationTypes", "userId") SELECT "id", "locale", "region", "originalLanguage", "pgpKey", "discordId", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "pushoverSound", "telegramChatId", "telegramSendSilently", "watchlistSyncMovies", "watchlistSyncTv", "notificationTypes", "userId" FROM "user_settings"`
);
await queryRunner.query(`DROP TABLE "user_settings"`);
await queryRunner.query(
`ALTER TABLE "temporary_user_settings" RENAME TO "user_settings"`
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "user_settings" RENAME TO "temporary_user_settings"`
);
await queryRunner.query(
`CREATE TABLE "user_settings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "locale" varchar NOT NULL DEFAULT (''), "region" varchar, "originalLanguage" varchar, "pgpKey" varchar, "discordId" varchar, "pushbulletAccessToken" varchar, "pushoverApplicationToken" varchar, "pushoverUserKey" varchar, "pushoverSound" varchar, "telegramChatId" varchar, "telegramSendSilently" boolean, "watchlistSyncMovies" boolean, "watchlistSyncTv" boolean, "notificationTypes" text, "userId" integer, CONSTRAINT "REL_986a2b6d3c05eb4091bb8066f7" UNIQUE ("userId"), CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
);
await queryRunner.query(
`INSERT INTO "user_settings"("id", "locale", "region", "originalLanguage", "pgpKey", "discordId", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "pushoverSound", "telegramChatId", "telegramSendSilently", "watchlistSyncMovies", "watchlistSyncTv", "notificationTypes", "userId") SELECT "id", "locale", "region", "originalLanguage", "pgpKey", "discordId", "pushbulletAccessToken", "pushoverApplicationToken", "pushoverUserKey", "pushoverSound", "telegramChatId", "telegramSendSilently", "watchlistSyncMovies", "watchlistSyncTv", "notificationTypes", "userId" FROM "temporary_user_settings"`
);
await queryRunner.query(`DROP TABLE "temporary_user_settings"`);
}
}
4 changes: 4 additions & 0 deletions server/routes/user/usersettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ userSettingsRoutes.get<{ id: string }, UserSettingsGeneralResponse>(
globalTvQuotaLimit: defaultQuotas.tv.quotaLimit,
watchlistSyncMovies: user.settings?.watchlistSyncMovies,
watchlistSyncTv: user.settings?.watchlistSyncTv,
hideTags: user.settings?.hideTags,
});
} catch (e) {
next({ status: 500, message: e.message });
Expand Down Expand Up @@ -118,6 +119,7 @@ userSettingsRoutes.post<
originalLanguage: req.body.originalLanguage,
watchlistSyncMovies: req.body.watchlistSyncMovies,
watchlistSyncTv: req.body.watchlistSyncTv,
hideTags: req.body.hideTags,
});
} else {
user.settings.discordId = req.body.discordId;
Expand All @@ -126,6 +128,7 @@ userSettingsRoutes.post<
user.settings.originalLanguage = req.body.originalLanguage;
user.settings.watchlistSyncMovies = req.body.watchlistSyncMovies;
user.settings.watchlistSyncTv = req.body.watchlistSyncTv;
user.settings.hideTags = req.body.hideTags;
}

await userRepository.save(user);
Expand All @@ -138,6 +141,7 @@ userSettingsRoutes.post<
originalLanguage: user.settings.originalLanguage,
watchlistSyncMovies: user.settings.watchlistSyncMovies,
watchlistSyncTv: user.settings.watchlistSyncTv,
hideTags: user.settings.hideTags,
});
} catch (e) {
next({ status: 500, message: e.message });
Expand Down
2 changes: 1 addition & 1 deletion src/components/MovieDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ const MovieDetails = ({ movie }: MovieDetailsProps) => {
</div>
</>
)}
{data.keywords.length > 0 && (
{!user?.settings?.hideTags && data.keywords.length > 0 && (
<div className="mt-6">
{data.keywords.map((keyword) => (
<Link
Expand Down
2 changes: 1 addition & 1 deletion src/components/TvDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ const TvDetails = ({ tv }: TvDetailsProps) => {
</div>
</>
)}
{data.keywords.length > 0 && (
{!user?.settings?.hideTags && data.keywords.length > 0 && (
<div className="mt-6">
{data.keywords.map((keyword) => (
<Link
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ const messages = defineMessages({
plexwatchlistsyncseries: 'Auto-Request Series',
plexwatchlistsyncseriestip:
'Automatically request series on your <PlexWatchlistSupportLink>Plex Watchlist</PlexWatchlistSupportLink>',
hideTags: 'Hide Tags',
hideTagsTip: 'Hide tags in Movie/Series detail page',
});

const UserGeneralSettings = () => {
Expand Down Expand Up @@ -130,6 +132,7 @@ const UserGeneralSettings = () => {
tvQuotaDays: data?.tvQuotaDays,
watchlistSyncMovies: data?.watchlistSyncMovies,
watchlistSyncTv: data?.watchlistSyncTv,
hideTags: data?.hideTags,
}}
validationSchema={UserGeneralSettingsSchema}
enableReinitialize
Expand All @@ -149,6 +152,7 @@ const UserGeneralSettings = () => {
tvQuotaDays: tvQuotaEnabled ? values.tvQuotaDays : null,
watchlistSyncMovies: values.watchlistSyncMovies,
watchlistSyncTv: values.watchlistSyncTv,
hideTags: values.hideTags,
});

if (currentUser?.id === user?.id && setLocale) {
Expand Down Expand Up @@ -334,6 +338,24 @@ const UserGeneralSettings = () => {
</div>
</div>
</div>
<div className="form-row">
<label htmlFor="hideTags" className="checkbox-label">
<span>{intl.formatMessage(messages.hideTags)}</span>
<span className="label-tip">
{intl.formatMessage(messages.hideTagsTip)}
</span>
</label>
<div className="form-input-area">
<Field
type="checkbox"
id="hideTags"
name="hideTags"
onChange={() => {
setFieldValue('hideTags', !values.hideTags);
}}
/>
</div>
</div>
{currentHasPermission(Permission.MANAGE_USERS) &&
!hasPermission(Permission.MANAGE_USERS) && (
<>
Expand Down
1 change: 1 addition & 0 deletions src/hooks/useUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface UserSettings {
notificationTypes: Partial<NotificationAgentTypes>;
watchlistSyncMovies?: boolean;
watchlistSyncTv?: boolean;
hideTags?: boolean;
}

interface UserHookResponse {
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,8 @@
"components.UserProfile.UserSettings.UserGeneralSettings.enableOverride": "Override Global Limit",
"components.UserProfile.UserSettings.UserGeneralSettings.general": "General",
"components.UserProfile.UserSettings.UserGeneralSettings.generalsettings": "General Settings",
"components.UserProfile.UserSettings.UserGeneralSettings.hideTags": "Hide Tags",
"components.UserProfile.UserSettings.UserGeneralSettings.hideTagsTip": "Hide tags in Movie/Series detail page",
"components.UserProfile.UserSettings.UserGeneralSettings.languageDefault": "Default ({language})",
"components.UserProfile.UserSettings.UserGeneralSettings.localuser": "Local User",
"components.UserProfile.UserSettings.UserGeneralSettings.movierequestlimit": "Movie Request Limit",
Expand Down

0 comments on commit 2e6be33

Please sign in to comment.