Module 863922

3,591 characters · in e88ab87d81cf1642.js
Dependencies
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{$T:()=>A,Ay:()=>b,C6:()=>C,C7:()=>S,O$:()=>_,Oz:()=>E,sK:()=>I,s_:()=>y});var l=n(582128),i=n(435558),s=n.n(i),r=n(702841),a=n(636537),o=n(228366),u=n(913122),c=n(432371),d=n(597643),h=n(734057),m=n(927813),f=n(822074),p=n(652215);let g=30*m.A.Millis.SECOND;async function x(e,t){let n,l;if(!f.A.shouldFetch(e,t))return;let i=Date.now();o.h.dispatch({type:"REQUEST_CHANNEL_SUMMARY",channelId:e,summaryId:t,requestedAt:i});try{let n=await a.Bo.get({url:p.BVt.CHANNEL_SUMMARY(e,t),rejectWithError:!1});l=n?.body}catch(e){n=new u.LG(e)}o.h.dispatch({type:"RECEIVE_CHANNEL_SUMMARY",channelId:e,summary:l,error:n,requestedAt:i,receivedAt:Date.now()})}async function A(e){let t,n;if(!f.A.shouldFetch(e))return;let l=Date.now();o.h.dispatch({type:"REQUEST_CHANNEL_SUMMARIES",channelId:e,requestedAt:l});try{n=await a.Bo.get({url:p.BVt.CHANNEL_SUMMARIES(e),rejectWithError:!1})}catch(e){t=new u.LG(e)}let i=n?.body?.summaries instanceof Array?n.body.summaries:n?.body??[];i=s().takeRight(i,75),o.h.dispatch({type:"RECEIVE_CHANNEL_SUMMARIES",channelId:e,summaries:i,error:t??void 0,requestedAt:l,receivedAt:Date.now()})}function C(e,t){o.h.dispatch({type:"SET_HIGHLIGHTED_SUMMARY",channelId:e,summaryId:t??null})}function E(){o.h.dispatch({type:"TOGGLE_TOPICS_BAR"})}function I(e,t){null!=e&&null!=t&&x(e,t),o.h.dispatch({type:"SET_SELECTED_SUMMARY",channelId:e,summaryId:t??null})}function y(e,t){o.h.dispatch({type:"UPDATE_VISIBLE_MESSAGES",topVisibleMessage:e??null,bottomVisibleMessage:t??null})}function S(e,t){o.h.dispatch({type:"SET_SUMMARY_FEEDBACK",summary:e,rating:t})}async function v(){let e,t;if(!f.A.shouldFetchChannelAffinities())return Promise.resolve(null);let n=Date.now();o.h.dispatch({type:"REQUEST_CHANNEL_AFFINITIES",requestedAt:n});try{t=await a.Bo.get({url:"/users/@me/affinities/channels",rejectWithError:!1})}catch(t){e=new u.LG(t)}let l=t?.body?.channel_affinities;o.h.dispatch({type:"RECEIVE_CHANNEL_AFFINITIES",affinities:l,error:e??void 0,requestedAt:n,receivedAt:Date.now()})}async function N(e){let t,n,{useQuickSwitcher:l=!0,useChannelAffinities:i=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=e??[];let s=Date.now();if(0===(e=e.concat(f.A.defaultChannelIds({withQuickSwitcher:l,withChannelAffinities:i})).filter(e=>{let t=h.A.getChannel(e);return(0,c.pk)(t,!1,!0)}).filter(e=>{let t=Date.now(),n=f.A.status(e);if(n?.fetching)return!1;let l=n?.lastReceivedAt;return null==l||t-l>g}).slice(0,50)).length)return Promise.resolve(null);o.h.dispatch({type:"REQUEST_CHANNEL_SUMMARIES_BULK",channelIds:e,requestedAt:s});try{n=await a.Bo.post({url:p.BVt.USER_SUMMARIES,body:{channel_ids:e},rejectWithError:!1})}catch(e){t=new u.LG(e)}let r=n?.body.summaries;o.h.dispatch({type:"RECEIVE_CHANNEL_SUMMARIES_BULK",requestedAt:s,receivedAt:Date.now(),summaries:r,requestArgs:{channelIds:e},error:t})}async function _(e){try{await a.Bo.del({url:p.BVt.CHANNEL_SUMMARY(e.channelId,e.id),rejectWithError:!1}),o.h.dispatch({type:"DELETE_SUMMARY",summary:e})}catch(e){throw new u.LG(e)}}let j=221552==n.j?{setSummaryFeedback:S,updateVisibleMessages:y,setSelectedSummary:I,setHighlightedSummary:C,fetchSummaries:A,fetchSummariesBulk:N,useChannelSummaries:function(e){let{channelIds:t=[]}=e;return!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=(0,r.bG)([d.A],()=>d.A.isConnected()),n=l.useMemo(()=>e.join(","),[e]);l.useEffect(()=>{t&&e();async function e(){try{await v()}catch(e){}await N(n.split(","))}},[n,t])}(t),(0,r.yK)([f.A],()=>f.A.topSummaries(),[])},deleteSummary:_}:null,b=221552==n.j?j:null}