diff options
| author | Patrick | 2025-03-24 00:20:50 +0100 |
|---|---|---|
| committer | Patrick | 2025-03-24 00:20:50 +0100 |
| commit | 4dcd5892e7db988893845b389abc4fd1a48d3fec (patch) | |
| tree | 7a40e719447e3acb96c9f707fae072fa687320f0 /src | |
| parent | a26fa9e137fb8693c595ca6a692181c8d4a402d7 (diff) | |
| download | chirp-4dcd5892e7db988893845b389abc4fd1a48d3fec.tar.gz chirp-4dcd5892e7db988893845b389abc4fd1a48d3fec.zip | |
Mark post lists/feeds to which this item has already been added
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.zig | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/main.zig b/src/main.zig index d7eec6c..6455207 100644 --- a/src/main.zig +++ b/src/main.zig @@ -620,7 +620,8 @@ fn write_post(res: *http.Response, txn: lmdb.Txn, logged_in: ?Login, post_id: Po while (it.next()) |kv| { const name = kv.val.name; const id = kv.val.list.idx.?; - try res.write("<option value=\"{x}\">{s}</option>", .{ id, name.constSlice() }); + const list_view = try kv.val.list.open(txn); + try res.write("<option value=\"{x}\">{s}{s}</option>", .{ id, name.constSlice(), if (list_view.has(post_id) catch false) " *" else "" }); } try res.write("</select>", .{}); try res.write("<input type=\"hidden\" name=\"post_id\" value=\"{x}\"></input>", .{@intFromEnum(post_id)}); @@ -700,7 +701,8 @@ fn write_profile(res: *http.Response, txn: lmdb.Txn, logged_in: ?Login, user: Us while (it.next()) |kv| { const name = kv.val.name; const id = kv.val.list.idx.?; - try res.write("<option value=\"{x}\">{s}</option>", .{ id, name.constSlice() }); + const list_view = try kv.val.list.open(txn); + try res.write("<option value=\"{x}\">{s}{s}</option>", .{ id, name.constSlice(), if (list_view.has(user.id) catch false) " *" else "" }); } try res.write("</select>", .{}); try res.write("<input type=\"hidden\" name=\"user.id\" value=\"{x}\"></input>", .{@intFromEnum(user.id)}); @@ -1065,7 +1067,7 @@ const GET = struct { const name = kv.val.name; const post_list = kv.val.list; try self.res.write( - \\<a href="/list/{x}">{s}</a> + \\<a href="/list/{x}">{s}</a> , .{ post_list.idx.?, name.constSlice() }); try html_form(self.res, "/delete_list", .{ .{ "type=\"hidden\" name=\"list_id\" value=\"{x}\"", .{kv.key} }, @@ -1096,7 +1098,7 @@ const GET = struct { const name = kv.val.name; const user_list = kv.val.list; try self.res.write( - \\<a href="/feed/{x}">{s}</a> + \\<a href="/feed/{x}">{s}</a> , .{ user_list.idx.?, name.constSlice() }); try html_form(self.res, "/delete_feed", .{ .{ "type=\"hidden\" name=\"list_id\" value=\"{x}\"", .{kv.key} }, |
