DEV: Remove cache option from ajax() (#13142)

1. It defaults to `cache: true` already
2. Setting it to `false` for non-GET request doesn't do anything
3. We were correcting `cache: false` GET requests to use `cache: true`

…so setting it to anything at all, for any type of request doesn't make sense (anymore)
This commit is contained in:
Jarek Radosz 2021-05-31 14:41:35 +02:00 committed by GitHub
parent ccbe3bea79
commit e06a206131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 23 additions and 44 deletions

View File

@ -366,7 +366,7 @@ export default Component.extend({
},
_buildPayload(facets) {
let payload = { data: { cache: true, facets } };
let payload = { data: { facets } };
if (this.startDate) {
payload.data.start_date = moment(this.startDate)

View File

@ -162,10 +162,6 @@ export function ajax() {
args.headers["Discourse-Script"] = true;
}
if (args.type === "GET" && args.cache !== true) {
args.cache = true; // Disable JQuery cache busting param, which was created to deal with IE8
}
ajaxObj = $.ajax(getURL(url), args);
}

View File

@ -33,7 +33,6 @@ function searchTags(term, categories, limit) {
function () {
oldSearch = $.ajax(getURL("/tags/filter/search"), {
type: "GET",
cache: true,
data: { limit: limit, q },
});

View File

@ -99,7 +99,6 @@ export default function loadScript(url, opts) {
ajax({
url: fullUrl,
dataType: "text",
cache: true,
}).then(cb);
} else {
// Always load JavaScript with script tag to avoid Content Security Policy inline violations

View File

@ -156,7 +156,6 @@ export default class {
ajax("/topics/timings", {
data,
cache: false,
type: "POST",
headers: {
"X-SILENCE-LOGGER": "true",

View File

@ -141,7 +141,7 @@ const Bookmark = RestModel.extend({
url += "?" + $.param(params);
}
return ajax(url, { cache: "false" });
return ajax(url);
},
loadMore(additionalParams) {

View File

@ -172,7 +172,6 @@ const Post = RestModel.extend({
return ajax(`/posts/${this.id}/recover`, {
type: "PUT",
cache: false,
})
.then((data) => {
this.setProperties({

View File

@ -66,7 +66,7 @@ export default RestModel.extend({
this.set("loading", true);
return ajax(findUrl, { cache: "false" })
return ajax(findUrl)
.then((result) => {
if (result && result.no_results_help) {
this.set("noContentHelp", result.no_results_help);

View File

@ -50,7 +50,7 @@ export default EmberObject.extend({
this.set("loading", true);
return ajax(this.url, { cache: false })
return ajax(this.url)
.then((result) => {
if (result) {
const posts = result.map((post) => UserAction.create(post));

View File

@ -100,7 +100,7 @@ export default RestModel.extend({
}
this.set("loading", true);
return ajax(findUrl, { cache: "false" })
return ajax(findUrl)
.then((result) => {
if (result && result.no_results_help) {
this.set("noContentHelp", result.no_results_help);

View File

@ -524,27 +524,23 @@ const User = RestModel.extend({
loadUserAction(id) {
const stream = this.stream;
return ajax(`/user_actions/${id}.json`, { cache: "false" }).then(
(result) => {
if (result && result.user_action) {
const ua = result.user_action;
return ajax(`/user_actions/${id}.json`).then((result) => {
if (result && result.user_action) {
const ua = result.user_action;
if (
(this.get("stream.filter") || ua.action_type) !== ua.action_type
) {
return;
}
if (!this.get("stream.filter") && !this.inAllStream(ua)) {
return;
}
ua.title = emojiUnescape(escapeExpression(ua.title));
const action = UserAction.collapseStream([UserAction.create(ua)]);
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
stream.get("content").insertAt(0, action[0]);
if ((this.get("stream.filter") || ua.action_type) !== ua.action_type) {
return;
}
if (!this.get("stream.filter") && !this.inAllStream(ua)) {
return;
}
ua.title = emojiUnescape(escapeExpression(ua.title));
const action = UserAction.collapseStream([UserAction.create(ua)]);
stream.set("itemsLoaded", stream.get("itemsLoaded") + 1);
stream.get("content").insertAt(0, action[0]);
}
);
});
},
inAllStream(ua) {

View File

@ -29,7 +29,6 @@ function reportToLogster(name, error) {
Ember.$.ajax(getURL("/logs/report_js_error"), {
data,
type: "POST",
cache: false,
});
}

View File

@ -63,24 +63,18 @@ createWidgetFrom(QuickAccessPanel, "quick-access-bookmarks", {
},
loadBookmarksWithReminders() {
return ajax(`/u/${this.currentUser.username}/bookmarks.json`, {
cache: "false",
}).then((result) => {
result = result.user_bookmark_list;
return result.bookmarks;
});
return ajax(`/u/${this.currentUser.username}/bookmarks.json`).then(
({ user_bookmark_list }) => user_bookmark_list.bookmarks
);
},
loadUserActivityBookmarks() {
return ajax("/user_actions.json", {
cache: "false",
data: {
username: this.currentUser.username,
filter: UserAction.TYPES.bookmarks,
no_results_help_key: "user_activity.no_bookmarks",
},
}).then(({ user_actions }) => {
return user_actions;
});
}).then(({ user_actions }) => user_actions);
},
});

View File

@ -71,7 +71,6 @@ function loadNext(ajax) {
category_id: categoryId,
topic_id: topicId,
},
cache: true,
})
.then(
(html) => {

View File

@ -11,7 +11,6 @@ export default Mixin.create({
searchTags(url, data, callback) {
return ajax(getURL(url), {
quietMillis: 200,
cache: true,
dataType: "json",
data,
})