Mithril 2 Update (#22)

Update for Mithril 2
This commit is contained in:
Alexander Skvortsov 2020-09-23 22:49:05 -04:00 committed by GitHub
parent b663d9b199
commit 080f553a08
4 changed files with 9 additions and 10 deletions

View File

@ -5,7 +5,7 @@ import CommentPost from 'flarum/components/CommentPost';
export default function() { export default function() {
extend(CommentPost.prototype, 'actionItems', function(items) { extend(CommentPost.prototype, 'actionItems', function(items) {
const post = this.props.post; const post = this.attrs.post;
if (post.isHidden() || !post.canLike()) return; if (post.isHidden() || !post.canLike()) return;
@ -15,7 +15,6 @@ export default function() {
items.add('like', items.add('like',
Button.component({ Button.component({
children: app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link'),
className: 'Button Button--link', className: 'Button Button--link',
onclick: () => { onclick: () => {
isLiked = !isLiked; isLiked = !isLiked;
@ -37,7 +36,7 @@ export default function() {
data.unshift({type: 'users', id: app.session.user.id()}); data.unshift({type: 'users', id: app.session.user.id()});
} }
} }
}) }, app.translator.trans(isLiked ? 'flarum-likes.forum.post.unlike_link' : 'flarum-likes.forum.post.like_link'))
); );
}); });
} }

View File

@ -9,7 +9,7 @@ import PostLikesModal from './components/PostLikesModal';
export default function() { export default function() {
extend(CommentPost.prototype, 'footerItems', function(items) { extend(CommentPost.prototype, 'footerItems', function(items) {
const post = this.props.post; const post = this.attrs.post;
const likes = post.likes(); const likes = post.likes();
if (likes && likes.length) { if (likes && likes.length) {
@ -22,7 +22,7 @@ export default function() {
.slice(0, overLimit ? limit - 1 : limit) .slice(0, overLimit ? limit - 1 : limit)
.map(user => { .map(user => {
return ( return (
<a href={app.route.user(user)} config={m.route}> <a route={app.route.user(user)}>
{user === app.session.user ? app.translator.trans('flarum-likes.forum.post.you_text') : username(user)} {user === app.session.user ? app.translator.trans('flarum-likes.forum.post.you_text') : username(user)}
</a> </a>
); );

View File

@ -7,17 +7,17 @@ export default class PostLikedNotification extends Notification {
} }
href() { href() {
return app.route.post(this.props.notification.subject()); return app.route.post(this.attrs.notification.subject());
} }
content() { content() {
const notification = this.props.notification; const notification = this.attrs.notification;
const user = notification.fromUser(); const user = notification.fromUser();
return app.translator.transChoice('flarum-likes.forum.notifications.post_liked_text', 1, {user}); return app.translator.transChoice('flarum-likes.forum.notifications.post_liked_text', 1, {user});
} }
excerpt() { excerpt() {
return truncate(this.props.notification.subject().contentPlain(), 200); return truncate(this.attrs.notification.subject().contentPlain(), 200);
} }
} }

View File

@ -15,9 +15,9 @@ export default class PostLikesModal extends Modal {
return ( return (
<div className="Modal-body"> <div className="Modal-body">
<ul className="PostLikesModal-list"> <ul className="PostLikesModal-list">
{this.props.post.likes().map(user => ( {this.attrs.post.likes().map(user => (
<li> <li>
<a href={app.route.user(user)} config={m.route}> <a route={app.route.user(user)}>
{avatar(user)} {' '} {avatar(user)} {' '}
{username(user)} {username(user)}
</a> </a>