Skip to content

Commit 1c564c9

Browse files
committed
Merge branch 'next' into apple-music
2 parents c84139b + ca9ee66 commit 1c564c9

File tree

8 files changed

+58
-41
lines changed

8 files changed

+58
-41
lines changed

next.config.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ module.exports = withBundleAnalyzer({
5252
destination: '/settings/profile',
5353
permanent: false,
5454
},
55+
{
56+
source: '/import',
57+
destination: '/settings/imports',
58+
permanent: true,
59+
},
5560
{
5661
source: '/discord',
5762
destination: 'https://stats.fm/discord',
@@ -108,15 +113,23 @@ module.exports = withBundleAnalyzer({
108113
},
109114
{
110115
source: '/:id/listeningClocks',
111-
destination: '/user/:id/listeningClocks',
116+
destination: '/user/:id/listening-clocks',
117+
},
118+
{
119+
source: '/:id/listening-clocks',
120+
destination: '/user/:id/listening-locks',
112121
},
113122
{
114123
source: '/:id/genres',
115124
destination: '/user/:id/genres',
116125
},
117126
{
118127
source: '/:id/recentStreams',
119-
destination: '/user/:id/recentStreams',
128+
destination: '/user/:id/recent-streams',
129+
},
130+
{
131+
source: '/:id/recent-streams',
132+
destination: '/user/:id/recent-streams',
120133
},
121134
];
122135
},

src/components/settings/Nav.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,7 @@ const NavBody: FC = () => (
5555
</NavGroup>
5656

5757
<NavGroup title="Stats">
58-
<SideNavItem external href="/import">
59-
Import
60-
</SideNavItem>
61-
{/* <SideNavItem disabled href="/settings/algorithms">
62-
Algorithms
63-
</SideNavItem> */}
64-
{/* <SideNavItem href="/account/algorithms">Stats & Algorithms</SideNavItem> */}
65-
{/* <SideNavItem href="/account/lang">Language & Theme</SideNavItem> */}
58+
<SideNavItem href="/settings/imports">Import</SideNavItem>
6659
</NavGroup>
6760
</aside>
6861
</nav>

src/hooks/use-api.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as statsfm from '@/utils/statsfm';
22
import Cookies from 'js-cookie';
33

4-
let apiUrl = process.env.NEXT_PUBLIC_API_URL ?? 'https://beta-api.stats.fm/api';
4+
let apiUrl = process.env.NEXT_PUBLIC_API_URL ?? 'https://api.stats.fm/api';
55

66
if (process.env.NODE_ENV === 'development')
77
apiUrl = process.env.NEXT_PUBLIC_API_URL ?? 'https://beta-api.stats.fm/api';

src/middleware.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ export const middleware = (request: NextRequest) => {
2828
};
2929

3030
export const config = {
31-
matcher: ['/import', '/settings/:path*'],
31+
matcher: ['/settings/:path*'],
3232
};

src/pages/import.tsx src/pages/settings/imports.tsx

+32-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
/* eslint-disable no-continue */
4-
import { Container } from '@/components/Container';
54
import { Divider } from '@/components/Divider';
65
import { ImportList } from '@/components/Import/ImportList';
76
import { UploadedItem } from '@/components/Import/UploadedItem';
@@ -23,8 +22,7 @@ import { MdFileUpload, MdWarning } from 'react-icons/md';
2322
import { BlobReader, TextWriter, ZipReader } from '@zip.js/zip.js';
2423
import { Button } from '@/components/Button';
2524
import { Platform } from '@/utils/statsfm';
26-
27-
type Props = {};
25+
import { AccountLayout } from '@/components/settings/Layout';
2826

2927
export const getServerSideProps: GetServerSideProps<SSRProps> = async (ctx) => {
3028
const user = await fetchUser(ctx);
@@ -44,7 +42,7 @@ interface ImportService {
4442
handleFileUpload: (file: File[]) => Promise<void> | void;
4543
}
4644

47-
const ImportPage: NextPage<Props> = () => {
45+
const Imports = () => {
4846
const { user } = useAuth();
4947
const api = useApi();
5048
const toaster = useToaster();
@@ -226,8 +224,8 @@ const ImportPage: NextPage<Props> = () => {
226224
if (!user) return <></>;
227225

228226
return (
229-
<Container className="pt-20">
230-
<Title>Import</Title>
227+
<div className="relative w-full">
228+
<Title>Imports</Title>
231229
{importWarning?.asBoolean() && (
232230
<div className="my-8 w-full flex-row rounded-md border-l-4 border-l-yellow-400/80 bg-yellow-400/20 p-4">
233231
<div className="flex w-full flex-col">
@@ -250,7 +248,7 @@ const ImportPage: NextPage<Props> = () => {
250248
target="blank"
251249
onClick={() => event('IMPORT_guide_click')}
252250
>
253-
here in the support docs
251+
in the support documentation.
254252
</a>
255253
.
256254
</p>
@@ -259,17 +257,19 @@ const ImportPage: NextPage<Props> = () => {
259257
{importAvailable?.asBoolean() ? (
260258
<>
261259
<div className="mt-5 flex flex-col items-center justify-center">
262-
<SegmentedControls
263-
onChange={(id) => {
264-
setImportService(services.find((x) => x.id === id)!);
265-
}}
266-
>
267-
{services.map((service) => (
268-
<Segment key={service.id} value={service.id}>
269-
{service.name}
270-
</Segment>
271-
))}
272-
</SegmentedControls>
260+
{services.length > 1 && (
261+
<SegmentedControls
262+
onChange={(id) => {
263+
setImportService(services.find((x) => x.id === id)!);
264+
}}
265+
>
266+
{services.map((service) => (
267+
<Segment key={service.id} value={service.id}>
268+
{service.name}
269+
</Segment>
270+
))}
271+
</SegmentedControls>
272+
)}
273273
<div className="mt-2 flex w-full items-center justify-center">
274274
<Dropzone
275275
onDrop={(files) => importService.handleFileUpload(files)}
@@ -302,7 +302,9 @@ const ImportPage: NextPage<Props> = () => {
302302
{Object.values(importService.acceptFiles)
303303
.flatMap((x) => x)
304304
.join(', ')}{' '}
305-
for this service.
305+
for{' '}
306+
{services.length > 1 ? 'this service' : 'Spotify'}
307+
.
306308
</p>
307309
<input {...getInputProps()} />
308310
</>
@@ -372,7 +374,17 @@ const ImportPage: NextPage<Props> = () => {
372374
you need stats.fm Plus.
373375
</h4>
374376
)}
375-
</Container>
377+
</div>
378+
);
379+
};
380+
381+
const ImportPage: NextPage = () => {
382+
const { user } = useAuth();
383+
if (!user) return null;
384+
return (
385+
<AccountLayout>
386+
<Imports />
387+
</AccountLayout>
376388
);
377389
};
378390

src/pages/user/[id]/[[...deeplink]].tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ function activeScrollIntoViewFromDeepLink(
6666
id !== 'tracks' &&
6767
id !== 'albums' &&
6868
id !== 'artists' &&
69-
id !== 'listeningClocks' &&
70-
id !== 'recentStreams'
69+
id !== 'listening-clocks' &&
70+
id !== 'recent-streams'
7171
)
7272
return null;
7373

@@ -110,7 +110,7 @@ export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => {
110110
const oembedUrl = encodeURIComponent(`https://stats.fm${ctx.resolvedUrl}`);
111111
ctx.res.setHeader(
112112
'Link',
113-
`<https://beta-api.stats.fm/api/v1/oembed?url=${oembedUrl}&format=json>; rel="alternate"; type="application/json+oembed"; title=""`
113+
`<https://api.stats.fm/api/v1/oembed?url=${oembedUrl}&format=json>; rel="alternate"; type="application/json+oembed"; title=""`
114114
);
115115

116116
return {
@@ -286,8 +286,8 @@ const User: NextPage<Props> = ({
286286
albums: topAlbumsRef,
287287
artists: topArtistsRef,
288288
genres: topGenresRef,
289-
listeningClocks: listeningClocksRef,
290-
recentStreams: recentStreamsRef,
289+
'listening-clocks': listeningClocksRef,
290+
'recent-streams': recentStreamsRef,
291291
};
292292

293293
if (scrollIntoView) refs[scrollIntoView].current?.scrollIntoView();

src/utils/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ export type UserScrollIntoView =
88
| 'tracks'
99
| 'albums'
1010
| 'artists'
11-
| 'listeningClocks'
12-
| 'recentStreams';
11+
| 'listening-clocks'
12+
| 'recent-streams';

src/utils/ssrUtils.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export const getApiInstance = (accessToken?: string) => {
1111
accessToken,
1212
},
1313
http: {
14-
apiUrl:
15-
process.env.NEXT_PUBLIC_API_URL ?? 'https://beta-api.stats.fm/api',
14+
apiUrl: process.env.NEXT_PUBLIC_API_URL ?? 'https://api.stats.fm/api',
1615
},
1716
});
1817
};

0 commit comments

Comments
 (0)