Skip to content

Commit db9e6fa

Browse files
committed
fix cargo fmt
1 parent d114b60 commit db9e6fa

File tree

6 files changed

+166
-152
lines changed

6 files changed

+166
-152
lines changed

apps/desktop/packages/mainWindow/src/components/NewsContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ export const useNewsContext = () => {
3838
throw new Error("useNewsContext must be used within a NewsProvider")
3939
}
4040
return context
41-
}
41+
}

apps/desktop/packages/mainWindow/src/pages/News/PageView.tsx

Lines changed: 145 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -38,134 +38,138 @@ const PageView = () => {
3838
}
3939

4040
const patchContent = createQuery(() => ({
41-
queryKey: ['patchContent', currentArticle()?.contentPath],
41+
queryKey: ["patchContent", currentArticle()?.contentPath],
4242
queryFn: () => fetchPatchContent(currentArticle()!.contentPath!),
43-
enabled: !!currentArticle()?.contentPath && currentArticle()?.type === "patch",
43+
enabled:
44+
!!currentArticle()?.contentPath && currentArticle()?.type === "patch",
4445
staleTime: 30 * 60 * 1000 // 30 minutes
4546
}))
4647

4748
return (
4849
<div class="max-w-4xl mx-auto p-6">
49-
<Show
50-
when={!news.isPending && !patchNotes.isPending && currentArticle()}
51-
fallback={
52-
<div class="text-center py-20">
53-
<div class="bg-darkSlate-700 rounded-2xl p-12 border border-darkSlate-600">
54-
<Show
55-
when={news.isPending || patchNotes.isPending}
56-
fallback={
57-
<>
58-
<h1 class="text-3xl font-bold mb-6 text-white">
59-
Article not found
60-
</h1>
61-
<p class="text-lightSlate-400 mb-8">
62-
The article you're looking for doesn't exist or has been
63-
removed.
64-
</p>
65-
<Button
66-
onClick={() => navigator.navigate("/news")}
67-
class="px-8 py-3"
68-
>
69-
Back to News
70-
</Button>
71-
</>
72-
}
73-
>
74-
<div class="flex items-center justify-center gap-3 text-lightSlate-400">
75-
<div class="animate-spin i-ri:loader-4-line text-2xl" />
76-
<span class="text-xl">Loading article...</span>
77-
</div>
78-
</Show>
79-
</div>
50+
<Show
51+
when={!news.isPending && !patchNotes.isPending && currentArticle()}
52+
fallback={
53+
<div class="text-center py-20">
54+
<div class="bg-darkSlate-700 rounded-2xl p-12 border border-darkSlate-600">
55+
<Show
56+
when={news.isPending || patchNotes.isPending}
57+
fallback={
58+
<>
59+
<h1 class="text-3xl font-bold mb-6 text-white">
60+
Article not found
61+
</h1>
62+
<p class="text-lightSlate-400 mb-8">
63+
The article you're looking for doesn't exist or has been
64+
removed.
65+
</p>
66+
<Button
67+
onClick={() => navigator.navigate("/news")}
68+
class="px-8 py-3"
69+
>
70+
Back to News
71+
</Button>
72+
</>
73+
}
74+
>
75+
<div class="flex items-center justify-center gap-3 text-lightSlate-400">
76+
<div class="animate-spin i-ri:loader-4-line text-2xl" />
77+
<span class="text-xl">Loading article...</span>
78+
</div>
79+
</Show>
8080
</div>
81-
}
82-
>
83-
{(article) => (
84-
<article class="flex flex-col gap-8">
85-
<style>
86-
{`
81+
</div>
82+
}
83+
>
84+
{(article) => (
85+
<article class="flex flex-col gap-8">
86+
<style>
87+
{`
8788
#news_article_content *::selection {
8889
background: rgb(var(--primary-500) / 0.3);
8990
color: rgb(var(--lightSlate-50));
9091
}
9192
`}
92-
</style>
93-
{/* Navigation */}
94-
<button
95-
onClick={() => navigator.navigate("/news")}
96-
class="self-start text-lightSlate-400 hover:text-lightSlate-200 flex items-center gap-3 mb-2 transition-colors group"
97-
>
98-
<div class="i-ri:arrow-left-line group-hover:transform group-hover:-translate-x-1 transition-transform" />
99-
<span class="font-medium">Back to News</span>
100-
</button>
93+
</style>
94+
{/* Navigation */}
95+
<button
96+
onClick={() => navigator.navigate("/news")}
97+
class="self-start text-lightSlate-400 hover:text-lightSlate-200 flex items-center gap-3 mb-2 transition-colors group"
98+
>
99+
<div class="i-ri:arrow-left-line group-hover:transform group-hover:-translate-x-1 transition-transform" />
100+
<span class="font-medium">Back to News</span>
101+
</button>
101102

102-
{/* Hero Image */}
103-
<div class="relative overflow-hidden rounded-2xl shadow-2xl">
104-
<img
105-
src={article().image}
106-
alt={article().title}
107-
class="w-full h-96 object-cover"
108-
/>
109-
<div class="absolute inset-0 bg-gradient-to-t from-black/50 to-transparent" />
110-
</div>
103+
{/* Hero Image */}
104+
<div class="relative overflow-hidden rounded-2xl shadow-2xl">
105+
<img
106+
src={article().image}
107+
alt={article().title}
108+
class="w-full h-96 object-cover"
109+
/>
110+
<div class="absolute inset-0 bg-gradient-to-t from-black/50 to-transparent" />
111+
</div>
111112

112-
{/* Header */}
113-
<header class="flex flex-col gap-6 bg-darkSlate-700 rounded-2xl p-8 border border-darkSlate-600">
114-
<div class="flex items-start justify-between gap-4">
115-
<h1 class="text-5xl font-bold leading-tight text-white">
116-
{article().title}
117-
</h1>
118-
{article().type === "patch" && (
119-
<div class="flex flex-col gap-2 items-end">
120-
<span class="text-sm bg-primary-600/20 text-primary-300 px-4 py-2 rounded-full border border-primary-600/30 font-semibold">
121-
Patch Notes
113+
{/* Header */}
114+
<header class="flex flex-col gap-6 bg-darkSlate-700 rounded-2xl p-8 border border-darkSlate-600">
115+
<div class="flex items-start justify-between gap-4">
116+
<h1 class="text-5xl font-bold leading-tight text-white">
117+
{article().title}
118+
</h1>
119+
{article().type === "patch" && (
120+
<div class="flex flex-col gap-2 items-end">
121+
<span class="text-sm bg-primary-600/20 text-primary-300 px-4 py-2 rounded-full border border-primary-600/30 font-semibold">
122+
Patch Notes
123+
</span>
124+
{article().version && (
125+
<span class="text-xs text-lightSlate-400 font-mono">
126+
v{article().version}
122127
</span>
123-
{article().version && (
124-
<span class="text-xs text-lightSlate-400 font-mono">
125-
v{article().version}
126-
</span>
127-
)}
128-
</div>
129-
)}
130-
</div>
131-
132-
<div class="flex items-center gap-4 text-lightSlate-300">
133-
<div class="flex items-center gap-2">
134-
<i class="i-ri:calendar-line text-primary-400" />
135-
<time class="text-lg font-medium">
136-
{new Date(article().date).toLocaleDateString(undefined, {
137-
year: "numeric",
138-
month: "long",
139-
day: "numeric"
140-
})}
141-
</time>
128+
)}
142129
</div>
143-
<div class="w-1 h-1 bg-lightSlate-500 rounded-full" />
144-
<span class="text-sm capitalize font-medium text-lightSlate-400">
145-
{article().type === "patch"
146-
? "Minecraft Patch"
147-
: "Minecraft News"}
148-
</span>
130+
)}
131+
</div>
132+
133+
<div class="flex items-center gap-4 text-lightSlate-300">
134+
<div class="flex items-center gap-2">
135+
<i class="i-ri:calendar-line text-primary-400" />
136+
<time class="text-lg font-medium">
137+
{new Date(article().date).toLocaleDateString(undefined, {
138+
year: "numeric",
139+
month: "long",
140+
day: "numeric"
141+
})}
142+
</time>
149143
</div>
150-
</header>
144+
<div class="w-1 h-1 bg-lightSlate-500 rounded-full" />
145+
<span class="text-sm capitalize font-medium text-lightSlate-400">
146+
{article().type === "patch"
147+
? "Minecraft Patch"
148+
: "Minecraft News"}
149+
</span>
150+
</div>
151+
</header>
151152

152-
{/* Content */}
153-
<div id="news_article_content" class="bg-darkSlate-700 rounded-2xl p-8 border border-darkSlate-600">
154-
{article().type === "patch" ? (
155-
<Show
156-
when={patchContent.data}
157-
fallback={
158-
<div class="flex items-center justify-center py-16">
159-
<div class="flex items-center gap-3 text-lightSlate-400">
160-
<div class="animate-spin i-ri:loader-4-line text-xl" />
161-
<span class="text-lg">Loading patch content...</span>
162-
</div>
153+
{/* Content */}
154+
<div
155+
id="news_article_content"
156+
class="bg-darkSlate-700 rounded-2xl p-8 border border-darkSlate-600"
157+
>
158+
{article().type === "patch" ? (
159+
<Show
160+
when={patchContent.data}
161+
fallback={
162+
<div class="flex items-center justify-center py-16">
163+
<div class="flex items-center gap-3 text-lightSlate-400">
164+
<div class="animate-spin i-ri:loader-4-line text-xl" />
165+
<span class="text-lg">Loading patch content...</span>
163166
</div>
164-
}
165-
>
166-
<div class="patch-content">
167-
<style>
168-
{`
167+
</div>
168+
}
169+
>
170+
<div class="patch-content">
171+
<style>
172+
{`
169173
.patch-content h1, .patch-content h2, .patch-content h3, .patch-content h4, .patch-content h5, .patch-content h6 {
170174
font-weight: 700;
171175
margin: 1.5rem 0 1rem 0;
@@ -274,40 +278,40 @@ const PageView = () => {
274278
font-weight: 600;
275279
}
276280
`}
277-
</style>
278-
<div
279-
class="text-lightSlate-100 leading-relaxed prose prose-lg prose-invert max-w-none"
280-
// eslint-disable-next-line solid/no-innerhtml
281-
innerHTML={parseToHtml(patchContent.data!)}
282-
/>
283-
</div>
284-
</Show>
285-
) : (
286-
<div class="prose prose-xl prose-invert max-w-none">
287-
<p class="text-lightSlate-100 leading-relaxed first-letter:text-6xl first-letter:font-bold first-letter:text-primary-400 first-letter:float-left first-letter:mr-3 first-letter:mt-1">
288-
{article().description}
289-
</p>
281+
</style>
282+
<div
283+
class="text-lightSlate-100 leading-relaxed prose prose-lg prose-invert max-w-none"
284+
// eslint-disable-next-line solid/no-innerhtml
285+
innerHTML={parseToHtml(patchContent.data!)}
286+
/>
290287
</div>
291-
)}
292-
</div>
288+
</Show>
289+
) : (
290+
<div class="prose prose-xl prose-invert max-w-none">
291+
<p class="text-lightSlate-100 leading-relaxed first-letter:text-6xl first-letter:font-bold first-letter:text-primary-400 first-letter:float-left first-letter:mr-3 first-letter:mt-1">
292+
{article().description}
293+
</p>
294+
</div>
295+
)}
296+
</div>
293297

