mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
a few fixes here & there - cache typehinting moved to Forum.ts, don't use button link in PostUser
This commit is contained in:
@@ -67,9 +67,7 @@ export default abstract class Application {
|
|||||||
* A local cache that can be used to store data at the application level, so
|
* A local cache that can be used to store data at the application level, so
|
||||||
* that is persists between different routes.
|
* that is persists between different routes.
|
||||||
*/
|
*/
|
||||||
cache = {
|
cache: { [key: string]: any } = {};
|
||||||
notifications: null,
|
|
||||||
};
|
|
||||||
|
|
||||||
routes = {};
|
routes = {};
|
||||||
|
|
||||||
@@ -243,10 +241,6 @@ export default abstract class Application {
|
|||||||
|
|
||||||
// Now make the request. If it's a failure, inspect the error that was
|
// Now make the request. If it's a failure, inspect the error that was
|
||||||
// returned and show an alert containing its contents.
|
// returned and show an alert containing its contents.
|
||||||
// const deferred = m.deferred();
|
|
||||||
|
|
||||||
// return new Promise((resolve, reject) => )
|
|
||||||
|
|
||||||
return m.request(options).then(
|
return m.request(options).then(
|
||||||
res => res,
|
res => res,
|
||||||
error => {
|
error => {
|
||||||
|
@@ -12,6 +12,8 @@ export default class Model {
|
|||||||
*/
|
*/
|
||||||
data: any;
|
data: any;
|
||||||
|
|
||||||
|
payload: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time at which the model's data was last updated. Watching the value
|
* The time at which the model's data was last updated. Watching the value
|
||||||
* of this property is a fast way to retain/cache a subtree if data hasn't
|
* of this property is a fast way to retain/cache a subtree if data hasn't
|
||||||
|
@@ -17,6 +17,7 @@ import CommentPost from './components/CommentPost';
|
|||||||
import User from '../common/models/User';
|
import User from '../common/models/User';
|
||||||
import Post from '../common/models/Post';
|
import Post from '../common/models/Post';
|
||||||
import Discussion from '../common/models/Discussion';
|
import Discussion from '../common/models/Discussion';
|
||||||
|
import Notification from '../common/models/Notification';
|
||||||
|
|
||||||
export default class Forum extends Application {
|
export default class Forum extends Application {
|
||||||
routes = {
|
routes = {
|
||||||
@@ -40,6 +41,12 @@ export default class Forum extends Application {
|
|||||||
*/
|
*/
|
||||||
history: History = new History();
|
history: History = new History();
|
||||||
|
|
||||||
|
cache: {
|
||||||
|
notifications?: Notification[];
|
||||||
|
discussionList?: DiscussionList;
|
||||||
|
[key: string]: any;
|
||||||
|
} = {};
|
||||||
|
|
||||||
postComponents = {
|
postComponents = {
|
||||||
comment: CommentPost,
|
comment: CommentPost,
|
||||||
// discussionRenamed: DiscussionRenamedPost
|
// discussionRenamed: DiscussionRenamedPost
|
||||||
|
@@ -35,21 +35,14 @@ export default class CommentPost extends Post {
|
|||||||
}
|
}
|
||||||
|
|
||||||
content() {
|
content() {
|
||||||
// Note: we avoid using JSX for the <ul> below because it results in some
|
return super.content().concat([
|
||||||
// weirdness in Mithril.js 0.1.x (see flarum/core#975). This workaround can
|
<header className="Post-header">
|
||||||
// be reverted when we upgrade to Mithril 1.0.
|
<ul>{listItems(this.headerItems().toArray())}</ul>
|
||||||
return super
|
</header>,
|
||||||
.content()
|
<div className="Post-body">
|
||||||
.concat([
|
{this.isEditing() ? <div className="Post-preview" config={this.configPreview.bind(this)} /> : m.trust(this.props.post.contentHtml())}
|
||||||
<header className="Post-header">{m('ul', listItems(this.headerItems().toArray()))}</header>,
|
</div>,
|
||||||
<div className="Post-body">
|
]);
|
||||||
{this.isEditing() ? (
|
|
||||||
<div className="Post-preview" config={this.configPreview.bind(this)} />
|
|
||||||
) : (
|
|
||||||
m.trust(this.props.post.contentHtml())
|
|
||||||
)}
|
|
||||||
</div>,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onupdate(vnode) {
|
onupdate(vnode) {
|
||||||
|
@@ -43,11 +43,11 @@ export default class PostUser extends Component<PostProps> {
|
|||||||
return (
|
return (
|
||||||
<div className="PostUser">
|
<div className="PostUser">
|
||||||
<h3>
|
<h3>
|
||||||
<LinkButton href={app.route.user(user)}>
|
<m.route.Link href={app.route.user(user)}>
|
||||||
{avatar(user, { className: 'PostUser-avatar' })}
|
{avatar(user, { className: 'PostUser-avatar' })}
|
||||||
{userOnline(user)}
|
{userOnline(user)}
|
||||||
{username(user)}
|
{username(user)}
|
||||||
</LinkButton>
|
</m.route.Link>
|
||||||
</h3>
|
</h3>
|
||||||
<ul className="PostUser-badges badges">{listItems(user.badges().toArray())}</ul>
|
<ul className="PostUser-badges badges">{listItems(user.badges().toArray())}</ul>
|
||||||
{card}
|
{card}
|
||||||
|
@@ -43,7 +43,7 @@ export default class History {
|
|||||||
* @param {String} [url] The URL of the route. The current URL will be used if
|
* @param {String} [url] The URL of the route. The current URL will be used if
|
||||||
* not provided.
|
* not provided.
|
||||||
*/
|
*/
|
||||||
push(name: string, title: string, url: string = m.route.get()) {
|
push(name: string, title?: string, url: string = m.route.get()) {
|
||||||
// If we're pushing an item with the same name as second-to-top item in the
|
// If we're pushing an item with the same name as second-to-top item in the
|
||||||
// stack, we will assume that the user has clicked the 'back' button in
|
// stack, we will assume that the user has clicked the 'back' button in
|
||||||
// their browser. In this case, we don't want to push a new item, so we will
|
// their browser. In this case, we don't want to push a new item, so we will
|
||||||
|
Reference in New Issue
Block a user