From e301e2184c8bbd6b87656860c8bcb0263bf5e226 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sat, 20 Mar 2021 00:12:12 +0100 Subject: [PATCH] Fixed undefined user ID in postgres function. Fixed and improved mobile alignment for new and stash icons on scene tile. --- assets/components/releases/scene-tile.vue | 10 ++++++++-- migrations/20190325001339_releases.js | 3 ++- src/web/postgraphile.js | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/components/releases/scene-tile.vue b/assets/components/releases/scene-tile.vue index 8ece43b1..4ad9d425 100644 --- a/assets/components/releases/scene-tile.vue +++ b/assets/components/releases/scene-tile.vue @@ -204,7 +204,7 @@ export default { width: 1rem; height: 1rem; box-sizing: border-box; - padding: .375rem .25rem; + margin: .25rem; border-radius: 0 0 .5rem 0; color: var(--primary); font-size: 1rem; @@ -434,7 +434,13 @@ export default { .tile.new .poster::after { bottom: 0; top: auto; - border-radius: 0 .5rem 0 0; + margin: 0 .25rem; + } + + .stash { + left: 0; + right: auto; + padding: .25rem .5rem .5rem .25rem; } } diff --git a/migrations/20190325001339_releases.js b/migrations/20190325001339_releases.js index 6903bbb5..c1b07742 100644 --- a/migrations/20190325001339_releases.js +++ b/migrations/20190325001339_releases.js @@ -1157,7 +1157,8 @@ exports.up = knex => Promise.resolve() // allow vim fold return knex.raw(` CREATE FUNCTION current_user_id() RETURNS INTEGER AS $$ - SELECT current_setting('user.id', true)::integer; + /* if the user ID is undefined, the adapter will pass it as a string, which cannot be cast as NULL by ::integer */ + SELECT NULLIF(current_setting('user.id', true), '')::integer; $$ LANGUAGE SQL STABLE; /* We need both the release entries and their search ranking, and PostGraphile does not seem to allow virtual foreign keys on function results. diff --git a/src/web/postgraphile.js b/src/web/postgraphile.js index 8b185958..331ed9e5 100644 --- a/src/web/postgraphile.js +++ b/src/web/postgraphile.js @@ -14,7 +14,7 @@ const connectionString = `postgres://${config.database.query.user}:${config.data async function pgSettings(req) { return { - 'user.id': req.session.user?.id, + 'user.id': req.session.user?.id || null, // undefined is passed as an empty string, avoid }; }