294-
{/* Action Button */}
295-
<div class="flex justify-center pt-4">
296-
<Button
297-
onClick={() => window.openExternalLink(article().url)}
298-
class="flex items-center gap-3 px-8 py-4 text-lg font-semibold bg-gradient-to-r from-primary-600 to-primary-700 hover:from-primary-500 hover:to-primary-600 border border-primary-500/50 shadow-lg hover:shadow-primary-500/25 transition-all duration-300"
299-
>
300-
<span>
301-
{article().type === "patch"
302-
? "Read Full Patch Notes"
303-
: "Read Full Article"}
304-
</span>
305-
<div class="i-ri:external-link-line text-xl" />
306-
</Button>
307-
</div>
308-
</article>
309-
)}
310-
</Show>
298+
{/* Action Button */}
299+
<div class="flex justify-center pt-4">
300+
<Button
301+
onClick={() => window.openExternalLink(article().url)}
302+
class="flex items-center gap-3 px-8 py-4 text-lg font-semibold bg-gradient-to-r from-primary-600 to-primary-700 hover:from-primary-500 hover:to-primary-600 border border-primary-500/50 shadow-lg hover:shadow-primary-500/25 transition-all duration-300"
303+
>
304+
<span>
305+
{article().type === "patch"
306+
? "Read Full Patch Notes"
307+
: "Read Full Article"}
308+
</span>
309+
<div class="i-ri:external-link-line text-xl" />
310+
</Button>
311+
</div>
312+
</article>
313+
)}
314+
</Show>
311315
</div>
312316
)
313317
}

