DEV: Import Promise from rsvp (#8296)
This commit is contained in:
parent
94a34af702
commit
014f19b6ea
|
@ -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())
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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"), [
|
||||
{
|
||||
|
|
|
@ -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]) => {
|
||||
|
|
|
@ -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 });
|
||||
});
|
||||
|
|
|
@ -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 = () => {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}`);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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 + '"]');
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {},
|
||||
|
|
|
@ -10,7 +10,7 @@ createWidgetFrom(QuickAccessPanel, "quick-access-profile", {
|
|||
},
|
||||
|
||||
findNewItems() {
|
||||
return Ember.RSVP.Promise.resolve(this._getItems());
|
||||
return Promise.resolve(this._getItems());
|
||||
},
|
||||
|
||||
itemHtml(item) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue