Commit f6796afa2aa64a4b29be370cf2e10548f8745920
Set branch property in issue comment posts
Charles Lehner committed on 3/27/2016, 12:34:35 PMParent: d3c935772de1f3a9100852af7769cc9083245340
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -1211,8 +1211,9 @@ | ||
1211 | 1211 | /* Issue */ |
1212 | 1212 | |
1213 | 1213 | function serveRepoIssue(req, repo, issue, path) { |
1214 | 1214 | var isAuthor = (myId == issue.author) || (myId == repo.feed) |
1215 | + var newestMsg = {key: issue.id, value: {timestamp: issue.created_at}} | |
1215 | 1216 | return renderRepoPage(repo, null, cat([ |
1216 | 1217 | pull.once( |
1217 | 1218 | renderNameForm(!isPublic, issue.id, issue.title, 'issue-title', null, |
1218 | 1219 | 'Rename the issue', |
@@ -1245,8 +1246,10 @@ | ||
1245 | 1246 | var authorLink = link([msg.value.author], msg.authorName) |
1246 | 1247 | var msgTimeLink = link([msg.key], |
1247 | 1248 | new Date(msg.value.timestamp).toLocaleString()) |
1248 | 1249 | var c = msg.value.content |
1250 | + if (msg.value.timestamp > newestMsg.value.timestamp) | |
1251 | + newestMsg = msg | |
1249 | 1252 | switch (c.type) { |
1250 | 1253 | case 'post': |
1251 | 1254 | if (c.root == issue.id) { |
1252 | 1255 | var changed = issues.isStatusChanged(msg, issue) |
@@ -1279,9 +1282,13 @@ | ||
1279 | 1282 | '</section>' |
1280 | 1283 | } |
1281 | 1284 | }) |
1282 | 1285 | ), |
1283 | - pull.once(isPublic ? '' : '<section><form action="" method="post">' + | |
1286 | + isPublic ? pull.empty() : readOnce(renderCommentForm) | |
1287 | + ])) | |
1288 | + | |
1289 | + function renderCommentForm(cb) { | |
1290 | + cb(null, '<section><form action="" method="post">' + | |
1284 | 1291 | '<input type="radio" class="tab-radio" id="tab1" name="tab" checked="checked"/>' + |
1285 | 1292 | '<input type="radio" class="tab-radio" id="tab2" name="tab"/>' + |
1286 | 1293 | '<div class="tab-links">' + |
1287 | 1294 | '<label for="tab1" id="write-tab-link" class="tab1-link">Write</label>' + |
@@ -1289,8 +1296,9 @@ | ||
1289 | 1296 | '</div>' + |
1290 | 1297 | '<div id="write-tab" class="tab1">' + |
1291 | 1298 | '<input type="hidden" name="action" value="comment">' + |
1292 | 1299 | '<input type="hidden" name="id" value="' + issue.id + '">' + |
1300 | + '<input type="hidden" name="branch" value="' + newestMsg.key + '">' + | |
1293 | 1301 | '<textarea id="comment-text" name="text" class="wide-input" rows="4" cols="77"></textarea>' + |
1294 | 1302 | '</div>' + |
1295 | 1303 | '<div class="preview-text tab2" id="preview-tab">' + |
1296 | 1304 | '</div>' + |
@@ -1301,8 +1309,8 @@ | ||
1301 | 1309 | '/>' : '') + |
1302 | 1310 | '<input type="submit" class="btn open" value="Comment" />' + |
1303 | 1311 | '<script>' + issueCommentScript + '</script>' + |
1304 | 1312 | '</section></form>') |
1305 | - ])) | |
1313 | + } | |
1306 | 1314 | } |
1307 | 1315 | |
1308 | 1316 | } |
Built with git-ssb-web