mirror of
https://github.com/discourse/discourse.git
synced 2025-02-20 11:48:26 -06:00
Merge pull request #193 from tms/timing-is-everything
Make topic lists show last activity more intuitively
This commit is contained in:
commit
0bcd142a81
@ -127,11 +127,6 @@ Discourse.Topic = Discourse.Model.extend({
|
|||||||
return this.get('archetype') === 'private_message';
|
return this.get('archetype') === 'private_message';
|
||||||
}).property('archetype'),
|
}).property('archetype'),
|
||||||
|
|
||||||
// Does this topic only have a single post?
|
|
||||||
singlePost: (function() {
|
|
||||||
return this.get('posts_count') === 1;
|
|
||||||
}).property('posts_count'),
|
|
||||||
|
|
||||||
toggleStatus: function(property) {
|
toggleStatus: function(property) {
|
||||||
this.toggleProperty(property);
|
this.toggleProperty(property);
|
||||||
return $.post("" + (this.get('url')) + "/status", {
|
return $.post("" + (this.get('url')) + "/status", {
|
||||||
|
@ -38,16 +38,16 @@
|
|||||||
|
|
||||||
<td class='num'>{{number views numberKey="views_long"}}</td>
|
<td class='num'>{{number views numberKey="views_long"}}</td>
|
||||||
|
|
||||||
{{#if singlePost}}
|
{{#if bumped}}
|
||||||
<td class='num activity'>
|
|
||||||
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
{{else}}
|
|
||||||
<td class='num activity'>
|
<td class='num activity'>
|
||||||
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
|
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class='num activity last'>
|
<td class='num activity last'>
|
||||||
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate last_posted_at}}}'>{{{last_post_age}}}</a>
|
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{{bumped_age}}}</a>
|
||||||
</td>
|
</td>
|
||||||
|
{{else}}
|
||||||
|
<td class='num activity'>
|
||||||
|
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -25,18 +25,18 @@
|
|||||||
|
|
||||||
<td class='num'>{{number views numberKey="views_long"}}</td>
|
<td class='num'>{{number views numberKey="views_long"}}</td>
|
||||||
|
|
||||||
{{#if singlePost}}
|
{{#if bumped}}
|
||||||
<td class='num activity'>
|
|
||||||
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
{{else}}
|
|
||||||
<td class='num activity'>
|
<td class='num activity'>
|
||||||
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
|
<a href="{{url}}" {{{bindAttr class=":age ageCold"}}} title='{{i18n first_post}}: {{{unboundDate created_at}}}' >{{{age}}}</a>
|
||||||
</td>
|
</td>
|
||||||
<td class='num activity last'>
|
<td class='num activity last'>
|
||||||
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate last_posted_at}}}'>{{{last_post_age}}}</a>
|
<a href="{{lastPostUrl}}" class='age' title='{{i18n last_post}}: {{{unboundDate bumped_at}}}'>{{{bumped_age}}}</a>
|
||||||
</td>
|
</td>
|
||||||
|
{{else}}
|
||||||
|
<td class='num activity'>
|
||||||
|
<a href="{{url}}" class='age' title='{{i18n first_post}}: {{{unboundDate created_at}}}'>{{{age}}}</a>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{/group}}
|
{{/group}}
|
||||||
|
@ -8,6 +8,9 @@ class ListableTopicSerializer < BasicTopicSerializer
|
|||||||
:image_url,
|
:image_url,
|
||||||
:created_at,
|
:created_at,
|
||||||
:last_posted_at,
|
:last_posted_at,
|
||||||
|
:bumped,
|
||||||
|
:bumped_at,
|
||||||
|
:bumped_age,
|
||||||
:age,
|
:age,
|
||||||
:unseen,
|
:unseen,
|
||||||
:last_read_post_number,
|
:last_read_post_number,
|
||||||
@ -18,6 +21,16 @@ class ListableTopicSerializer < BasicTopicSerializer
|
|||||||
def age
|
def age
|
||||||
AgeWords.age_words(Time.now - (object.created_at || Time.now))
|
AgeWords.age_words(Time.now - (object.created_at || Time.now))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def bumped
|
||||||
|
object.created_at < object.bumped_at
|
||||||
|
end
|
||||||
|
|
||||||
|
def bumped_age
|
||||||
|
return nil if object.bumped_at.blank?
|
||||||
|
AgeWords.age_words(Time.now - object.bumped_at)
|
||||||
|
end
|
||||||
|
alias include_bumped_age? :bumped
|
||||||
|
|
||||||
def seen
|
def seen
|
||||||
object.user_data.present?
|
object.user_data.present?
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
class SuggestedTopicSerializer < ListableTopicSerializer
|
class SuggestedTopicSerializer < ListableTopicSerializer
|
||||||
|
|
||||||
attributes :archetype, :like_count, :views, :last_post_age
|
attributes :archetype, :like_count, :views
|
||||||
has_one :category, embed: :objects
|
has_one :category, embed: :objects
|
||||||
|
|
||||||
def last_post_age
|
|
||||||
return nil if object.last_posted_at.blank?
|
|
||||||
AgeWords.age_words(Time.now - object.last_posted_at)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,7 +8,6 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||||||
:pinned,
|
:pinned,
|
||||||
:closed,
|
:closed,
|
||||||
:archived,
|
:archived,
|
||||||
:last_post_age,
|
|
||||||
:starred,
|
:starred,
|
||||||
:has_best_of,
|
:has_best_of,
|
||||||
:archetype
|
:archetype
|
||||||
@ -16,11 +15,6 @@ class TopicListItemSerializer < ListableTopicSerializer
|
|||||||
has_one :category
|
has_one :category
|
||||||
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
has_many :posters, serializer: TopicPosterSerializer, embed: :objects
|
||||||
|
|
||||||
def last_post_age
|
|
||||||
return nil if object.last_posted_at.blank?
|
|
||||||
AgeWords.age_words(Time.now - object.last_posted_at)
|
|
||||||
end
|
|
||||||
|
|
||||||
def starred
|
def starred
|
||||||
object.user_data.starred?
|
object.user_data.starred?
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user