diff --git a/api/src/offers.ts b/api/src/offers.ts index 0c50026..4639f9e 100644 --- a/api/src/offers.ts +++ b/api/src/offers.ts @@ -134,8 +134,7 @@ export default function createOffers(log: Log, pg: Pg) { async function samples() { const user = await pg.userFindEmail('ntr@mnml.gg'); const offerGroups = await userOffers(user); - const i = Math.floor(Math.random() * offerGroups.length / 2); - return offerGroups[i]; + return offerGroups.slice(0, 1); } return { diff --git a/api/src/rpc.ts b/api/src/rpc.ts index 3bb4d5a..a8b9490 100644 --- a/api/src/rpc.ts +++ b/api/src/rpc.ts @@ -112,18 +112,21 @@ export default function createRpc(log: Log, pg: Pg, ws, discogs: Discogs, offers throw new Error(`Invalid parameters for message type ${msgType}: ${JSON.stringify(message)}`); } + async function anonConnection() { + const samples = await offers.samples(); + const sampleMsg: OfferSamplesMessage = [RpcMessageType.OfferSamples, samples]; + send(sampleMsg); + } + async function onConnection() { + if (!user) return anonConnection(); + const userMsg: UserMessage = [RpcMessageType.User, user]; send(userMsg); const wants = await pg.userWants(user); const wantsMsg: WantsMessage = [RpcMessageType.Wants, wants]; send(wantsMsg); - - const samples = await offers.samples(); - const sampleMsg: OfferSamplesMessage = [RpcMessageType.OfferSamples, samples]; - // console.log(samples); - send(sampleMsg); } function send(msg: RpcMessage) { diff --git a/client/src/routes/login.tsx b/client/src/routes/login.tsx index 0dca412..2b0aa41 100644 --- a/client/src/routes/login.tsx +++ b/client/src/routes/login.tsx @@ -6,6 +6,7 @@ import { useSelector, useDispatch } from 'react-redux' import http from './../http'; import { State, userState } from './../store'; import Swirl from './../components/swirl'; +import OfferGroup from './../components/offer.group'; const Login = ({ mode }) => { const dispatch = useDispatch() @@ -94,14 +95,20 @@ const Login = ({ mode }) => { }; function LoginPage({ mode }) { + const offers = useSelector((state: State) => state.offers); + return (
Mates Crates is a record importing service.
-We bundle orders together from thousands of online stores to reduce the cost of shipping vinyl.
-Based in Preston.
+We bundle orders together from thousands of online stores to reduce the cost of shipping vinyl.
+Based in Preston.
+