diff --git a/app/assets/javascripts/admin/mixins/penalty-controller.js.es6 b/app/assets/javascripts/admin/mixins/penalty-controller.js.es6 index 7be1ab97b24..cb07e9d2ca3 100644 --- a/app/assets/javascripts/admin/mixins/penalty-controller.js.es6 +++ b/app/assets/javascripts/admin/mixins/penalty-controller.js.es6 @@ -1,6 +1,7 @@ import ModalFunctionality from "discourse/mixins/modal-functionality"; import { popupAjaxError } from "discourse/lib/ajax-error"; import Mixin from "@ember/object/mixin"; +import { Promise } from "rsvp"; export default Mixin.create(ModalFunctionality, { reason: null, @@ -26,7 +27,7 @@ export default Mixin.create(ModalFunctionality, { penalize(cb) { let before = this.before; - let promise = before ? before() : Ember.RSVP.resolve(); + let promise = before ? before() : Promise.resolve(); return promise .then(() => cb()) diff --git a/app/assets/javascripts/admin/mixins/setting-component.js.es6 b/app/assets/javascripts/admin/mixins/setting-component.js.es6 index a8040a63ca3..762d5cfa2b3 100644 --- a/app/assets/javascripts/admin/mixins/setting-component.js.es6 +++ b/app/assets/javascripts/admin/mixins/setting-component.js.es6 @@ -5,6 +5,7 @@ import { on } from "@ember/object/evented"; import Mixin from "@ember/object/mixin"; import showModal from "discourse/lib/show-modal"; import AboutRoute from "discourse/routes/about"; +import { Promise } from "rsvp"; const CUSTOM_TYPES = [ "bool", @@ -112,7 +113,7 @@ export default Mixin.create({ Ember.warn("You should define a `_save` method", { id: "discourse.setting-component.missing-save" }); - return Ember.RSVP.resolve(); + return Promise.resolve(); }, actions: { diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6 index e99c84e0b42..880cb44c39b 100644 --- a/app/assets/javascripts/admin/models/admin-user.js.es6 +++ b/app/assets/javascripts/admin/models/admin-user.js.es6 @@ -6,6 +6,7 @@ import { propertyNotEqual } from "discourse/lib/computed"; import { popupAjaxError } from "discourse/lib/ajax-error"; import Group from "discourse/models/group"; import { userPath } from "discourse/lib/url"; +import { Promise } from "rsvp"; const wrapAdmin = user => (user ? AdminUser.create(user) : null); @@ -503,7 +504,7 @@ const AdminUser = Discourse.User.extend({ loadDetails() { if (this.loadedDetails) { - return Ember.RSVP.resolve(this); + return Promise.resolve(this); } return AdminUser.find(this.id).then(result => { diff --git a/app/assets/javascripts/admin/services/admin-tools.js.es6 b/app/assets/javascripts/admin/services/admin-tools.js.es6 index 38aa9e452de..bb5e1ac06a8 100644 --- a/app/assets/javascripts/admin/services/admin-tools.js.es6 +++ b/app/assets/javascripts/admin/services/admin-tools.js.es6 @@ -9,6 +9,7 @@ import { ajax } from "discourse/lib/ajax"; import showModal from "discourse/lib/show-modal"; import { getOwner } from "discourse-common/lib/get-owner"; import Service from "@ember/service"; +import { Promise } from "rsvp"; export default Service.extend({ init() { @@ -54,7 +55,7 @@ export default Service.extend({ controller.setProperties({ postId: opts.postId, postEdit: opts.postEdit }); return (user.adminUserView - ? Ember.RSVP.resolve(user) + ? Promise.resolve(user) : AdminUser.find(user.get("id")) ).then(loadedUser => { controller.setProperties({ @@ -78,7 +79,7 @@ export default Service.extend({ // Try loading the email if the site supports it let tryEmail = this.siteSettings.moderators_view_emails ? adminUser.checkEmail() - : Ember.RSVP.resolve(); + : Promise.resolve(); return tryEmail.then(() => { let message = I18n.messageFormat("flagging.delete_confirm_MF", { @@ -92,7 +93,7 @@ export default Service.extend({ let userId = adminUser.get("id"); - return new Ember.RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const buttons = [ { label: I18n.t("composer.cancel"), diff --git a/app/assets/javascripts/discourse-loader.js b/app/assets/javascripts/discourse-loader.js index d6f2171dd79..21034aa75a4 100644 --- a/app/assets/javascripts/discourse-loader.js +++ b/app/assets/javascripts/discourse-loader.js @@ -73,7 +73,13 @@ var define, requirejs; }, "@ember/utils": { isEmpty: Ember.isEmpty + }, + "rsvp": { + Promise: Ember.RSVP.Promise, + hash: Ember.RSVP.hash, + all: Ember.RSVP.all } + }; } diff --git a/app/assets/javascripts/discourse/components/d-editor.js.es6 b/app/assets/javascripts/discourse/components/d-editor.js.es6 index e839fad6c6f..3d926b97837 100644 --- a/app/assets/javascripts/discourse/components/d-editor.js.es6 +++ b/app/assets/javascripts/discourse/components/d-editor.js.es6 @@ -29,6 +29,7 @@ import { translations } from "pretty-text/emoji/data"; import { emojiSearch, isSkinTonableEmoji } from "pretty-text/emoji"; import { emojiUrlFor } from "discourse/lib/text"; import showModal from "discourse/lib/show-modal"; +import { Promise } from "rsvp"; // Our head can be a static string or a function that returns a string // based on input (like for numbered lists). @@ -453,7 +454,7 @@ export default Component.extend({ }, dataSource: term => { - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { const full = `:${term}`; term = term.toLowerCase(); diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 195df3baad0..df268122807 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -24,6 +24,7 @@ import { import { emojiUnescape } from "discourse/lib/text"; import { shortDate } from "discourse/lib/formatter"; import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer"; +import { Promise } from "rsvp"; function loadDraft(store, opts) { opts = opts || {}; @@ -801,7 +802,7 @@ export default Controller.extend({ composerModel = null; } - return new Ember.RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (composerModel && composerModel.replyDirty) { // If we're already open, we don't have to do anything if ( @@ -945,7 +946,7 @@ export default Controller.extend({ this.appEvents.trigger("draft:destroyed", key) ); } else { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } }, @@ -962,7 +963,7 @@ export default Controller.extend({ } if (_checkDraftPopup) { - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { bootbox.dialog(I18n.t("drafts.abandon.confirm"), [ { label: I18n.t("drafts.abandon.no_value"), @@ -988,7 +989,7 @@ export default Controller.extend({ const keyPrefix = this.model.action === "edit" ? "post.abandon_edit" : "post.abandon"; - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { if (this.get("model.hasMetaData") || this.get("model.replyDirty")) { bootbox.dialog(I18n.t(keyPrefix + ".confirm"), [ { diff --git a/app/assets/javascripts/discourse/controllers/grant-badge.js.es6 b/app/assets/javascripts/discourse/controllers/grant-badge.js.es6 index 8e88d41ad52..287b6a69942 100644 --- a/app/assets/javascripts/discourse/controllers/grant-badge.js.es6 +++ b/app/assets/javascripts/discourse/controllers/grant-badge.js.es6 @@ -6,6 +6,7 @@ import ModalFunctionality from "discourse/mixins/modal-functionality"; import GrantBadgeController from "discourse/mixins/grant-badge-controller"; import Badge from "discourse/models/badge"; import UserBadge from "discourse/models/user-badge"; +import { all } from "rsvp"; export default Controller.extend(ModalFunctionality, GrantBadgeController, { topicController: inject("topic"), @@ -42,7 +43,7 @@ export default Controller.extend(ModalFunctionality, GrantBadgeController, { onShow() { this.set("loading", true); - Ember.RSVP.all([ + all([ Badge.findAll(), UserBadge.findByUsername(this.get("post.username")) ]).then(([allBadges, userBadges]) => { diff --git a/app/assets/javascripts/discourse/controllers/topic.js.es6 b/app/assets/javascripts/discourse/controllers/topic.js.es6 index 291e07d29b4..af63f140be8 100644 --- a/app/assets/javascripts/discourse/controllers/topic.js.es6 +++ b/app/assets/javascripts/discourse/controllers/topic.js.es6 @@ -25,6 +25,7 @@ import { spinnerHTML } from "discourse/helpers/loading-spinner"; import { userPath } from "discourse/lib/url"; import showModal from "discourse/lib/show-modal"; import TopicTimer from "discourse/models/topic-timer"; +import { Promise } from "rsvp"; let customPostMessageCallbacks = {}; @@ -268,7 +269,7 @@ export default Controller.extend(bufferedProperty("model"), { selectText(postId, buffer) { const loadedPost = this.get("model.postStream").findLoadedPost(postId); const promise = loadedPost - ? Ember.RSVP.resolve(loadedPost) + ? Promise.resolve(loadedPost) : this.get("model.postStream").loadPost(postId); return promise.then(post => { @@ -826,7 +827,7 @@ export default Controller.extend(bufferedProperty("model"), { }, addNotice(post) { - return new Ember.RSVP.Promise(function(resolve, reject) { + return new Promise(function(resolve, reject) { const controller = showModal("add-post-notice"); controller.setProperties({ post, resolve, reject }); }); diff --git a/app/assets/javascripts/discourse/lib/ajax.js.es6 b/app/assets/javascripts/discourse/lib/ajax.js.es6 index e2bb45ef085..40fd85d686c 100644 --- a/app/assets/javascripts/discourse/lib/ajax.js.es6 +++ b/app/assets/javascripts/discourse/lib/ajax.js.es6 @@ -1,6 +1,7 @@ import { run } from "@ember/runloop"; import pageVisible from "discourse/lib/page-visible"; import logout from "discourse/lib/logout"; +import { Promise } from "rsvp"; let _trackView = false; let _transientHeader = null; @@ -163,13 +164,13 @@ export function ajax() { url !== Discourse.getURL("/clicks/track") && !Discourse.Session.currentProp("csrfToken") ) { - promise = new Ember.RSVP.Promise((resolve, reject) => { + promise = new Promise((resolve, reject) => { ajaxObj = updateCsrfToken().then(() => { performAjax(resolve, reject); }); }); } else { - promise = new Ember.RSVP.Promise(performAjax); + promise = new Promise(performAjax); } promise.abort = () => { diff --git a/app/assets/javascripts/discourse/lib/category-tag-search.js.es6 b/app/assets/javascripts/discourse/lib/category-tag-search.js.es6 index 164839fabf0..0b46e05b73a 100644 --- a/app/assets/javascripts/discourse/lib/category-tag-search.js.es6 +++ b/app/assets/javascripts/discourse/lib/category-tag-search.js.es6 @@ -3,6 +3,7 @@ import { CANCELLED_STATUS } from "discourse/lib/autocomplete"; import Category from "discourse/models/category"; import { TAG_HASHTAG_POSTFIX } from "discourse/lib/tag-hashtags"; import { SEPARATOR } from "discourse/lib/category-hashtags"; +import { Promise } from "rsvp"; var cache = {}; var cacheTime; @@ -15,7 +16,7 @@ function updateCache(term, results) { } function searchTags(term, categories, limit) { - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { const clearPromise = setTimeout(() => { resolve(CANCELLED_STATUS); }, 5000); diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6 index 6e27ebbbe25..12abc761528 100644 --- a/app/assets/javascripts/discourse/lib/click-track.js.es6 +++ b/app/assets/javascripts/discourse/lib/click-track.js.es6 @@ -3,6 +3,7 @@ import { ajax } from "discourse/lib/ajax"; import DiscourseURL from "discourse/lib/url"; import { wantsNewWindow } from "discourse/lib/intercept-click"; import { selectedText } from "discourse/lib/utilities"; +import { Promise } from "rsvp"; export function isValidLink($link) { // Do not track: @@ -96,7 +97,7 @@ export default { } } - let trackPromise = Ember.RSVP.resolve(); + let trackPromise = Promise.resolve(); if (tracking) { if (!Ember.testing && navigator.sendBeacon) { const data = new FormData(); diff --git a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 index 330772014d1..52c0449285c 100644 --- a/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 +++ b/app/assets/javascripts/discourse/lib/desktop-notifications.js.es6 @@ -2,6 +2,7 @@ import { later } from "@ember/runloop"; import DiscourseURL from "discourse/lib/url"; import KeyValueStore from "discourse/lib/key-value-store"; import { formatUsername } from "discourse/lib/utilities"; +import { Promise } from "rsvp"; let primaryTab = false; let liveEnabled = false; @@ -189,11 +190,11 @@ function onNotification(data) { // Wraps Notification.requestPermission in a Promise function requestPermission() { if (havePermission === true) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } else if (havePermission === false) { - return Ember.RSVP.reject(); + return Promise.reject(); } else { - return new Ember.RSVP.Promise(function(resolve, reject) { + return new Promise(function(resolve, reject) { Notification.requestPermission(function(status) { if (status === "granted") { resolve(); diff --git a/app/assets/javascripts/discourse/lib/load-script.js.es6 b/app/assets/javascripts/discourse/lib/load-script.js.es6 index c1f11ec0f49..1efec2ea78f 100644 --- a/app/assets/javascripts/discourse/lib/load-script.js.es6 +++ b/app/assets/javascripts/discourse/lib/load-script.js.es6 @@ -1,5 +1,7 @@ import { run } from "@ember/runloop"; import { ajax } from "discourse/lib/ajax"; +import { Promise } from "rsvp"; + const _loaded = {}; const _loading = {}; @@ -38,7 +40,7 @@ export function loadCSS(url) { export default function loadScript(url, opts) { // TODO: Remove this once plugins have been updated not to use it: if (url === "defer/html-sanitizer-bundle") { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } opts = opts || {}; @@ -55,7 +57,7 @@ export default function loadScript(url, opts) { } }); - return new Ember.RSVP.Promise(function(resolve) { + return new Promise(function(resolve) { // If we already loaded this url if (_loaded[url]) { return resolve(); @@ -65,7 +67,7 @@ export default function loadScript(url, opts) { } let done; - _loading[url] = new Ember.RSVP.Promise(function(_done) { + _loading[url] = new Promise(function(_done) { done = _done; }); diff --git a/app/assets/javascripts/discourse/lib/pwa-utils.js.es6 b/app/assets/javascripts/discourse/lib/pwa-utils.js.es6 index c1833da32b6..1e2c901bd65 100644 --- a/app/assets/javascripts/discourse/lib/pwa-utils.js.es6 +++ b/app/assets/javascripts/discourse/lib/pwa-utils.js.es6 @@ -1,6 +1,8 @@ +import { Promise } from "rsvp"; + export function nativeShare(data) { const caps = Discourse.__container__.lookup("capabilities:main"); - return new Ember.RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { if (!(caps.isIOS || caps.isAndroid || caps.isWinphone)) { reject(); return; diff --git a/app/assets/javascripts/discourse/lib/text.js.es6 b/app/assets/javascripts/discourse/lib/text.js.es6 index cb02036cede..2767426c09e 100644 --- a/app/assets/javascripts/discourse/lib/text.js.es6 +++ b/app/assets/javascripts/discourse/lib/text.js.es6 @@ -4,6 +4,7 @@ import WhiteLister from "pretty-text/white-lister"; import { sanitize as textSanitize } from "pretty-text/sanitizer"; import loadScript from "discourse/lib/load-script"; import { formatUsername } from "discourse/lib/utilities"; +import { Promise } from "rsvp"; function getOpts(opts) { const siteSettings = Discourse.__container__.lookup("site-settings:main"), @@ -51,7 +52,7 @@ function loadMarkdownIt() { console.error(e); }); } else { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } } diff --git a/app/assets/javascripts/discourse/lib/user-search.js.es6 b/app/assets/javascripts/discourse/lib/user-search.js.es6 index 5288fae5896..63fbb2da717 100644 --- a/app/assets/javascripts/discourse/lib/user-search.js.es6 +++ b/app/assets/javascripts/discourse/lib/user-search.js.es6 @@ -2,6 +2,7 @@ import debounce from "discourse/lib/debounce"; import { CANCELLED_STATUS } from "discourse/lib/autocomplete"; import { userPath } from "discourse/lib/url"; import { emailValid } from "discourse/lib/utilities"; +import { Promise } from "rsvp"; var cache = {}, cacheKey, @@ -166,7 +167,7 @@ export default function userSearch(options) { currentTerm = term; - return new Ember.RSVP.Promise(function(resolve) { + return new Promise(function(resolve) { const newCacheKey = `${topicId}-${categoryId}`; if (new Date() - cacheTime > 30000 || cacheKey !== newCacheKey) { diff --git a/app/assets/javascripts/discourse/models/badge.js.es6 b/app/assets/javascripts/discourse/models/badge.js.es6 index ee0009246e4..88203b5084f 100644 --- a/app/assets/javascripts/discourse/models/badge.js.es6 +++ b/app/assets/javascripts/discourse/models/badge.js.es6 @@ -4,6 +4,7 @@ import { ajax } from "discourse/lib/ajax"; import BadgeGrouping from "discourse/models/badge-grouping"; import RestModel from "discourse/models/rest"; import computed from "ember-addons/ember-computed-decorators"; +import { Promise } from "rsvp"; const Badge = RestModel.extend({ newBadge: none("id"), @@ -53,7 +54,7 @@ const Badge = RestModel.extend({ }, destroy() { - if (this.newBadge) return Ember.RSVP.resolve(); + if (this.newBadge) return Promise.resolve(); return ajax(`/admin/badges/${this.id}`, { type: "DELETE" diff --git a/app/assets/javascripts/discourse/models/composer.js.es6 b/app/assets/javascripts/discourse/models/composer.js.es6 index 57b0478e2a3..3648107d6f5 100644 --- a/app/assets/javascripts/discourse/models/composer.js.es6 +++ b/app/assets/javascripts/discourse/models/composer.js.es6 @@ -17,6 +17,7 @@ import { import { escapeExpression, tinyAvatar } from "discourse/lib/utilities"; import { propertyNotEqual } from "discourse/lib/computed"; import throttle from "discourse/lib/throttle"; +import { Promise } from "rsvp"; // The actions the composer can take export const CREATE_TOPIC = "createTopic", @@ -755,7 +756,7 @@ const Composer = RestModel.extend({ // Overwrite to implement custom logic beforeSave() { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); }, save(opts) { @@ -792,7 +793,7 @@ const Composer = RestModel.extend({ editPost(opts) { const post = this.post; const oldCooked = post.cooked; - let promise = Ember.RSVP.resolve(); + let promise = Promise.resolve(); // Update the topic if we're editing the first post if (this.title && post.post_number === 1) { diff --git a/app/assets/javascripts/discourse/models/invite.js.es6 b/app/assets/javascripts/discourse/models/invite.js.es6 index f8a4a036101..54baf013f55 100644 --- a/app/assets/javascripts/discourse/models/invite.js.es6 +++ b/app/assets/javascripts/discourse/models/invite.js.es6 @@ -2,6 +2,7 @@ import EmberObject from "@ember/object"; import { ajax } from "discourse/lib/ajax"; import { popupAjaxError } from "discourse/lib/ajax-error"; import { userPath } from "discourse/lib/url"; +import { Promise } from "rsvp"; const Invite = Discourse.Model.extend({ rescind() { @@ -32,7 +33,7 @@ Invite.reopenClass({ }, findInvitedBy(user, filter, search, offset) { - if (!user) Ember.RSVP.resolve(); + if (!user) Promise.resolve(); const data = {}; if (!Ember.isNone(filter)) data.filter = filter; @@ -48,7 +49,7 @@ Invite.reopenClass({ }, findInvitedCount(user) { - if (!user) Ember.RSVP.resolve(); + if (!user) Promise.resolve(); return ajax(userPath(`${user.username_lower}/invited_count.json`)).then( result => EmberObject.create(result.counts) diff --git a/app/assets/javascripts/discourse/models/login-method.js.es6 b/app/assets/javascripts/discourse/models/login-method.js.es6 index 6e7de67e552..0bfddf39514 100644 --- a/app/assets/javascripts/discourse/models/login-method.js.es6 +++ b/app/assets/javascripts/discourse/models/login-method.js.es6 @@ -1,6 +1,7 @@ import EmberObject from "@ember/object"; import computed from "ember-addons/ember-computed-decorators"; import { updateCsrfToken } from "discourse/lib/ajax"; +import { Promise } from "rsvp"; const LoginMethod = EmberObject.extend({ @computed @@ -21,12 +22,12 @@ const LoginMethod = EmberObject.extend({ doLogin({ reconnect = false } = {}) { if (this.customLogin) { this.customLogin(); - return Ember.RSVP.resolve(); + return Promise.resolve(); } if (this.custom_url) { window.location = this.custom_url; - return Ember.RSVP.resolve(); + return Promise.resolve(); } let authUrl = Discourse.getURL(`/auth/${this.name}`); diff --git a/app/assets/javascripts/discourse/models/post-stream.js.es6 b/app/assets/javascripts/discourse/models/post-stream.js.es6 index ae634fbd311..6baafb909b6 100644 --- a/app/assets/javascripts/discourse/models/post-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/post-stream.js.es6 @@ -7,6 +7,7 @@ import RestModel from "discourse/models/rest"; import PostsWithPlaceholders from "discourse/lib/posts-with-placeholders"; import { default as computed } from "ember-addons/ember-computed-decorators"; import { loadTopicView } from "discourse/models/topic"; +import { Promise } from "rsvp"; export default RestModel.extend({ _identityMap: null, @@ -255,7 +256,7 @@ export default RestModel.extend({ } else { const postWeWant = this.posts.findBy("post_number", opts.nearPost); if (postWeWant) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } } @@ -317,7 +318,7 @@ export default RestModel.extend({ }); } } - return Ember.RSVP.resolve(); + return Promise.resolve(); }, // Fill in a gap of posts after a particular post @@ -333,14 +334,14 @@ export default RestModel.extend({ this.stream.arrayContentDidChange(); }); } - return Ember.RSVP.resolve(); + return Promise.resolve(); }, // Appends the next window of posts to the stream. Call it when scrolling downwards. appendMore() { // Make sure we can append more posts if (!this.canAppendMore) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } const postsWithPlaceholders = this.postsWithPlaceholders; @@ -363,7 +364,7 @@ export default RestModel.extend({ }); } else { const postIds = this.nextWindow; - if (isEmpty(postIds)) return Ember.RSVP.resolve(); + if (isEmpty(postIds)) return Promise.resolve(); this.set("loadingBelow", true); postsWithPlaceholders.appending(postIds); @@ -383,7 +384,7 @@ export default RestModel.extend({ prependMore() { // Make sure we can append more posts if (!this.canPrependMore) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } if (this.isMegaTopic) { @@ -404,7 +405,7 @@ export default RestModel.extend({ }); } else { const postIds = this.previousWindow; - if (isEmpty(postIds)) return Ember.RSVP.resolve(); + if (isEmpty(postIds)) return Promise.resolve(); this.set("loadingAbove", true); return this.findPostsByIds(postIds.reverse()) @@ -580,7 +581,7 @@ export default RestModel.extend({ have no filters. **/ triggerNewPostInStream(postId) { - const resolved = Ember.RSVP.Promise.resolve(); + const resolved = Promise.resolve(); if (!postId) { return resolved; @@ -680,13 +681,13 @@ export default RestModel.extend({ this.removePosts([existing]); }); } - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); }, triggerChangedPost(postId, updatedAt, opts) { opts = opts || {}; - const resolved = Ember.RSVP.Promise.resolve(); + const resolved = Promise.resolve(); if (!postId) { return resolved; } @@ -707,7 +708,7 @@ export default RestModel.extend({ }, triggerReadPost(postId, readersCount) { - const resolved = Ember.RSVP.Promise.resolve(); + const resolved = Promise.resolve(); resolved.then(() => { const post = this.findLoadedPost(postId); if (post && readersCount > post.readers_count) { @@ -958,7 +959,7 @@ export default RestModel.extend({ loadIntoIdentityMap(postIds) { if (isEmpty(postIds)) { - return Ember.RSVP.resolve([]); + return Promise.resolve([]); } let includeSuggested = !this.get("topic.suggested_topics"); @@ -1029,12 +1030,12 @@ export default RestModel.extend({ excerpt(streamPosition) { if (this.isMegaTopic) { - return new Ember.RSVP.Promise(resolve => resolve("")); + return new Promise(resolve => resolve("")); } const stream = this.stream; - return new Ember.RSVP.Promise((resolve, reject) => { + return new Promise((resolve, reject) => { let excerpt = this._excerpts && this._excerpts[stream[streamPosition]]; if (excerpt) { diff --git a/app/assets/javascripts/discourse/models/post.js.es6 b/app/assets/javascripts/discourse/models/post.js.es6 index 382b369c562..4fbfcdeea02 100644 --- a/app/assets/javascripts/discourse/models/post.js.es6 +++ b/app/assets/javascripts/discourse/models/post.js.es6 @@ -13,6 +13,7 @@ import { postUrl } from "discourse/lib/utilities"; import { cookAsync } from "discourse/lib/text"; import { userPath } from "discourse/lib/url"; import Composer from "discourse/models/composer"; +import { Promise } from "rsvp"; const Post = RestModel.extend({ // TODO: Remove this once one instantiate all `Discourse.Post` models via the store. @@ -230,7 +231,7 @@ const Post = RestModel.extend({ }); } - return promise || Ember.RSVP.Promise.resolve(); + return promise || Promise.resolve(); }, /** diff --git a/app/assets/javascripts/discourse/models/rest.js.es6 b/app/assets/javascripts/discourse/models/rest.js.es6 index 9ca2f5d0db6..a140dad5047 100644 --- a/app/assets/javascripts/discourse/models/rest.js.es6 +++ b/app/assets/javascripts/discourse/models/rest.js.es6 @@ -1,5 +1,6 @@ import { equal } from "@ember/object/computed"; import EmberObject from "@ember/object"; +import { Promise } from "rsvp"; const RestModel = EmberObject.extend({ isNew: equal("__state", "new"), @@ -11,7 +12,7 @@ const RestModel = EmberObject.extend({ update(props) { if (this.isSaving) { - return Ember.RSVP.reject(); + return Promise.reject(); } props = props || this.updateProperties(); @@ -39,7 +40,7 @@ const RestModel = EmberObject.extend({ _saveNew(props) { if (this.isSaving) { - return Ember.RSVP.reject(); + return Promise.reject(); } props = props || this.createProperties(); diff --git a/app/assets/javascripts/discourse/models/result-set.js.es6 b/app/assets/javascripts/discourse/models/result-set.js.es6 index dc9f1f9ec48..436abfd2de6 100644 --- a/app/assets/javascripts/discourse/models/result-set.js.es6 +++ b/app/assets/javascripts/discourse/models/result-set.js.es6 @@ -1,4 +1,5 @@ import computed from "ember-addons/ember-computed-decorators"; +import { Promise } from "rsvp"; export default Ember.ArrayProxy.extend({ loading: false, @@ -34,7 +35,7 @@ export default Ember.ArrayProxy.extend({ .finally(() => this.set("loadingMore", false)); } - return Ember.RSVP.resolve(); + return Promise.resolve(); }, refresh() { diff --git a/app/assets/javascripts/discourse/models/reviewable.js.es6 b/app/assets/javascripts/discourse/models/reviewable.js.es6 index 25fc62f63dc..892822c59e1 100644 --- a/app/assets/javascripts/discourse/models/reviewable.js.es6 +++ b/app/assets/javascripts/discourse/models/reviewable.js.es6 @@ -2,6 +2,7 @@ import { ajax } from "discourse/lib/ajax"; import RestModel from "discourse/models/rest"; import computed from "ember-addons/ember-computed-decorators"; import Category from "discourse/models/category"; +import { Promise } from "rsvp"; export const PENDING = 0; export const APPROVED = 1; @@ -25,7 +26,7 @@ export default RestModel.extend({ update(updates) { // If no changes, do nothing if (Object.keys(updates).length === 0) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } let adapter = this.store.adapterFor("reviewable"); diff --git a/app/assets/javascripts/discourse/models/static-page.js.es6 b/app/assets/javascripts/discourse/models/static-page.js.es6 index 50c63e083c2..57bb3cc2df2 100644 --- a/app/assets/javascripts/discourse/models/static-page.js.es6 +++ b/app/assets/javascripts/discourse/models/static-page.js.es6 @@ -4,7 +4,7 @@ const StaticPage = EmberObject.extend(); StaticPage.reopenClass({ find(path) { - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { // Models shouldn't really be doing Ajax request, but this is a huge speed boost if we // preload content. const $preloaded = $('noscript[data-path="/' + path + '"]'); diff --git a/app/assets/javascripts/discourse/models/store.js.es6 b/app/assets/javascripts/discourse/models/store.js.es6 index 841def676ff..3160fff6f50 100644 --- a/app/assets/javascripts/discourse/models/store.js.es6 +++ b/app/assets/javascripts/discourse/models/store.js.es6 @@ -210,7 +210,7 @@ export default EmberObject.extend({ // If the record is new, don't perform an Ajax call if (record.get("isNew")) { removeMap(type, record.get("id")); - return Ember.RSVP.Promise.resolve(true); + return Promise.resolve(true); } return this.adapterFor(type) diff --git a/app/assets/javascripts/discourse/models/topic-list.js.es6 b/app/assets/javascripts/discourse/models/topic-list.js.es6 index d9c9b211de1..da01a6899d6 100644 --- a/app/assets/javascripts/discourse/models/topic-list.js.es6 +++ b/app/assets/javascripts/discourse/models/topic-list.js.es6 @@ -4,6 +4,7 @@ import { ajax } from "discourse/lib/ajax"; import RestModel from "discourse/models/rest"; import Model from "discourse/models/model"; import { getOwner } from "discourse-common/lib/get-owner"; +import { Promise } from "rsvp"; // Whether to show the category badge in topic lists function displayCategoryInList(site, category) { @@ -54,7 +55,7 @@ const TopicList = RestModel.extend({ loadMore() { if (this.loadingMore) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } let moreUrl = this.more_topics_url; @@ -97,7 +98,7 @@ const TopicList = RestModel.extend({ }); } else { // Return a promise indicating no more results - return Ember.RSVP.resolve(); + return Promise.resolve(); } }, diff --git a/app/assets/javascripts/discourse/models/topic.js.es6 b/app/assets/javascripts/discourse/models/topic.js.es6 index b7614afddf7..f4bf6c65339 100644 --- a/app/assets/javascripts/discourse/models/topic.js.es6 +++ b/app/assets/javascripts/discourse/models/topic.js.es6 @@ -374,7 +374,7 @@ const Topic = RestModel.extend({ toggleBookmark() { if (this.bookmarking) { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } this.set("bookmarking", true); @@ -417,7 +417,7 @@ const Topic = RestModel.extend({ ); } - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { if (unbookmarkedPosts.length > 1) { bootbox.confirm( I18n.t("bookmarks.confirm_clear"), diff --git a/app/assets/javascripts/discourse/models/user-badge.js.es6 b/app/assets/javascripts/discourse/models/user-badge.js.es6 index a8850674a4c..69e88caf2ef 100644 --- a/app/assets/javascripts/discourse/models/user-badge.js.es6 +++ b/app/assets/javascripts/discourse/models/user-badge.js.es6 @@ -1,6 +1,7 @@ import { ajax } from "discourse/lib/ajax"; import Badge from "discourse/models/badge"; import computed from "ember-addons/ember-computed-decorators"; +import { Promise } from "rsvp"; const UserBadge = Discourse.Model.extend({ @computed @@ -96,7 +97,7 @@ UserBadge.reopenClass({ **/ findByUsername: function(username, options) { if (!username) { - return Ember.RSVP.resolve([]); + return Promise.resolve([]); } var url = "/user-badges/" + username + ".json"; if (options && options.grouped) { diff --git a/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6 b/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6 index c384b49569f..ee1d3cccad7 100644 --- a/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/user-drafts-stream.js.es6 @@ -4,7 +4,7 @@ import RestModel from "discourse/models/rest"; import UserDraft from "discourse/models/user-draft"; import { emojiUnescape } from "discourse/lib/text"; import computed from "ember-addons/ember-computed-decorators"; - +import { Promise } from "rsvp"; import { NEW_TOPIC_KEY, NEW_PRIVATE_MESSAGE_KEY @@ -55,11 +55,11 @@ export default RestModel.extend({ const lastLoadedUrl = this.lastLoadedUrl; if (lastLoadedUrl === findUrl) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } if (this.loading) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } this.set("loading", true); diff --git a/app/assets/javascripts/discourse/models/user-posts-stream.js.es6 b/app/assets/javascripts/discourse/models/user-posts-stream.js.es6 index 7521b82dcec..74cadcb4553 100644 --- a/app/assets/javascripts/discourse/models/user-posts-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/user-posts-stream.js.es6 @@ -2,6 +2,7 @@ import { on } from "ember-addons/ember-computed-decorators"; import { ajax } from "discourse/lib/ajax"; import { url } from "discourse/lib/computed"; import UserAction from "discourse/models/user-action"; +import { Promise } from "rsvp"; export default Discourse.Model.extend({ loaded: false, @@ -24,7 +25,7 @@ export default Discourse.Model.extend({ filterBy(opts) { if (this.loaded && this.filter === opts.filter) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } this.setProperties( @@ -43,7 +44,7 @@ export default Discourse.Model.extend({ findItems() { if (this.loading || !this.canLoadMore) { - return Ember.RSVP.reject(); + return Promise.reject(); } this.set("loading", true); diff --git a/app/assets/javascripts/discourse/models/user-stream.js.es6 b/app/assets/javascripts/discourse/models/user-stream.js.es6 index 35e44cc6612..1a90ebd9403 100644 --- a/app/assets/javascripts/discourse/models/user-stream.js.es6 +++ b/app/assets/javascripts/discourse/models/user-stream.js.es6 @@ -3,6 +3,7 @@ import { url } from "discourse/lib/computed"; import RestModel from "discourse/models/rest"; import UserAction from "discourse/models/user-action"; import { emojiUnescape } from "discourse/lib/text"; +import { Promise } from "rsvp"; import { default as computed, on @@ -92,11 +93,11 @@ export default RestModel.extend({ // Don't load the same stream twice. We're probably at the end. const lastLoadedUrl = this.lastLoadedUrl; if (lastLoadedUrl === findUrl) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } if (this.loading) { - return Ember.RSVP.resolve(); + return Promise.resolve(); } this.set("loading", true); diff --git a/app/assets/javascripts/discourse/models/user.js.es6 b/app/assets/javascripts/discourse/models/user.js.es6 index 6ce6bf90cdd..af2a0dd2fc3 100644 --- a/app/assets/javascripts/discourse/models/user.js.es6 +++ b/app/assets/javascripts/discourse/models/user.js.es6 @@ -23,6 +23,7 @@ import PreloadStore from "preload-store"; import { defaultHomepage } from "discourse/lib/utilities"; import { userPath } from "discourse/lib/url"; import Category from "discourse/models/category"; +import { Promise } from "rsvp"; import { getProperties } from "@ember/object"; export const SECOND_FACTOR_METHODS = { @@ -583,7 +584,7 @@ const User = RestModel.extend({ findStaffInfo() { if (!Discourse.User.currentProp("staff")) { - return Ember.RSVP.resolve(null); + return Promise.resolve(null); } return ajax(userPath(`${this.username_lower}/staff-info.json`)).then( info => { @@ -672,7 +673,7 @@ const User = RestModel.extend({ data: { context: window.location.pathname } }); } else { - return Ember.RSVP.reject(I18n.t("user.delete_yourself_not_allowed")); + return Promise.reject(I18n.t("user.delete_yourself_not_allowed")); } }, diff --git a/app/assets/javascripts/discourse/routes/badges-show.js.es6 b/app/assets/javascripts/discourse/routes/badges-show.js.es6 index 9197a77cc14..86b8f0d4afc 100644 --- a/app/assets/javascripts/discourse/routes/badges-show.js.es6 +++ b/app/assets/javascripts/discourse/routes/badges-show.js.es6 @@ -2,6 +2,7 @@ import DiscourseRoute from "discourse/routes/discourse"; import UserBadge from "discourse/models/user-badge"; import Badge from "discourse/models/badge"; import PreloadStore from "preload-store"; +import { hash } from "rsvp"; export default DiscourseRoute.extend({ queryParams: { @@ -52,7 +53,7 @@ export default DiscourseRoute.extend({ userBadgesAll }; - return Ember.RSVP.hash(promises); + return hash(promises); }, titleToken() { diff --git a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 index 99c41ed6403..06259b920c1 100644 --- a/app/assets/javascripts/discourse/routes/build-category-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-category-route.js.es6 @@ -8,6 +8,7 @@ import TopicList from "discourse/models/topic-list"; import PermissionType from "discourse/models/permission-type"; import CategoryList from "discourse/models/category-list"; import Category from "discourse/models/category"; +import { Promise, all } from "rsvp"; // A helper function to create a category route with parameters export default (filterArg, params) => { @@ -50,7 +51,7 @@ export default (filterArg, params) => { } this._setupNavigation(model.category); - return Ember.RSVP.all([ + return all([ this._createSubcategoryList(model.category), this._retrieveTopicList(model.category, transition) ]); @@ -87,7 +88,7 @@ export default (filterArg, params) => { } // If we're not loading a subcategory list just resolve - return Ember.RSVP.resolve(); + return Promise.resolve(); }, _retrieveTopicList(category, transition) { diff --git a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 index fb4249205d0..5d0a5760055 100644 --- a/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 +++ b/app/assets/javascripts/discourse/routes/build-topic-route.js.es6 @@ -18,7 +18,7 @@ function filterQueryParams(params, defaultParams) { function findTopicList(store, tracking, filter, filterParams, extras) { extras = extras || {}; - return new Ember.RSVP.Promise(function(resolve) { + return new Promise(function(resolve) { const session = Discourse.Session.current(); if (extras.cached) { diff --git a/app/assets/javascripts/discourse/routes/discovery-categories.js.es6 b/app/assets/javascripts/discourse/routes/discovery-categories.js.es6 index 125b6bf9d04..f5bafdf12b3 100644 --- a/app/assets/javascripts/discourse/routes/discovery-categories.js.es6 +++ b/app/assets/javascripts/discourse/routes/discovery-categories.js.es6 @@ -9,6 +9,7 @@ import TopicList from "discourse/models/topic-list"; import { ajax } from "discourse/lib/ajax"; import PreloadStore from "preload-store"; import { searchPriorities } from "discourse/components/concerns/category-search-priorities"; +import { hash } from "rsvp"; const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, { renderTemplate() { @@ -44,11 +45,11 @@ const DiscoveryCategoriesRoute = DiscourseRoute.extend(OpenComposer, { }, _findCategoriesAndTopics(filter) { - return Ember.RSVP.hash({ + return hash({ wrappedCategoriesList: PreloadStore.getAndRemove("categories_list"), topicsList: PreloadStore.getAndRemove(`topic_list_${filter}`) - }).then(hash => { - let { wrappedCategoriesList, topicsList } = hash; + }).then(response => { + let { wrappedCategoriesList, topicsList } = response; let categoriesList = wrappedCategoriesList && wrappedCategoriesList.category_list; diff --git a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 index 3c70593130a..780cb20e1fb 100644 --- a/app/assets/javascripts/discourse/widgets/post-menu.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post-menu.js.es6 @@ -4,6 +4,7 @@ import { applyDecorators, createWidget } from "discourse/widgets/widget"; import { avatarAtts } from "discourse/widgets/actions-summary"; import { h } from "virtual-dom"; import showModal from "discourse/lib/show-modal"; +import { Promise } from "rsvp"; const LIKE_ACTION = 2; @@ -575,7 +576,7 @@ export default createWidget("post-menu", { this.state.collapsed = false; const likesPromise = !this.state.likedUsers.length ? this.getWhoLiked() - : Ember.RSVP.resolve(); + : Promise.resolve(); return likesPromise.then(() => { if (!this.state.readers.length && this.attrs.showReadIndicator) { @@ -601,7 +602,7 @@ export default createWidget("post-menu", { $heart.closest("button").addClass("has-like"); const scale = [1.0, 1.5]; - return new Ember.RSVP.Promise(resolve => { + return new Promise(resolve => { animateHeart($heart, scale[0], scale[1], () => { animateHeart($heart, scale[1], scale[0], () => { this.sendWidgetAction("toggleLike").then(() => resolve()); diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6 index 12eadf99cb1..8eec4318a88 100644 --- a/app/assets/javascripts/discourse/widgets/post.js.es6 +++ b/app/assets/javascripts/discourse/widgets/post.js.es6 @@ -588,7 +588,7 @@ createWidget("post-article", { if (topicUrl) { DiscourseURL.routeTo(`${topicUrl}/${replyPostNumber}`); } - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } if (this.state.repliesAbove.length) { @@ -598,7 +598,7 @@ createWidget("post-article", { `${this.attrs.topicUrl}/${this.attrs.post_number}` ); } - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); } else { const topicUrl = this._getTopicUrl(); return this.store diff --git a/app/assets/javascripts/discourse/widgets/quick-access-panel.js.es6 b/app/assets/javascripts/discourse/widgets/quick-access-panel.js.es6 index e70985fde2d..904629b818d 100644 --- a/app/assets/javascripts/discourse/widgets/quick-access-panel.js.es6 +++ b/app/assets/javascripts/discourse/widgets/quick-access-panel.js.es6 @@ -22,7 +22,7 @@ export default createWidget("quick-access-panel", { }, markReadRequest() { - return Ember.RSVP.Promise.resolve(); + return Promise.resolve(); }, hasUnread() { @@ -38,7 +38,7 @@ export default createWidget("quick-access-panel", { }, findNewItems() { - return Ember.RSVP.Promise.resolve([]); + return Promise.resolve([]); }, newItemsLoaded() {}, diff --git a/app/assets/javascripts/discourse/widgets/quick-access-profile.js.es6 b/app/assets/javascripts/discourse/widgets/quick-access-profile.js.es6 index 761ebf085fc..f2bfc7ffb74 100644 --- a/app/assets/javascripts/discourse/widgets/quick-access-profile.js.es6 +++ b/app/assets/javascripts/discourse/widgets/quick-access-profile.js.es6 @@ -10,7 +10,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", { }, findNewItems() { - return Ember.RSVP.Promise.resolve(this._getItems()); + return Promise.resolve(this._getItems()); }, itemHtml(item) { diff --git a/app/assets/javascripts/discourse/widgets/widget.js.es6 b/app/assets/javascripts/discourse/widgets/widget.js.es6 index f6f5f78b918..ed848faa0dc 100644 --- a/app/assets/javascripts/discourse/widgets/widget.js.es6 +++ b/app/assets/javascripts/discourse/widgets/widget.js.es6 @@ -8,6 +8,7 @@ import { } from "discourse/widgets/hooks"; import { h } from "virtual-dom"; import DecoratorHelper from "discourse/widgets/decorator-helper"; +import { Promise } from "rsvp"; const _registry = {}; @@ -265,12 +266,12 @@ export default class Widget { if (typeof method === "string") { view[method](param); - promise = Ember.RSVP.resolve(); + promise = Promise.resolve(); } else { const target = view.get("target") || view; promise = method.call(target, param); if (!promise || !promise.then) { - promise = Ember.RSVP.resolve(promise); + promise = Promise.resolve(promise); } } }