FIX: Don't notify of duplicate links on edit of the first post
This commit is contained in:
parent
024c2e90c1
commit
df368ce251
|
@ -111,9 +111,13 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
afterRefresh($preview) {
|
afterRefresh($preview) {
|
||||||
|
const topic = this.get('model.topic');
|
||||||
const linkLookup = this.get('linkLookup');
|
const linkLookup = this.get('linkLookup');
|
||||||
if (linkLookup) {
|
if (!topic || !linkLookup) { return; }
|
||||||
|
|
||||||
|
// Don't check if there's only one post
|
||||||
|
if (topic.get('posts_count') === 1) { return; }
|
||||||
|
|
||||||
const post = this.get('model.post');
|
const post = this.get('model.post');
|
||||||
if (post && post.get('user_id') !== this.currentUser.id) { return; }
|
if (post && post.get('user_id') !== this.currentUser.id) { return; }
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ export default Ember.Controller.extend({
|
||||||
const body = I18n.t('composer.duplicate_link', {
|
const body = I18n.t('composer.duplicate_link', {
|
||||||
domain: info.domain,
|
domain: info.domain,
|
||||||
username: info.username,
|
username: info.username,
|
||||||
post_url: info.post_url,
|
post_url: topic.urlForPostNumber(info.post_number),
|
||||||
ago: relativeAge(moment(info.posted_at).toDate(), { format: 'medium' })
|
ago: relativeAge(moment(info.posted_at).toDate(), { format: 'medium' })
|
||||||
});
|
});
|
||||||
this.appEvents.trigger('composer-messages:create', {
|
this.appEvents.trigger('composer-messages:create', {
|
||||||
|
@ -140,7 +144,6 @@ export default Ember.Controller.extend({
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleWhisper() {
|
toggleWhisper() {
|
||||||
|
|
|
@ -16,8 +16,8 @@ export default class LinkLookup {
|
||||||
|
|
||||||
const linkInfo = this._links[normalized];
|
const linkInfo = this._links[normalized];
|
||||||
if (linkInfo) {
|
if (linkInfo) {
|
||||||
// Skip edits to the same URL
|
// Skip edits to the same post
|
||||||
if (post && post.get('url') === linkInfo.post_url) { return NO_RESULT; }
|
if (post && post.get('post_number') === linkInfo.post_number) { return NO_RESULT; }
|
||||||
|
|
||||||
_warned[href] = true;
|
_warned[href] = true;
|
||||||
_warned[normalized] = true;
|
_warned[normalized] = true;
|
||||||
|
|
|
@ -232,8 +232,8 @@ class TopicLink < ActiveRecord::Base
|
||||||
normalized = tl.url.downcase.sub(/^https?:\/\//, '').sub(/\/$/, '')
|
normalized = tl.url.downcase.sub(/^https?:\/\//, '').sub(/\/$/, '')
|
||||||
lookup[normalized] = { domain: tl.domain,
|
lookup[normalized] = { domain: tl.domain,
|
||||||
username: tl.post.user.username_lower,
|
username: tl.post.user.username_lower,
|
||||||
post_url: tl.post.url,
|
posted_at: tl.post.created_at,
|
||||||
posted_at: tl.post.created_at }
|
post_number: tl.post.post_number }
|
||||||
end
|
end
|
||||||
|
|
||||||
lookup
|
lookup
|
||||||
|
|
Loading…
Reference in New Issue