1
0
mirror of https://github.com/flarum/core.git synced 2025-07-29 04:30:56 +02:00

Massive refactor

- Use contextual namespaces within Flarum\Core
- Clean up and docblock everything
- Refactor Activity/Notification blueprint stuff
- Refactor Formatter stuff
- Refactor Search stuff
- Upgrade to JSON-API 1.0
- Removed “addedPosts” and “removedPosts” relationships from discussion
API. This was used for adding/removing event posts after renaming a
discussion etc. Instead we should make an additional request to get all
new posts

Todo:
- Fix Extenders and extensions
- Get rid of repository interfaces
- Fix other bugs I’ve inevitably introduced
This commit is contained in:
Toby Zerner
2015-07-04 12:24:48 +09:30
parent 12dd550a14
commit a74b40fe47
324 changed files with 6443 additions and 4197 deletions

View File

@@ -46,9 +46,11 @@ export default class ActivityPage extends UserPage {
loadResults(offset) {
return app.store.find('activity', {
users: this.user().id(),
page: {offset, limit: this.loadLimit},
type: this.props.filter
filter: {
user: this.user().id(),
type: this.props.filter
},
page: {offset, limit: this.loadLimit}
})
}

View File

@@ -208,6 +208,7 @@ class Composer extends Component {
if (flexible.length) {
flexible.height(height -
(flexible.offset().top - this.$().offset().top) -
parseInt(flexible.css('padding-bottom')) -
this.$('.text-editor-controls').outerHeight(true));
}
}

View File

@@ -65,7 +65,7 @@ export default class DiscussionPage extends mixin(Component, evented) {
params() {
return {
near: this.currentNear,
page: {near: this.currentNear},
include: ['posts', 'posts.user', 'posts.user.groups']
};
}
@@ -91,7 +91,7 @@ export default class DiscussionPage extends mixin(Component, evented) {
var includedPosts = [];
if (discussion.payload && discussion.payload.included) {
discussion.payload.included.forEach(record => {
if (record.type === 'posts' && record.links && record.links.discussion) {
if (record.type === 'posts' && record.relationships && record.relationships.discussion) {
includedPosts.push(app.store.getById('posts', record.id));
}
});

View File

@@ -9,7 +9,7 @@ export default class DiscussionsSearchResults {
search(string) {
this.results[string] = [];
return app.store.find('discussions', {q: string, page: {limit: 3}, include: 'relevantPosts,relevantPosts.discussion'}).then(results => {
return app.store.find('discussions', {filter: {q: string}, page: {limit: 3}, include: 'relevantPosts,relevantPosts.discussion'}).then(results => {
this.results[string] = results;
});
}

View File

@@ -79,7 +79,7 @@ export default class NotificationList extends Component {
this.loading(true);
m.redraw();
app.store.find('notifications').then(notifications => {
app.session.user().pushData({unreadNotificationsCount: 0});
app.session.user().pushAttributes({unreadNotificationsCount: 0});
this.loading(false);
app.cache.notifications = notifications.sort((a, b) => b.time() - a.time());
m.redraw();

View File

@@ -76,11 +76,11 @@ class PostStream extends mixin(Component, evented) {
sync() {
var addedPosts = this.discussion.addedPosts();
if (addedPosts) addedPosts.forEach(this.pushPost.bind(this));
this.discussion.pushData({links: {addedPosts: null}});
this.discussion.pushAttributes({links: {addedPosts: null}});
var removedPosts = this.discussion.removedPosts();
if (removedPosts) removedPosts.forEach(this.removePost.bind(this));
this.discussion.pushData({removedPosts: null});
this.discussion.pushAttributes({removedPosts: null});
}
/**
@@ -352,8 +352,8 @@ class PostStream extends mixin(Component, evented) {
this.clear();
return app.store.find('posts', {
discussions: this.discussion.id(),
near: number
filter: {discussion: this.discussion.id()},
page: {near: number}
}).then(this.setup.bind(this));
}

View File

@@ -32,7 +32,7 @@ export default class ReplyComposer extends ComposerBody {
data() {
return {
content: this.content(),
links: {discussion: this.props.discussion}
relationships: {discussion: this.props.discussion}
};
}
@@ -47,8 +47,8 @@ export default class ReplyComposer extends ComposerBody {
app.store.createRecord('posts').save(data).then((post) => {
app.composer.hide();
discussion.pushData({
links: {
discussion.pushAttributes({
relationships: {
lastUser: post.user(),
lastPost: post
},
@@ -58,7 +58,7 @@ export default class ReplyComposer extends ComposerBody {
readTime: post.time(),
readNumber: post.number()
});
discussion.data().links.posts.linkage.push({type: 'posts', id: post.id()});
discussion.data().relationships.posts.data.push({type: 'posts', id: post.id()});
// If we're currently viewing the discussion which this reply was made
// in, then we can add the post to the end of the post stream.

View File

@@ -113,7 +113,7 @@ export default class SettingsPage extends UserPage {
label: 'Allow others to see when I am online',
state: this.user().preferences().discloseOnline,
onchange: (value, component) => {
this.user().pushData({lastSeenTime: null});
this.user().pushAttributes({lastSeenTime: null});
this.save('discloseOnline')(value, component);
}
})

View File

@@ -3,7 +3,7 @@ import avatar from 'flarum/helpers/avatar';
export default class UsersSearchResults {
search(string) {
return app.store.find('users', {q: string, page: {limit: 5}});
return app.store.find('users', {filter: {q: string}, page: {limit: 5}});
}
view(string) {