88 useRelativeTime ,
99} from ' @modrinth/ui'
1010import { defineMessages , useVIntl } from ' @vintl/vintl'
11+ import { IntlFormatted } from ' @vintl/vintl/components'
1112import { computed , onUnmounted , ref , watch } from ' vue'
1213
1314import FriendsSection from ' @/components/ui/friends/FriendsSection.vue'
@@ -127,6 +128,7 @@ watch(
127128 () => {
128129 if (userCredentials .value === undefined ) {
129130 userFriends .value = []
131+ loading .value = false
130132 } else if (userCredentials .value === null ) {
131133 userFriends .value = []
132134 loading .value = false
@@ -199,6 +201,15 @@ const messages = defineMessages({
199201 id: ' friends.no-friends-match' ,
200202 defaultMessage: ` No friends matching ''{query}'' ` ,
201203 },
204+ signInToAddFriends: {
205+ id: ' friends.sign-in-to-add-friends' ,
206+ defaultMessage:
207+ " <link>Sign in to a Modrinth account</link> to add friends and see what they're playing!" ,
208+ },
209+ addFriendsToShare: {
210+ id: ' friends.add-friends-to-share' ,
211+ defaultMessage: " <link>Add friends</link> to see what they're playing!" ,
212+ },
202213})
203214 </script >
204215
@@ -211,7 +222,7 @@ const messages = defineMessages({
211222 <div class =" grid grid-cols-[1fr_auto] w-full gap-4" >
212223 <div >
213224 <p class =" m-0" >
214- <template v-if =" friend .id === userCredentials .user_id " >
225+ <template v-if =" friend .id === userCredentials ? .user_id " >
215226 <span class =" text-contrast" >{{ friend.username }}</span > sent you a friend request
216227 </template >
217228 <template v-else >
@@ -223,7 +234,7 @@ const messages = defineMessages({
223234 </p >
224235 </div >
225236 <div class =" flex gap-2" >
226- <template v-if =" friend .id === userCredentials .user_id " >
237+ <template v-if =" friend .id === userCredentials ? .user_id " >
227238 <ButtonStyled color =" brand" >
228239 <button @click =" addFriend(friend)" >
229240 <UserPlusIcon />
@@ -277,33 +288,38 @@ const messages = defineMessages({
277288 </div >
278289 </div >
279290 </ModalWrapper >
280- <div v-if =" userCredentials && !loading" class =" flex gap-1 items-center mb-3 ml-2 mr-2" >
281- <ButtonStyled circular type =" transparent" >
282- <button
283- v-tooltip =" formatMessage(messages.addFriend)"
284- :aria-label =" formatMessage(messages.addFriend)"
285- @click =" addFriendModal.show"
286- >
287- <UserPlusIcon />
288- </button >
289- </ButtonStyled >
290- <div class =" iconified-input flex-1" >
291- <input
292- v-model =" search"
293- type =" text"
294- class =" friends-search-bar flex w-full"
295- :placeholder =" formatMessage(messages.searchFriends)"
296- @keyup.esc =" search = ''"
297- />
298- <button
299- v-if =" search"
300- v-tooltip =" formatMessage(commonMessages.clearButton)"
301- class =" r-btn flex items-center justify-center bg-transparent button-animation p-2 cursor-pointer appearance-none border-none"
302- @click =" search = ''"
303- >
304- <XIcon />
305- </button >
306- </div >
291+ <div v-if =" userCredentials && !loading" class =" flex gap-1 items-center mb-3 ml-2 mr-1" >
292+ <template v-if =" sortedFriends .length > 0 " >
293+ <ButtonStyled circular type =" transparent" >
294+ <button
295+ v-tooltip =" formatMessage(messages.addFriend)"
296+ :aria-label =" formatMessage(messages.addFriend)"
297+ @click =" addFriendModal.show"
298+ >
299+ <UserPlusIcon />
300+ </button >
301+ </ButtonStyled >
302+ <div class =" iconified-input flex-1" >
303+ <input
304+ v-model =" search"
305+ type =" text"
306+ class =" friends-search-bar flex w-full"
307+ :placeholder =" formatMessage(messages.searchFriends)"
308+ @keyup.esc =" search = ''"
309+ />
310+ <button
311+ v-if =" search"
312+ v-tooltip =" formatMessage(commonMessages.clearButton)"
313+ class =" r-btn flex items-center justify-center bg-transparent button-animation p-2 cursor-pointer appearance-none border-none"
314+ @click =" search = ''"
315+ >
316+ <XIcon />
317+ </button >
318+ </div >
319+ </template >
320+ <h3 v-else class =" ml-2 w-full text-base text-primary font-medium m-0" >
321+ {{ formatMessage(messages.friends) }}
322+ </h3 >
307323 <ButtonStyled v-if =" incomingRequests.length > 0" circular type =" transparent" >
308324 <button
309325 v-tooltip =" formatMessage(messages.viewFriendRequests, { count: incomingRequests.length })"
@@ -323,9 +339,14 @@ const messages = defineMessages({
323339 </ButtonStyled >
324340 </div >
325341 <div class =" flex flex-col gap-3" >
342+ <h3
343+ v-if =" sortedFriends.length === 0 || loading"
344+ class =" ml-4 mr-1 text-base text-primary font-medium m-0"
345+ >
346+ {{ formatMessage(messages.friends) }}
347+ </h3 >
326348 <template v-if =" loading " >
327- <h3 class =" text-base text-primary font-medium m-0" >{{ formatMessage(messages.friends) }}</h3 >
328- <div v-for =" n in 5" :key =" n" class =" flex gap-2 items-center animate-pulse" >
349+ <div v-for =" n in 5" :key =" n" class =" flex gap-2 items-center animate-pulse ml-4 mr-1" >
329350 <div class =" min-w-9 min-h-9 bg-button-bg rounded-full" ></div >
330351 <div class =" flex flex-col w-full" >
331352 <div class =" h-3 bg-button-bg rounded-full w-1/2 mb-1" ></div >
@@ -334,16 +355,24 @@ const messages = defineMessages({
334355 </div >
335356 </template >
336357 <template v-else-if =" sortedFriends .length === 0 " >
337- <div class =" text-sm mx-4 " >
358+ <div class =" text-sm ml-4 mr-1 " >
338359 <div v-if =" !userCredentials" >
339- <span class =" font-semibold text-brand cursor-pointer" @click =" signIn"
340- >Sign in to a Modrinth account</span
341- >
342- to add friends and see what they're playing!
360+ <IntlFormatted :message-id =" messages.signInToAddFriends" >
361+ <template #link =" { children } " >
362+ <span class =" font-semibold text-brand cursor-pointer" @click =" signIn" >
363+ <component :is =" () => children" />
364+ </span >
365+ </template >
366+ </IntlFormatted >
343367 </div >
344368 <div v-else >
345- <span class =" text-link cursor-pointer" @click =" addFriendModal.show()" >Add friends</span >
346- to share what you're playing!
369+ <IntlFormatted :message-id =" messages.addFriendsToShare" >
370+ <template #link =" { children } " >
371+ <span class =" font-semibold text-brand cursor-pointer" @click =" signIn" >
372+ <component :is =" () => children" />
373+ </span >
374+ </template >
375+ </IntlFormatted >
347376 </div >
348377 </div >
349378 </template >
0 commit comments