dotfiles/.config/spicetify/Extracted/Raw/xpui/xpui-routes-buddy-feed.js

2 lines
16 KiB
JavaScript
Executable File

"use strict";(("undefined"!=typeof self?self:global).webpackChunkopen=("undefined"!=typeof self?self:global).webpackChunkopen||[]).push([[4338],{71429:(e,s,i)=>{i.r(s),i.d(s,{default:()=>Os});var a=i(59496),t=i(74567),n=i(69042),r=i(3802),c=i(52143),l=i(61940),d=i(48631),o=i(35800),u=i(95663),m=i(3289),f=i(64719),g=i(21524),h=i(96170),x=i(48657),b=i(84875),j=i.n(b),p=i(56162),y=i(50346),N=i(62344),v=i(88513),k=i(14280),C=i(73444),E=i(762),I=i(84229),L=i(68776),S=i(63120),w=i(24843),D=i(6142),O=i(54299),T=i(4183),F=i(98340),A=i(48607),M=i(9374),_=i(95077),B=i(45265);const U=e=>{if(!Number.isInteger(e))return"";const s=Date.now()-Number(e),i=Math.round(s/1e3/60),a=Math.round(s/1e3/60/60),t=Math.round(s/1e3/60/60/24),n=Math.round(s/1e3/60/60/24/7);return t>=7?r.ag.get("time.weeks.short",n):a>=24?r.ag.get("time.days.short",t):i>=60?r.ag.get("time.hours.short",a):i>0?r.ag.get("time.minutes.short",i):r.ag.get("time.now")};var P=i(4637);const z=e=>{const{timestamp:s,isNowPlaying:i}=e;return i?(0,P.jsx)(B.w,{label:r.ag.get("time.now"),children:(0,P.jsx)(_.h,{"aria-label":r.ag.get("time.now"),iconSize:16})}):(0,P.jsx)("span",{children:U(s)})},J="main-buddyFeed-friendActivity",R="VLKqDIGaQn2bILzJKSZ0",Y="main-buddyFeed-friendsFeedContainer",Z="main-buddyFeed-avatarContainer",K="main-buddyFeed-overlay",H="main-buddyFeed-playIcon",q="main-buddyFeed-activityMetadata",W="main-buddyFeed-usernameAndTimestamp",Q="main-buddyFeed-username",V="main-buddyFeed-timestamp",G="main-buddyFeed-artistAndTrackName",X="main-buddyFeed-playbackContextIcon",$="main-buddyFeed-playbackContext",ee="main-buddyFeed-playbackContextLink",se="main-buddyFeed-addFriendPlaceholder",ie="main-buddyFeed-addFriendPlaceholderBtn",ae="main-buddyFeed-emptyBuddyFeed",te="main-buddyFeed-addFriendPlaceholderText",ne="PjDcsgAPmXlcTBJRGpIu",re="IRpPQFA57qgQ5jicWWaD",ce="Hm3nIbegLclY1uCAmnx_",le="bhRoVUHjWdo9mgUkU6fe",de="BliqfY7vu_qE2C9zs5Ou",oe="qdYWuHZd4HdSWfd4pSQB",ue="DhvYWKjDc7uyF3HfkDJJ",me="ralK8s_OmE8a8zWcfNKM",fe=e=>Date.now()-e<9e5,ge=(e,s)=>{const i=(0,y.EC)(e)?.type;switch(i){case y.JM.PLAYLIST:case y.JM.PLAYLIST_V2:return(0,P.jsx)(C.X,{uri:e});case y.JM.EPISODE:case y.JM.SHOW:return(0,P.jsx)(E.M,{uri:e});case y.JM.ALBUM:return(0,P.jsx)(v.Y,{uri:e,artistUri:s});case y.JM.ARTIST:return(0,P.jsx)(k.m,{uri:e});default:return null}},he=e=>{switch(e){case y.JM.ALBUM:return M.p.ALBUM;case y.JM.ARTIST:return M.p.ARTIST;case y.JM.SHOW:return M.p.SHOW;case y.JM.EPISODE:return M.p.EPISODE;case y.JM.PLAYLIST:case y.JM.PLAYLIST_V2:return M.p.PLAYLIST;default:return}},xe=e=>{const{show:s=!0,spec:i,friend:t}=e,n=(0,a.useMemo)((()=>t.user.imageUrl?[{url:t.user.imageUrl,width:0,height:0}]:[]),[t.user.imageUrl]),c=(0,u.o)(),l=(0,h.$P)(),d=t.track,o=d.uri,m=d?.context?.uri,{usePlayContextItem:f}=(0,A.n)({uri:m},{featureIdentifier:"buddy_feed",referrerIdentifier:"buddy_feed"}),{togglePlay:g,isPlaying:x,isActive:b}=f({uri:o}),v=(0,y.EC)(d.context?.uri),C=v?.type,E=(0,a.useCallback)((()=>{g(),c({intent:x?"pause":"play",type:"click",itemIdSuffix:"buddyfeed_play",targetUri:o});const e=i.friendRowFactory().playButtonFactory();b?x?l.logInteraction(e.hitPause({itemToBePaused:o})):l.logInteraction(e.hitResume({itemToBeResumed:o})):l.logInteraction(e.hitPlay({itemToBePlayed:o}))}),[g,c,x,o,i,b,l]),M=(0,a.useCallback)(((e,s)=>{l.logInteraction(i.friendRowFactory().friendRowLinkFactory({identifier:e}).hitUiNavigate({destination:s}))}),[l,i]),_=(0,D.O)([o],d.name),B=(0,D.O)([d.artist?.uri],d.artist?.name),U=(0,D.O)([d.context?.uri],d.context?.name);return s?(0,P.jsxs)("div",{className:j()(J),children:[(0,P.jsx)(O._,{menu:ge(d.context?.uri,d.artist?.uri),children:(0,P.jsxs)("div",{className:Z,children:[(0,P.jsx)(N.q,{label:t.user.name,width:40,userIconSize:16,images:n,withBadge:fe(t.timestamp)}),(0,P.jsx)(w.I,{className:K,iconClassName:H,isPlaying:x,isLocked:!1,onClick:E,playAriaLabel:x?r.ag.get("pause"):`${r.ag.get("play")} ${d.artist.name} ${d.name}`})]})}),(0,P.jsxs)("div",{className:j()(q),children:[(0,P.jsxs)("div",{className:W,children:[(0,P.jsx)(p.D,{as:"p",variant:"mestoBold",className:j()(Q,"ellipsis-one-line"),children:(0,P.jsx)(F.ZP,{value:"/buddyfeed_user_profile",children:(0,P.jsx)(O._,{menu:(0,P.jsx)(L.I,{uri:t.user.uri}),children:(0,P.jsx)(S.Link,{title:t.user.name,to:t.user.uri,dir:"auto",onClick:()=>M("profile_link",t.user.uri),children:t.user.name})})})}),(0,P.jsx)(p.D,{as:"p",variant:"finale",className:j()(V),children:(0,P.jsx)(z,{timestamp:t.timestamp,isNowPlaying:fe(t.timestamp)})})]}),(0,P.jsxs)(p.D,{as:"p",variant:"finale",className:G,children:[(0,P.jsx)(F.ZP,{value:"/buddyfeed_track",children:(0,P.jsx)(O._,{menu:(0,P.jsx)(I.$,{uri:d.uri,contextUri:d.context?.uri,albumUri:d.album?.uri,artists:[d.artist]}),children:(0,P.jsx)(S.Link,{title:d.name,to:o,className:"ellipsis-one-line",dir:"auto",draggable:!0,onDragStart:_,onClick:()=>M("track_link",o),children:d.name})})}),(0,P.jsx)("span",{"aria-hidden":!0,children:" • "}),(0,P.jsx)(F.ZP,{value:"/buddyfeed_artist",children:(0,P.jsx)(O._,{menu:d.artist?(0,P.jsx)(k.m,{uri:d.artist.uri}):null,children:(0,P.jsx)(S.Link,{title:d.artist?.name,to:d.artist?.uri,className:"ellipsis-one-line",dir:"auto",draggable:!0,onDragStart:B,onClick:()=>M("artist_link",d.artist?.uri),children:d.artist?.name})})})]}),(0,P.jsx)(p.D,{as:"p",variant:"finale",className:j()("ellipsis-one-line",$),children:(0,P.jsx)(F.ZP,{value:"/buddyfeed_context",children:(0,P.jsx)(O._,{menu:ge(d.context?.uri,d.artist?.uri),children:(0,P.jsxs)(S.Link,{title:d.context?.name,to:d.context?.uri,className:ee,draggable:!0,onDragStart:U,onClick:()=>M("context_link",d.context?.uri),children:[(0,P.jsx)(T.t,{type:he(C),iconSize:16,className:X}),(0,P.jsx)("span",{dir:"auto",className:"ellipsis-one-line",children:d.context?.name})]})})})})]})]},t.user.uri):null},be=100;function je({friends:e,spec:s}){return(0,P.jsx)(x.U5,{flipKey:e.map((e=>e.user.uri)).join(""),children:(0,P.jsx)("ol",{children:e.map(((e,i)=>(0,P.jsx)(x.$3,{flipId:e.user.uri,children:(0,P.jsx)("li",{children:(0,P.jsx)(xe,{friend:e,show:i<be,spec:s},e.user.uri)})},e.user.uri)))})})}var pe=i(22991),ye=i(79475),Ne=i(67176),ve=i(3254),ke=i(58706),Ce=i(85830),Ee=i(48710),Ie=i(83680),Le=i(75362),Se=i(43097),we=i(8951);const De="w5nHQ74JGTytKwWanjvB",Oe="u11kJflcqt7CSXo9qL_T",Te="MmENkh6tW0MyjTtTtPHZ",Fe="Gl0dkNQbAyNjVZ1IpghI",Ae=({name:e,following:s,imageUrl:i,uri:n})=>{const c=(0,Se.q)(),l=(0,u.o)(),d=a.createRef(),[o,m]=(0,a.useState)(s);(0,we.d)(Le.rA.OPERATION_COMPLETE,(e=>{if(e.data.uris.includes(n))switch(e.data.operation){case Le.BM.FOLLOW_USER:m(!0);break;case Le.BM.UNFOLLOW_USER:m(!1)}}));const g=(0,a.useCallback)((()=>{o?c.unfollowUsers([n]):(c.followUsers([n]),l({intent:"follow",type:"click",itemIdSuffix:"buddyfeed"})),d.current&&d.current.blur()}),[o,d,n,c,l]);return(0,a.useEffect)((()=>{m(s)}),[s]),(0,P.jsxs)("div",{className:De,children:[(0,P.jsx)(N.q,{label:e,width:40,userIconSize:16,images:(0,a.useMemo)((()=>[{width:40,height:40,url:i}]),[i])}),(0,P.jsxs)("div",{className:j()(Oe,"ellipsis-one-line"),children:[(0,P.jsx)(p.D,{as:"p",variant:"mestoBold",className:"ellipsis-one-line",children:e}),o&&(0,P.jsx)(p.D,{as:"p",variant:"finale",className:"ellipsis-one-line",children:r.ag.get("following")})]}),(0,P.jsx)("div",{className:Te,children:(0,P.jsx)(f.E,{className:Fe,size:"sm",ref:d,onClick:g,ariaLabel:o?r.ag.get("buddy-feed.button.remove-friend"):r.ag.get("buddy-feed.button.add-friend"),icon:o?Ie.k:t.t})})]})},Me={friendsList:"main-buddyFeed-friendsList"};function _e({facebookFriends:e}){return(0,P.jsx)("div",{className:Me.friendsList,children:e.map((({uri:e,following:s,title:i,image:a})=>(0,P.jsx)(Ae,{uri:e,name:i,imageUrl:a,following:s},`fb-friend-${e}`)))})}var Be=i(52052);const Ue={loadingFriends:"main-buddyFeed-loadingFriends"};function Pe(){return(0,P.jsx)("div",{className:Ue.loadingFriends,children:Array(20).fill(0).map(((e,s)=>(0,P.jsx)(Be.C,{isLoading:!0,charCount:100,as:"p",variant:"canon"},s)))})}var ze=i(9102),Je=i(76912);const Re="pZFwflwH1vXVCmAO5vbz",Ye="yPL55nV5rC97vJhAf7ke",Ze="qpgo9DQ9rVZbO5pLJog5",Ke="A3hvkJOGkBNa6zWj6oZa",He="pIyez6N1SF3jW0U5VUx4",qe="lIxuZR4lYTrEKkMYedty",We="VEmC3OHK3uAasHvO5OuA",Qe="wzGPtuvvLpOpY1PDu4Qv",Ve="YoJTUV4hazVCFNbfKoNq",Ge=({onBackButtonClick:e})=>{const[s,i]=(0,a.useState)(""),{isLoading:t,friends:n}=(e=>{const s=(0,Je.I)(),i=e.trim().toLowerCase(),{data:a,isLoading:t}=(0,ze.useQuery)("useFacebookFriends",(async()=>(await s.fetchFacebookFriends()).sort(((e,s)=>e.title>s.title?1:-1))));return{isLoading:t,friends:a?.filter((({title:e})=>-1!==e.trim().toLowerCase().indexOf(i)))??[]}})(s),c=(0,Ce.y1)((e=>{i(e.target.value)}),100),l=(0,a.useCallback)((e=>{null!==e&&e.focus()}),[]);return(0,P.jsxs)("div",{className:Re,children:[(0,P.jsx)(f.E,{ariaLabel:r.ag.get("buddy-feed.button.back"),onClick:e,ref:l,className:Ye,icon:pe.e,size:"sm",testId:"back-to-friends"}),(0,P.jsxs)("div",{className:Ze,children:[(0,P.jsx)("div",{className:Ke,children:(0,P.jsx)(Ne.z,{className:He,iconSize:32})}),(0,P.jsx)("div",{className:qe,children:t?(0,P.jsx)(Be.C,{isLoading:!0,charCount:25,as:"p",variant:"mesto"}):(0,P.jsx)(p.D,{as:"p",variant:"mesto",children:r.ag.get("buddy-feed.number-of-friends",n.length)})})]}),t?(0,P.jsx)(Pe,{}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)("div",{className:We,children:[(0,P.jsx)(Ee.j,{className:Ve,iconSize:16,role:"presentation"}),(0,P.jsx)("input",{onChange:c,className:Qe,placeholder:r.ag.get("buddy-feed.find-in-playlists")})]}),(0,P.jsx)(_e,{facebookFriends:n})]})]})};var Xe=i(51385);function $e({isOpen:e,onClose:s,onConfirm:i}){return(0,P.jsx)(Xe.Q,{onClose:s,"aria-label":r.ag.get("web-player.buddy-feed.connect-with-facebook-title"),onConfirm:i,titleText:r.ag.get("web-player.buddy-feed.connect-with-facebook-title"),descriptionText:r.ag.get("web-player.buddy-feed.connect-with-facebook-description"),cancelText:r.ag.get("queue.cancel-button"),confirmText:r.ag.get("web-player.buddy-feed.connect-button"),isOpen:e})}let es=function(e){return e[e.LOADING=0]="LOADING",e[e.CONNECTED=1]="CONNECTED",e[e.DISCONNECTED=2]="DISCONNECTED",e}({});const ss="EmZCbU1_B_J9RAHebolL",is="Ym6Yyx83U7mNKOMw9dxw",as="NXcZaSipzomJ6d4_nM94",ts="b9rqRkvRvhrSY4FYHQVC",ns="xHc_2FQr3NxfCgfDSVhY",rs="QAJYN0xWh3h2A5d8_C1g",cs="PKhH1CknobkjJdVITsb4",ls="HgRmCE3NxfiYNtv6pF3H",ds="HnA5mipUMkheAlbxqCn_",os="mvp0xhvZTo0xv0TIwi9u",us=e=>{const s=(0,u.o)(),{onBackButtonClick:i,feedIsEmpty:t,goToAddFriends:n=!1}=e,c=function(){const e=(0,Je.I)(),[s,i]=(0,a.useState)(es.LOADING);return(0,a.useEffect)((()=>e.subscribeToFacebookConnectionState((e=>{i(e.connection?es.CONNECTED:es.DISCONNECTED)})).cancel),[e]),s}(),l=(0,Je.I)(),[d,o]=(0,a.useState)(!1),[m,g]=(0,a.useState)(!1),[h,x]=(0,a.useState)(!1),b=(0,a.useCallback)((e=>{null!==e&&e.focus()}),[]),j=(0,a.useCallback)((()=>{location.reload()}),[]);if(m)return(0,P.jsxs)("div",{className:ds,children:[(0,P.jsx)(f.E,{onClick:i,ref:b,className:as,ariaLabel:r.ag.get("buddy-feed.button.back"),icon:pe.e,size:"sm"}),(0,P.jsxs)("div",{className:os,children:[(0,P.jsx)(p.D,{as:"h1",variant:"balladBold",className:is,children:r.ag.get("error-dialog.generic.header")}),(0,P.jsx)(p.D,{as:"p",variant:"mesto",className:ts,children:r.ag.get("error-dialog.generic.body")}),(0,P.jsx)(ye.D,{colorSet:"invertedLight",onClick:j,children:r.ag.get("error.reload")})]})]});const y=(n||h)&&c===es.CONNECTED;return(0,P.jsxs)("div",{className:ss,children:[y&&(0,P.jsx)(Ge,{onBackButtonClick:()=>{t&&x(!1),i()}}),!y&&(0,P.jsxs)("div",{className:rs,children:[(0,P.jsx)(f.E,{ariaLabel:r.ag.get("buddy-feed.button.back"),onClick:i,className:as,ref:b,icon:pe.e,size:"sm"}),(0,P.jsx)(p.D,{as:"h1",variant:"balladBold",className:is,children:r.ag.get("buddy-feed.friend-activity")}),(0,P.jsx)(p.D,{as:"p",variant:"mesto",className:ts,children:r.ag.get("buddy-feed.facebook.connect-with-friends-default")}),(0,P.jsx)("div",{className:cs,children:(0,P.jsx)(ye.D,{className:ls,buttonSize:"sm",iconLeading:Ne.z,UNSAFE_colorSet:(0,ve.Ev)("#2374E1",ke.$_Y.white),onClick:()=>{s({intent:"connect-to-facebook",type:"click",itemIdSuffix:"buddyfeed"}),c!==es.CONNECTED?o(!0):x(!0)},children:r.ag.get("buddy-feed.facebook.button")})}),(0,P.jsx)(p.D,{as:"p",variant:"finale",className:ns,children:r.ag.get("buddy-feed.facebook.disclaimer")}),(0,P.jsx)($e,{isOpen:d,onClose:()=>{o(!1)},onConfirm:()=>{l.connectToFacebook().then((()=>{x(!0),o(!1)})).catch((()=>{g(!0)}))}})]})]})};var ms=i(33103),fs=i(31925);const gs=({showOnlineIndicator:e})=>(0,P.jsxs)("div",{className:ne,children:[(0,P.jsxs)("div",{className:re,children:[(0,P.jsx)(fs.f,{iconSize:24}),e?(0,P.jsx)("div",{className:ce}):null]}),(0,P.jsxs)("div",{className:le,children:[(0,P.jsx)("div",{className:j()(de,oe)}),(0,P.jsx)("div",{className:de}),(0,P.jsx)("div",{className:de})]})]}),hs=()=>(0,P.jsxs)("div",{"data-testid":"buddy-feed-empty-state",className:ae,children:[(0,P.jsx)(p.D,{as:"p",className:te,children:r.ag.get("buddy-feed.let-followers-see-your-listening")}),(0,P.jsx)(gs,{showOnlineIndicator:!0}),(0,P.jsx)(gs,{showOnlineIndicator:!0}),(0,P.jsx)(gs,{}),(0,P.jsx)(p.D,{as:"p",className:te,children:r.ag.get("buddy-feed.enable-share-listening-activity")}),(0,P.jsx)(ms.rU,{to:"/preferences",className:ue,children:(0,P.jsx)(ye.D,{colorSet:"invertedLight",className:me,children:r.ag.get("desktop.settings.settings")})})]});var xs=i(91633),bs=i(49823);const js="jUF2eKgYMm64aYykubct",ps="zhL_lhJqzKfJVy7L5VuY",ys="XqquM_o2eODcnD8Y4QhS",Ns="UGtycHBJ4egymBSmD_lX",vs="ND2ydDPzwQZB7HyaGCN8",ks="D9YN554UFGJle2CPP1TA",Cs="v7Zcy9UKVUTDZIMKB6ZF",Es="RX3U6eAasqazEkuFdnj0",Is=({children:e,page:s})=>{const i=0===s,a=e.filter(((e,i)=>i!==s));return(0,P.jsx)(xs.Z,{component:null,children:a.map((e=>(0,P.jsx)(bs.Z,{in:i,timeout:500,classNames:{enter:i?js:vs,enterActive:i?ps:ks,exit:i?ys:Cs,exitActive:i?Ns:Es},children:e},i?"first-page":"second-page")))})};function Ls(e){return e.sort(((e,s)=>s.timestamp-e.timestamp))}function Ss(e,s){return s.some((s=>s.user.uri===e.user.uri))?s:Ls([...s,e])}function ws(e,s){return s.filter((s=>s.user.uri!==e))}function Ds(e){const s=(0,Je.I)(),[i,t]=(0,a.useState)(Ls(e)),{subscribeToFriend:n,unSubscribeFromFriend:r}=function(e,s){const i=(0,Je.I)(),t=(0,a.useRef)(e),n=(0,a.useRef)({}),r=(0,a.useRef)(s);r.current=s;const c=(0,a.useCallback)((e=>{const s=(0,y.EC)(e)?.username;return i.subscribeToBuddyActivity(s,(e=>{e&&r.current(e)}))}),[i]),l=(0,a.useCallback)((e=>{n.current[e]?.cancel(),delete n.current[e]}),[]);return(0,a.useEffect)((()=>{n.current=t.current.reduce(((e,s)=>{const i=s.user.uri,a=c(i);return e[i]=a,e}),{})}),[c]),(0,a.useEffect)((()=>{const e=n.current;return()=>{Object.values(e).forEach((e=>{e.cancel()}))}}),[]),{subscribeToFriend:c,unSubscribeFromFriend:l}}(e,(e=>{t((s=>function(e,s){return Ls(s.map((s=>s.user.uri===e.user.uri?e:s)))}(e,s)))}));return(0,we.d)(Le.rA.OPERATION_COMPLETE,(async e=>{const a=e.data.uris;if(e.data.operation!==Le.BM.FOLLOW_USER){if(e.data.operation===Le.BM.UNFOLLOW_USER)for(const e of a)i.find((s=>s.user.uri===e))&&(r(e),t((s=>ws(e,s))))}else for(const e of a)if(!i.find((s=>s.user.uri===e))){const i=(await s.fetchFriendActivity([e]))[0];t((e=>Ss(i,e))),n(e)}})),i}const Os=({initialFriends:e,className:s})=>{const i=(0,u.o)(),x=Ds(e),b=(0,h.$P)(),{spec:j}=(0,h.fU)(n.createDesktopFriendActivityEventFactory,{});(0,a.useEffect)((()=>{i({intent:"view",type:"impression",itemIdSuffix:"buddyfeed"})}),[i]);const[p,y]=(0,a.useState)(!1),N=()=>{p||b.logInteraction(j.addFriendButtonFactory().hitUiReveal()),y(!p)},v=0===x.length,k=(0,a.useCallback)((()=>{b.logInteraction(j.closeButtonFactory().hitUiHide())}),[b,j]);return(0,P.jsx)(g.DJ.Provider,{value:"buddy_feed",children:(0,P.jsx)(c.l,{label:r.ag.get("buddy-feed.friend-activity"),className:s,children:(0,P.jsxs)(Is,{page:p?1:0,children:[(0,P.jsx)("div",{className:R,children:(0,P.jsx)(us,{onBackButtonClick:N,feedIsEmpty:v,goToAddFriends:p})}),(0,P.jsx)("div",{className:Y,children:(0,P.jsxs)(l.K,{children:[(0,P.jsx)(d.V,{title:r.ag.get("buddy-feed.friend-activity"),panel:o.s.BuddyFeed,onClose:k,actions:(0,P.jsx)(m._,{label:r.ag.get("buddy-feed.add-friends"),children:(0,P.jsx)(f.E,{ariaLabel:r.ag.get("buddy-feed.add-friends"),testId:"add-friends-button",size:"sm",onClick:N,icon:t.t})})}),(0,P.jsx)("div",{className:se,children:(0,P.jsx)(f.E,{ariaLabel:r.ag.get("buddy-feed.add-friends"),className:ie,size:"sm",onClick:N,icon:t.t})}),v?(0,P.jsx)(hs,{}):(0,P.jsx)(je,{friends:x,spec:j})]})})]})})})}}}]);
//# sourceMappingURL=xpui-routes-buddy-feed.js.map