Skip to content

Commit

Permalink
Minor fixes (#811)
Browse files Browse the repository at this point in the history
* ci(frontend): add output for routes task

* ci(ts): quote moon configs correctly

* fix(backend): allow nullable media reason

* fix(frontend): extract to vars

* fix(frontend): type error

* build(backend): bump version

* fix(frontend): move loader correctly

* fix(frontend): remove duplicated code
  • Loading branch information
IgnisDa committed May 3, 2024
1 parent 6ed0f9a commit 94df117
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 77 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ryot"
version = "5.1.1"
version = "5.1.2"
edition = "2021"
repository = "https://github.com/IgnisDa/ryot"
license = "GPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/miscellaneous/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2410,7 +2410,7 @@ impl MiscellaneousService {
title: String,
publish_year: Option<i32>,
images: Option<serde_json::Value>,
media_reason: Vec<UserToMediaReason>,
media_reason: Option<Vec<UserToMediaReason>>,
}

let count_select = Query::select()
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub mod media {
pub struct MediaListItem {
pub data: MetadataSearchItem,
pub average_rating: Option<Decimal>,
pub media_reason: Vec<UserToMediaReason>,
pub media_reason: Option<Vec<UserToMediaReason>>,
}

#[derive(Debug, Serialize, Deserialize, SimpleObject, Clone, FromQueryResult)]
Expand Down
46 changes: 17 additions & 29 deletions apps/frontend/app/components/media.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
IconArrowBigUp,
IconArrowsRight,
IconBackpack,
IconBookmarksFilled,
IconBookmarks,
IconCheck,
IconCloudDownload,
IconEdit,
Expand Down Expand Up @@ -468,7 +468,7 @@ export const BaseDisplayItem = (props: {
highlightRightText?: string;
children?: ReactNode;
nameRight?: JSX.Element;
mediaReason?: UserToMediaReason[];
mediaReason?: UserToMediaReason[] | null;
}) => {
const colorScheme = useComputedColorScheme("dark");

Expand All @@ -492,6 +492,10 @@ export const BaseDisplayItem = (props: {
</Box>
);

const reasons = props.mediaReason?.filter((r) =>
[UserToMediaReason.Seen, UserToMediaReason.Watchlist].includes(r),
);

const themeIconSurrounder = (idx: number, icon?: JSX.Element) => (
<ThemeIcon variant="transparent" size="sm" color="lime" key={idx}>
{icon}
Expand All @@ -505,7 +509,6 @@ export const BaseDisplayItem = (props: {
justify="center"
direction="column"
>
{props.topLeft}
<SurroundingElement style={{ flex: "none" }} pos="relative">
<Image
src={props.imageLink}
Expand All @@ -527,29 +530,29 @@ export const BaseDisplayItem = (props: {
getInitials(props.name),
)}
/>
<Box pos="absolute" style={{ zIndex: 999 }} top={10} left={10}>
{props.topLeft}
</Box>
<Box pos="absolute" top={5} right={5}>
{props.topRight}
</Box>
{props.mediaReason ? (
{reasons && reasons.length > 0 ? (
<Group
style={blackBgStyles}
pos="absolute"
bottom={5}
left={5}
gap="xs"
gap={3}
>
{props.mediaReason
{reasons
.map((r) =>
match(r)
.with(UserToMediaReason.Seen, () => (
<IconRosetteDiscountCheck />
))
.with(UserToMediaReason.Watchlist, () => (
<IconBookmarksFilled />
))
.otherwise(() => undefined),
.with(UserToMediaReason.Watchlist, () => <IconBookmarks />)
.run(),
)
.filter(Boolean)
.map((icon, idx) => themeIconSurrounder(idx, icon))}
</Group>
) : null}
Expand Down Expand Up @@ -605,7 +608,7 @@ export const MediaItemWithoutUpdateModal = (props: {
noHref?: boolean;
onClick?: (e: React.MouseEvent) => Promise<void>;
nameRight?: JSX.Element;
mediaReason?: UserToMediaReason[];
mediaReason?: UserToMediaReason[] | null;
}) => {
const navigate = useNavigate();
const id = props.item.identifier;
Expand Down Expand Up @@ -640,15 +643,7 @@ export const MediaItemWithoutUpdateModal = (props: {
imagePlaceholder={getInitials(props.item?.title || "")}
topLeft={
props.imageOverlayForLoadingIndicator ? (
<Loader
pos="absolute"
style={{ zIndex: 999 }}
top={10}
left={10}
color="red"
variant="bars"
size="sm"
/>
<Loader color="red" variant="bars" size="sm" />
) : null
}
mediaReason={props.mediaReason}
Expand All @@ -675,14 +670,7 @@ export const MediaItemWithoutUpdateModal = (props: {
</Box>
) : props.noRatingLink ? undefined : (
<Box
p={3}
pos="absolute"
top={5}
right={5}
style={{
backgroundColor: "rgba(0, 0, 0, 0.75)",
borderRadius: 3,
}}
style={blackBgStyles}
onClick={(e) => {
e.preventDefault();
navigate(
Expand Down
29 changes: 12 additions & 17 deletions apps/frontend/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@ dependsOn:

fileGroups:
remix:
- app/**/*
- public/**/*
- env.d.ts
- remix.config.*
- 'app/**/*'
- 'public/**/*'
- 'env.d.ts'
- 'remix.config.*'

tasks:
routes:
command: remix-routes
inputs:
- '@group(remix)'
command: 'remix-routes'
inputs: ['@group(remix)']
outputs: ['app/remix-routes.d.ts']

dev:
command: 'remix vite:dev --port 3000 --host'
local: true
deps:
- routes
deps: ['~:routes']

build:
deps:
- routes
command: 'remix vite:build'
inputs:
- '@group(remix)'
outputs:
- build
inputs: ['@group(remix)']
outputs: ['build']
deps: ['~:routes']
options:
runDepsInParallel: false

typecheck:
inputs:
- '@group(remix)'
inputs: ['@group(remix)']
20 changes: 8 additions & 12 deletions apps/landing/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ dependsOn:

fileGroups:
astro:
- src/**/*
- public/**/*
- astro.config.*
- tailwind.config.*
- 'src/**/*'
- 'public/**/*'
- 'astro.config.*'
- 'tailwind.config.*'

tasks:
dev:
Expand All @@ -15,14 +15,10 @@ tasks:

check:
command: 'astro check'
inputs:
- '@group(astro)'
inputs: ['@group(astro)']

build:
command: 'astro build'
deps:
- ~:check
inputs:
- '@group(astro)'
outputs:
- dist
deps: ['~:check']
inputs: ['@group(astro)']
outputs: ['dist']
15 changes: 7 additions & 8 deletions libs/generated/moon.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
type: library
type: 'library'

tasks:
backend-graphql:
command:
- graphql-codegen
- 'graphql-codegen'
- '--config'
- src/graphql/backend/codegen.ts
outputs:
- src/graphql/backend
- 'src/graphql/backend/codegen.ts'
outputs: ['src/graphql/backend']
local: true

workspace:
inheritedTasks:
exclude:
- build
- lint
- format
- 'build'
- 'lint'
- 'format'
4 changes: 2 additions & 2 deletions libs/generated/src/graphql/backend/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ export enum MediaGeneralFilter {
export type MediaListItem = {
averageRating?: Maybe<Scalars['Decimal']['output']>;
data: MetadataSearchItem;
mediaReason: Array<UserToMediaReason>;
mediaReason?: Maybe<Array<UserToMediaReason>>;
};

export type MediaListResults = {
Expand Down Expand Up @@ -2843,7 +2843,7 @@ export type MetadataListQueryVariables = Exact<{
}>;


export type MetadataListQuery = { metadataList: { details: { total: number, nextPage?: number | null }, items: Array<{ averageRating?: string | null, mediaReason: Array<UserToMediaReason>, data: { identifier: string, title: string, image?: string | null, publishYear?: number | null } }> } };
export type MetadataListQuery = { metadataList: { details: { total: number, nextPage?: number | null }, items: Array<{ averageRating?: string | null, mediaReason?: Array<UserToMediaReason> | null, data: { identifier: string, title: string, image?: string | null, publishYear?: number | null } }> } };

export type MetadataMainDetailsQueryVariables = Exact<{
metadataId: Scalars['Int']['input'];
Expand Down
6 changes: 3 additions & 3 deletions libs/graphql/moon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type: library
type: 'library'

workspace:
inheritedTasks:
exclude:
- build
- test
- 'build'
- 'test'
4 changes: 2 additions & 2 deletions libs/ts-utils/moon.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type: library
type: 'library'

workspace:
inheritedTasks:
exclude:
- build
- 'build'

0 comments on commit 94df117

Please sign in to comment.