link to first unread as opposed to last read in topic lists
This commit is contained in:
parent
1d74cc60a1
commit
4b0a1179e9
|
@ -32,7 +32,7 @@ Handlebars.registerHelper('topicLink', function(property, options) {
|
||||||
var title, topic;
|
var title, topic;
|
||||||
topic = Ember.Handlebars.get(this, property, options);
|
topic = Ember.Handlebars.get(this, property, options);
|
||||||
title = topic.get('fancy_title') || topic.get('title');
|
title = topic.get('fancy_title') || topic.get('title');
|
||||||
return "<a href='" + (topic.get('lastReadUrl')) + "' class='title'>" + title + "</a>";
|
return "<a href='" + (topic.get('lastUnreadUrl')) + "' class='title'>" + title + "</a>";
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -78,6 +78,11 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
return this.urlForPostNumber(this.get('last_read_post_number'));
|
return this.urlForPostNumber(this.get('last_read_post_number'));
|
||||||
}.property('url', 'last_read_post_number'),
|
}.property('url', 'last_read_post_number'),
|
||||||
|
|
||||||
|
lastUnreadUrl: function() {
|
||||||
|
var postNumber = Math.min(this.get('last_read_post_number') + 1, this.get('highest_post_number'));
|
||||||
|
return this.urlForPostNumber(postNumber);
|
||||||
|
}.property('url', 'last_read_post_number', 'highest_post_number'),
|
||||||
|
|
||||||
lastPostUrl: function() {
|
lastPostUrl: function() {
|
||||||
return this.urlForPostNumber(this.get('highest_post_number'));
|
return this.urlForPostNumber(this.get('highest_post_number'));
|
||||||
}.property('url', 'highest_post_number'),
|
}.property('url', 'highest_post_number'),
|
||||||
|
@ -86,8 +91,9 @@ Discourse.Topic = Discourse.Model.extend({
|
||||||
// tells us if we are still asynchronously flushing our "recently read" data.
|
// tells us if we are still asynchronously flushing our "recently read" data.
|
||||||
// So take what the browser has seen into consideration.
|
// So take what the browser has seen into consideration.
|
||||||
displayNewPosts: function() {
|
displayNewPosts: function() {
|
||||||
var delta, highestSeen, result;
|
var delta, result;
|
||||||
if (highestSeen = Discourse.Session.currentProp('highestSeenByTopic')[this.get('id')]) {
|
var highestSeen = Discourse.Session.currentProp('highestSeenByTopic')[this.get('id')];
|
||||||
|
if (highestSeen) {
|
||||||
delta = highestSeen - this.get('last_read_post_number');
|
delta = highestSeen - this.get('last_read_post_number');
|
||||||
if (delta > 0) {
|
if (delta > 0) {
|
||||||
result = this.get('new_posts') - delta;
|
result = this.get('new_posts') - delta;
|
||||||
|
|
|
@ -29,20 +29,20 @@
|
||||||
{{{topicLink this}}}
|
{{{topicLink this}}}
|
||||||
|
|
||||||
{{#if unread}}
|
{{#if unread}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if new_posts}}
|
{{#if new_posts}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if unseen}}
|
{{#if unseen}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if hasExcerpt}}
|
{{#if hasExcerpt}}
|
||||||
<div class="topic-excerpt">
|
<div class="topic-excerpt">
|
||||||
{{{excerpt}}}
|
{{{excerpt}}}
|
||||||
{{#if excerptTruncated}}
|
{{#if excerptTruncated}}
|
||||||
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
{{#unless canClearPin}}<a href="{{lastUnreadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if canClearPin}}
|
{{#if canClearPin}}
|
||||||
<a href="#" {{action clearPin this}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
<a href="#" {{action clearPin this}} title="{{unbound i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
||||||
|
|
|
@ -13,21 +13,21 @@
|
||||||
{{#groupedEach view.topics}}
|
{{#groupedEach view.topics}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class='main-link'>
|
<td class='main-link'>
|
||||||
<a class='title' href="{{unbound lastReadUrl}}">{{{unbound fancy_title}}}</a>
|
<a class='title' href="{{unbound lastUnreadUrl}}">{{{unbound fancy_title}}}</a>
|
||||||
{{#if unread}}
|
{{#if unread}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unbound unread}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if new_posts}}
|
{{#if new_posts}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="new_posts"}}'>{{unbound new_posts}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if unseen}}
|
{{#if unseen}}
|
||||||
<a href="{{unbound lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
<a href="{{unbound lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</td>
|
</td>
|
||||||
<td class='category'>
|
<td class='category'>
|
||||||
{{categoryLink category}}
|
{{categoryLink category}}
|
||||||
</td>
|
</td>
|
||||||
<td class='num posts'><a href="{{unbound lastReadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
<td class='num posts'><a href="{{unbound lastUnreadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
||||||
|
|
||||||
<td class='num likes'>
|
<td class='num likes'>
|
||||||
{{#if like_count}}
|
{{#if like_count}}
|
||||||
|
@ -52,4 +52,4 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{/groupedEach}}
|
{{/groupedEach}}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -19,20 +19,20 @@
|
||||||
{{topicStatus topic=this}}
|
{{topicStatus topic=this}}
|
||||||
{{{topicLink this}}}
|
{{{topicLink this}}}
|
||||||
{{#if unread}}
|
{{#if unread}}
|
||||||
<a href="{{lastReadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unread}}</a>
|
<a href="{{lastUnreadUrl}}" class='badge unread badge-notification' title='{{i18n topic.unread_posts count="unread"}}'>{{unread}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if displayNewPosts}}
|
{{#if displayNewPosts}}
|
||||||
<a href="{{lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="displayNewPosts"}}'>{{displayNewPosts}}</a>
|
<a href="{{lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new_posts count="displayNewPosts"}}'>{{displayNewPosts}}</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if unseen}}
|
{{#if unseen}}
|
||||||
<a href="{{lastReadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
<a href="{{lastUnreadUrl}}" class='badge new-posts badge-notification' title='{{i18n topic.new}}'><i class='icon icon-asterisk'></i></a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if hasExcerpt}}
|
{{#if hasExcerpt}}
|
||||||
<div class="topic-excerpt">
|
<div class="topic-excerpt">
|
||||||
{{excerpt}}
|
{{excerpt}}
|
||||||
{{#if excerptTruncated}}
|
{{#if excerptTruncated}}
|
||||||
{{#unless canClearPin}}<a href="{{lastReadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
{{#unless canClearPin}}<a href="{{lastUnreadUrl}}">{{i18n read_more}}</a>{{/unless}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if canClearPin}}
|
{{#if canClearPin}}
|
||||||
<a href="#" {{action clearPin this}} title="{{i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
<a href="#" {{action clearPin this}} title="{{i18n topic.clear_pin.help}}">{{i18n topic.clear_pin.title}}</a>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class='num posts'><a href="{{lastReadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
<td class='num posts'><a href="{{lastUnreadUrl}}" class='badge-posts'>{{number posts_count numberKey="posts_long"}}</a></td>
|
||||||
|
|
||||||
<td class='num likes'>
|
<td class='num likes'>
|
||||||
{{#if like_count}}
|
{{#if like_count}}
|
||||||
|
|
Loading…
Reference in New Issue