sample wip
This commit is contained in:
1 parent
ffc023f419
commit
c99b148e15
6 files changed
+26
-18
No files matched your search
+1
-2
@@ -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 {
|
||||
|
||||
+8
-5
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user