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