Skip to content

Commit 10f44df

Browse files
authored
Merge pull request #53 from teal-fm/matt/am-unlink
2 parents d843fa4 + a6c4f0c commit 10f44df

1 file changed

Lines changed: 54 additions & 10 deletions

File tree

pages/templates/applemusic_link.gohtml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,33 @@
1616
></script>
1717
</head>
1818
<body>
19-
<main style="max-width: 720px; margin: 4rem auto; padding: 0 1.5rem;">
20-
<h1 style="font-size: 2.5rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.75rem; background: linear-gradient(135deg, #fa2d48, #fc5c7d); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;">Link Apple Music</h1>
21-
<p style="font-size: 1.125rem; color: #8e8e93; max-width: 480px;">Authorize with Apple Music to enable MusicKit features and sync your library.</p>
19+
<main style="max-width: 720px; margin: 4rem auto; padding: 0 1.5rem">
20+
<h1
21+
style="
22+
font-size: 2.5rem;
23+
font-weight: 700;
24+
letter-spacing: -0.03em;
25+
margin-bottom: 0.75rem;
26+
background: linear-gradient(135deg, #fa2d48, #fc5c7d);
27+
-webkit-background-clip: text;
28+
-webkit-text-fill-color: transparent;
29+
background-clip: text;
30+
"
31+
>
32+
Link Apple Music
33+
</h1>
34+
<p style="font-size: 1.125rem; color: #8e8e93; max-width: 480px">
35+
Authorize with Apple Music to enable MusicKit features and sync your
36+
library.
37+
</p>
2238
<div
23-
style="display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; margin-top: 2rem;"
39+
style="
40+
display: flex;
41+
gap: 1.5rem;
42+
align-items: center;
43+
flex-wrap: wrap;
44+
margin-top: 2rem;
45+
"
2446
>
2547
<button id="authorizeBtn" class="am-btn am-btn-primary">
2648
🎵 Authorize Apple Music
@@ -29,11 +51,28 @@
2951
id="unlinkForm"
3052
method="post"
3153
action="/api/v1/applemusic/unlink"
32-
onsubmit="handleUnlink(event)"
54+
onsubmit="
55+
(async () => {
56+
const music = window.MusicKit.getInstance();
57+
await music.unauthorize();
58+
handleUnlink(event);
59+
})()
60+
"
3361
>
3462
<button type="submit" class="am-btn am-btn-danger">
35-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="flex-shrink: 0;">
36-
<path d="M18 6L6 18M6 6l12 12"/>
63+
<svg
64+
xmlns="http://www.w3.org/2000/svg"
65+
width="24"
66+
height="24"
67+
viewBox="0 0 24 24"
68+
fill="none"
69+
stroke="currentColor"
70+
stroke-width="2.5"
71+
stroke-linecap="round"
72+
stroke-linejoin="round"
73+
style="flex-shrink: 0"
74+
>
75+
<path d="M18 6L6 18M6 6l12 12" />
3776
</svg>
3877
Unlink Apple Music
3978
</button>
@@ -56,7 +95,12 @@
5695
letter-spacing: -0.01em;
5796
}
5897
.am-btn-primary {
59-
background: linear-gradient(135deg, #fa2d48 0%, #fc5c7d 50%, #fa2d48 100%);
98+
background: linear-gradient(
99+
135deg,
100+
#fa2d48 0%,
101+
#fc5c7d 50%,
102+
#fa2d48 100%
103+
);
60104
background-size: 200% 200%;
61105
color: white;
62106
}
@@ -146,7 +190,7 @@
146190
music.addEventListener("authorizationStatusDidChange", (e) => {
147191
console.debug(
148192
"authorizationStatusDidChange",
149-
e && e.authorizationStatus
193+
e && e.authorizationStatus,
150194
);
151195
});
152196
music.addEventListener("userTokenDidChange", (e) => {
@@ -161,7 +205,7 @@
161205
} catch (evtErr) {
162206
console.warn(
163207
"Failed to attach some MusicKit event listeners",
164-
evtErr
208+
evtErr,
165209
);
166210
}
167211
document

0 commit comments

Comments
 (0)