diff --git a/src/server/types/Item.js b/src/server/types/Item.js index 343d447..58f13c5 100644 --- a/src/server/types/Item.js +++ b/src/server/types/Item.js @@ -1138,6 +1138,14 @@ const resolvers = { [itemId, userId, ownsOrWantsItems === "OWNS", listId, 1, now, now], ); + // Finally, touch the `updated_at` timestamp for the list. + await connection.query( + ` + UPDATE closet_lists SET updated_at = ? WHERE id = ? LIMIT 1; + `, + [now, listId], + ); + await connection.commit(); } catch (error) { try { @@ -1182,6 +1190,9 @@ const resolvers = { const connection = await db.getConnection(); try { await connection.beginTransaction(); + const now = new Date(); + + // First, remove the hanger from the list. await connection.query( ` DELETE FROM closet_hangers @@ -1190,6 +1201,16 @@ const resolvers = { [...listMatcherValues, itemId], ); + // Then, touch the `updated_at` timestamp for the list. + if (!closetListRef.isDefaultList) { + await connection.query( + ` + UPDATE closet_lists SET updated_at = ? WHERE id = ? LIMIT 1; + `, + [now, closetListRef.id], + ); + } + if (ensureInSomeList) { // If requested, we check whether the item is still in *some* list of // the same own/want type. If not, we add it to the default list. @@ -1202,7 +1223,6 @@ const resolvers = { ); if (rows[0].count === 0) { - const now = new Date(); await connection.query( ` INSERT INTO closet_hangers @@ -1221,6 +1241,8 @@ const resolvers = { } catch (error) { console.warn(`Error rolling back transaction`, error); } + + throw error; } finally { await connection.release(); }