diff --git a/backend/src/tools/snippets/routes.js b/backend/src/tools/snippets/routes.js index f36b9ac..7e5b5f5 100644 --- a/backend/src/tools/snippets/routes.js +++ b/backend/src/tools/snippets/routes.js @@ -27,7 +27,16 @@ router.get('/', authenticate, (req, res) => { ORDER BY s.updated_at DESC `).all(me).map(enrich); - res.json({ own, shared }); + const sharedByMe = db.prepare(` + SELECT s.*, u.username as shared_with_name + FROM snippets s + JOIN snippet_shares sh ON sh.snippet_id=s.id + JOIN users u ON u.id=sh.shared_with + WHERE s.user_id=? + ORDER BY s.title ASC + `).all(me).map(enrich); + + res.json({ own, shared, sharedByMe }); }); // ── Einzelnes Snippet ──────────────────────────────────────────────────────── diff --git a/frontend/src/tools/codeschnipsel.jsx b/frontend/src/tools/codeschnipsel.jsx index 75b16da..c17a01c 100644 --- a/frontend/src/tools/codeschnipsel.jsx +++ b/frontend/src/tools/codeschnipsel.jsx @@ -96,76 +96,123 @@ function SnippetShareModal({ snippet, onClose, toast }) { ); } -// ── History Modal ───────────────────────────────────────────────────────────── +// ── Simple Diff ─────────────────────────────────────────────────────────────── +function DiffView({ oldCode, newCode }) { + if (!oldCode) return ( +
+ {newCode}
+
+ );
+ const oldLines = oldCode.split('\n');
+ const newLines = newCode.split('\n');
+ const maxLen = Math.max(oldLines.length, newLines.length);
+ const rows = [];
+ for (let i = 0; i < maxLen; i++) {
+ const o = oldLines[i];
+ const n = newLines[i];
+ if (o === n) {
+ rows.push({ type:'same', text: n ?? '' });
+ } else {
+ if (o !== undefined) rows.push({ type:'del', text: o });
+ if (n !== undefined) rows.push({ type:'add', text: n });
+ }
+ }
+ return (
+