apps/desktop/packages/mainWindow/src/utils/news.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ const fetchNews = async (): Promise<ContentItem[]> => {
132132

133133
export const useNews = () => {
134134
return createQuery(() => ({
135-
queryKey: ['news'],
135+
queryKey: ["news"],
136136
queryFn: fetchNews,
137137
staleTime: 15 * 60 * 1000, // 15 minutes
138138
gcTime: 30 * 60 * 1000 // 30 minutes
@@ -141,10 +141,9 @@ export const useNews = () => {
141141

142142
export const usePatchNotes = () => {
143143
return createQuery(() => ({
144-
queryKey: ['patchNotes'],
144+
queryKey: ["patchNotes"],
145145
queryFn: fetchPatchNotes,
146146
staleTime: 15 * 60 * 1000, // 15 minutes
147147
gcTime: 30 * 60 * 1000 // 30 minutes
148148
}))
149149
}
150-

apps/desktop/packages/mainWindow/src/utils/routes.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ export const isNewsPath = (path: string | number) => {
2929
export const isNewsDetailPath = (path: string | number) => {
3030
return /^\/news\/[^/]+$/.exec(path.toString())
3131
}
32-

crates/carbon_app/src/api/modplatforms/filters.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,9 @@ impl From<FEUnifiedSearchParameters> for ProjectSearchParameters {
258258

259259
// Extract Modrinth-specific sorting from platform filters, default to Downloads
260260
let sort_index = match &value.platform_filters {
261-
Some(FEPlatformFilters::Modrinth { sort_index }) => sort_index.as_ref().map(|idx| idx.clone().into()),
261+
Some(FEPlatformFilters::Modrinth { sort_index }) => {
262+
sort_index.as_ref().map(|idx| idx.clone().into())
263+
}
262264
_ => Some(SearchIndex::Downloads), // Default to Downloads when no platform filters
263265
};
264266

@@ -281,10 +283,17 @@ impl From<FEUnifiedSearchParameters> for ModSearchParameters {
281283
fn from(value: FEUnifiedSearchParameters) -> Self {
282284
// Extract Curseforge-specific sorting from platform filters, default to TotalDownloads DESC
283285
let (sort_field, sort_order) = match &value.platform_filters {
284-
Some(FEPlatformFilters::Curseforge { sort_field, sort_order }) => {
285-
(sort_field.as_ref().map(|f| f.clone().into()), sort_order.as_ref().map(|o| o.clone().into()))
286-
},
287-
_ => (Some(ModSearchSortField::TotalDownloads), Some(ModSearchSortOrder::Descending)), // Default to TotalDownloads DESC
286+
Some(FEPlatformFilters::Curseforge {
287+
sort_field,
288+
sort_order,
289+
}) => (
290+
sort_field.as_ref().map(|f| f.clone().into()),
291+
sort_order.as_ref().map(|o| o.clone().into()),
292+
),
293+
_ => (
294+
Some(ModSearchSortField::TotalDownloads),
295+
Some(ModSearchSortOrder::Descending),
296+
), // Default to TotalDownloads DESC
288297
};
289298

290299
ModSearchParameters {

crates/carbon_app/src/api/modplatforms/responses.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,10 @@ impl From<Project> for FEUnifiedSearchResult {
546546
}
547547

548548
impl FEUnifiedSearchResult {
549-
pub fn from_project_with_team(value: Project, team: Option<Vec<carbon_platforms::modrinth::user::TeamMember>>) -> Self {
549+
pub fn from_project_with_team(
550+
value: Project,
551+
team: Option<Vec<carbon_platforms::modrinth::user::TeamMember>>,
552+
) -> Self {
550553
let authors = if let Some(team_members) = team {
551554
team_members
552555
.into_iter()

0 commit comments

Comments
 (0)