mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 15:28:37 -05:00
submit_text: Solve race condition issues by aborting old requests.
This commit is contained in:
@@ -634,7 +634,10 @@ r.ui.SubredditSubmitText = Backbone.View.extend({
|
||||
var sr = this.$input.val()
|
||||
this.$sr.text(sr)
|
||||
this.$el.addClass('working')
|
||||
this.cache.ajax(sr, {
|
||||
if (this.req && this.req.abort) {
|
||||
this.req.abort()
|
||||
}
|
||||
this.req = this.cache.ajax(sr, {
|
||||
url: '/r/' + sr + '/api/submit_text/.json',
|
||||
dataType: 'json'
|
||||
}).done(_.bind(this.settext, this, sr))
|
||||
@@ -650,10 +653,12 @@ r.ui.SubredditSubmitText = Backbone.View.extend({
|
||||
},
|
||||
|
||||
error: function() {
|
||||
delete this.req
|
||||
this.hide()
|
||||
},
|
||||
|
||||
settext: function(sr, data) {
|
||||
delete this.req
|
||||
if (!data.submit_text || !data.submit_text.trim()) {
|
||||
this.hide()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user