REFACTOR: Remove Discourse.Model
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
const Draft = Discourse.Model.extend();
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const Draft = EmberObject.extend();
|
||||
|
||||
Draft.reopenClass({
|
||||
clear(key, sequence) {
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
import Model from "discourse/models/model";
|
||||
|
||||
// A trivial model we use to handle input validation
|
||||
export default Model.extend();
|
||||
import EmberObject from "@ember/object";
|
||||
export default EmberObject.extend();
|
||||
|
||||
@@ -4,7 +4,7 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { userPath } from "discourse/lib/url";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
const Invite = Discourse.Model.extend({
|
||||
const Invite = EmberObject.extend({
|
||||
rescind() {
|
||||
ajax("/invites", {
|
||||
type: "DELETE",
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
const LivePostCounts = Discourse.Model.extend({});
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const LivePostCounts = EmberObject.extend({});
|
||||
|
||||
LivePostCounts.reopenClass({
|
||||
find() {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import EmberObject from "@ember/object";
|
||||
const Model = EmberObject.extend();
|
||||
|
||||
Model.reopenClass({
|
||||
extractByKey(collection, klass) {
|
||||
const retval = {};
|
||||
if (isEmpty(collection)) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
collection.forEach(function(item) {
|
||||
retval[item.id] = klass.create(item);
|
||||
});
|
||||
return retval;
|
||||
}
|
||||
});
|
||||
|
||||
export default Model;
|
||||
@@ -2,8 +2,9 @@ import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { toTitleCase } from "discourse/lib/formatter";
|
||||
import { emojiUnescape } from "discourse/lib/text";
|
||||
import Category from "discourse/models/category";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const NavItem = Discourse.Model.extend({
|
||||
const NavItem = EmberObject.extend({
|
||||
@discourseComputed("categoryName", "name")
|
||||
title(categoryName, name) {
|
||||
const extra = {};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const PermissionType = Discourse.Model.extend({
|
||||
const PermissionType = EmberObject.extend({
|
||||
@discourseComputed("id")
|
||||
description(id) {
|
||||
var key = "";
|
||||
|
||||
@@ -2,11 +2,24 @@ import { notEmpty } from "@ember/object/computed";
|
||||
import EmberObject from "@ember/object";
|
||||
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";
|
||||
import Category from "discourse/models/category";
|
||||
import Session from "discourse/models/session";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import User from "discourse/models/user";
|
||||
|
||||
function extractByKey(collection, klass) {
|
||||
const retval = {};
|
||||
if (isEmpty(collection)) {
|
||||
return retval;
|
||||
}
|
||||
|
||||
collection.forEach(function(item) {
|
||||
retval[item.id] = klass.create(item);
|
||||
});
|
||||
return retval;
|
||||
}
|
||||
|
||||
// Whether to show the category badge in topic lists
|
||||
function displayCategoryInList(site, category) {
|
||||
@@ -139,8 +152,8 @@ TopicList.reopenClass({
|
||||
// Stitch together our side loaded data
|
||||
|
||||
const categories = Category.list(),
|
||||
users = Model.extractByKey(result.users, Discourse.User),
|
||||
groups = Model.extractByKey(result.primary_groups, EmberObject);
|
||||
users = extractByKey(result.users, User),
|
||||
groups = extractByKey(result.primary_groups, EmberObject);
|
||||
|
||||
return result.topic_list[listKey].map(t => {
|
||||
t.category = categories.findBy("id", t.category_id);
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { defaultHomepage } from "discourse/lib/utilities";
|
||||
import PreloadStore from "preload-store";
|
||||
import Category from "discourse/models/category";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
function isNew(topic) {
|
||||
return (
|
||||
@@ -25,7 +26,7 @@ function isUnread(topic) {
|
||||
);
|
||||
}
|
||||
|
||||
const TopicTrackingState = Discourse.Model.extend({
|
||||
const TopicTrackingState = EmberObject.extend({
|
||||
messageCount: 0,
|
||||
|
||||
@on("init")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
/**
|
||||
A data model representing a group of UserActions
|
||||
**/
|
||||
export default Discourse.Model.extend({
|
||||
push: function(item) {
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
export default EmberObject.extend({
|
||||
push(item) {
|
||||
if (!this.items) {
|
||||
this.items = [];
|
||||
}
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ajax } from "discourse/lib/ajax";
|
||||
import Badge from "discourse/models/badge";
|
||||
import { Promise } from "rsvp";
|
||||
import Topic from "discourse/models/topic";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
const UserBadge = Discourse.Model.extend({
|
||||
const UserBadge = EmberObject.extend({
|
||||
@discourseComputed
|
||||
postUrl: function() {
|
||||
if (this.topic_title) {
|
||||
|
||||
@@ -3,8 +3,9 @@ import { ajax } from "discourse/lib/ajax";
|
||||
import { url } from "discourse/lib/computed";
|
||||
import UserAction from "discourse/models/user-action";
|
||||
import { Promise } from "rsvp";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
export default Discourse.Model.extend({
|
||||
export default EmberObject.extend({
|
||||
loaded: false,
|
||||
|
||||
@on("init")
|
||||
|
||||
Reference in New Issue
Block a user