nicer toasts and fix some discogs sync problems

This commit is contained in:
ntr committed 2023-02-07 22:11:38 +11:00
1 parent 1ca9a7225c
commit c6bf50f963
7 files changed
+50 -26

No files matched your search

+3 -3
View File
@@ -26,7 +26,7 @@ model Listing {
offers Offer[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now())
@@index([seller])
@@map("listings")
@@ -38,7 +38,7 @@ model User {
password String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now())
wants Want[]
offers Offer[]
@@ -55,7 +55,7 @@ model Want {
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
updatedAt DateTime @default(now())
listings Listing[]
offers Offer[]
+3 -1
View File
@@ -29,8 +29,9 @@ export default function createApi(log: Log, pg: Pg, discogs: Discogs, offers: Of
const app = koaWebsocket(new koa());
// @ts-ignore - ts don't know wtf it talking about
BigInt.prototype.toJSON = function bigIntStringify() {
return this.toString();
return this.toString();
};
app.use(async (ctx, next) => {
@@ -71,6 +72,7 @@ export default function createApi(log: Log, pg: Pg, discogs: Discogs, offers: Of
router.post('/want/discogs', async function wantListPost(ctx, next) {
ctx.assert(ctx.isAuthenticated(), 401, 'log in required');
const { username } = ctx.request.body;
ctx.assert(username, 'no username supplied');
const user = await pg.userFindId(ctx.state.user.id);
const wants = await discogs.wantListSync(username, user);
events.emit(Events.WantsAdded, wants);
+4 -8
View File
@@ -109,14 +109,10 @@ export default function createDiscogs(log: Log, pg: Pg) {
const listing = await pg.listingFind(id);
if (listing) return listing;
try {
log.debug('fetching listing', id);
const res = await api.get(`${apiBase}/marketplace/listings/${id}`);
log.debug(res.data);
return pg.listingUpsert(res.data, want);
} catch (e) {
return handleApiError(e);
}
log.debug('fetching listing', id);
const res = await api.get(`${apiBase}/marketplace/listings/${id}`);
log.debug(res.data);
return pg.listingUpsert(res.data, want);
}
return {