mirror of
https://github.com/flarum/framework.git
synced 2025-03-15 00:05:12 +08:00
Scroll to reply preview initially
This commit is contained in:
parent
1fd5f3f545
commit
0eee50f6d3
42
framework/core/js/forum/dist/app.js
vendored
42
framework/core/js/forum/dist/app.js
vendored
@ -30204,46 +30204,30 @@ System.register('flarum/utils/DiscussionControls', ['flarum/components/Discussio
|
||||
return items;
|
||||
},
|
||||
replyAction: function replyAction(goToLast, forceRefresh) {
|
||||
var _this2 = this;
|
||||
|
||||
var deferred = m.deferred();
|
||||
|
||||
// Define a function that will check the user's permission to reply, and
|
||||
// either open the reply composer for this discussion and resolve the
|
||||
// promise, or reject it.
|
||||
var reply = function reply() {
|
||||
if (_this2.canReply()) {
|
||||
if (goToLast && app.viewingDiscussion(_this2)) {
|
||||
app.current.stream.goToLast();
|
||||
}
|
||||
|
||||
if (app.session.user) {
|
||||
if (this.canReply()) {
|
||||
var component = app.composer.component;
|
||||
if (!app.composingReplyTo(_this2) || forceRefresh) {
|
||||
if (!app.composingReplyTo(this) || forceRefresh) {
|
||||
component = new ReplyComposer({
|
||||
user: app.session.user,
|
||||
discussion: _this2
|
||||
discussion: this
|
||||
});
|
||||
app.composer.load(component);
|
||||
}
|
||||
app.composer.show();
|
||||
|
||||
if (goToLast && app.viewingDiscussion(this)) {
|
||||
app.current.stream.goToNumber('reply');
|
||||
}
|
||||
|
||||
deferred.resolve(component);
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
};
|
||||
|
||||
// If the user is logged in, then we can run that function right away. But
|
||||
// if they're not, we'll prompt them to log in and then run the function
|
||||
// after the discussion has reloaded.
|
||||
if (app.session.user) {
|
||||
reply();
|
||||
} else {
|
||||
app.modal.show(new LogInModal({
|
||||
onlogin: function onlogin() {
|
||||
return app.current.one('loaded', reply);
|
||||
}
|
||||
}));
|
||||
app.modal.show(new LogInModal());
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
@ -30259,7 +30243,7 @@ System.register('flarum/utils/DiscussionControls', ['flarum/components/Discussio
|
||||
return this.save({ isHidden: false });
|
||||
},
|
||||
deleteAction: function deleteAction() {
|
||||
var _this3 = this;
|
||||
var _this2 = this;
|
||||
|
||||
if (confirm(extractText(app.translator.trans('core.forum.discussion_controls.delete_confirmation')))) {
|
||||
// If we're currently viewing the discussion that was deleted, go back
|
||||
@ -30271,14 +30255,14 @@ System.register('flarum/utils/DiscussionControls', ['flarum/components/Discussio
|
||||
return this.delete().then(function () {
|
||||
// If there is a discussion list in the cache, remove this discussion.
|
||||
if (app.cache.discussionList) {
|
||||
app.cache.discussionList.removeDiscussion(_this3);
|
||||
app.cache.discussionList.removeDiscussion(_this2);
|
||||
m.redraw();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
renameAction: function renameAction() {
|
||||
var _this4 = this;
|
||||
var _this3 = this;
|
||||
|
||||
var currentTitle = this.title();
|
||||
var title = prompt(extractText(app.translator.trans('core.forum.discussion_controls.rename_text')), currentTitle);
|
||||
@ -30288,7 +30272,7 @@ System.register('flarum/utils/DiscussionControls', ['flarum/components/Discussio
|
||||
// indicating that the discussion was renamed.
|
||||
if (title && title !== currentTitle) {
|
||||
return this.save({ title: title }).then(function () {
|
||||
if (app.viewingDiscussion(_this4)) {
|
||||
if (app.viewingDiscussion(_this3)) {
|
||||
app.current.stream.update();
|
||||
}
|
||||
m.redraw();
|
||||
|
@ -134,8 +134,7 @@ export default {
|
||||
/**
|
||||
* Open the reply composer for the discussion. A promise will be returned,
|
||||
* which resolves when the composer opens successfully. If the user is not
|
||||
* logged in, they will be prompted and then the reply composer will open (and
|
||||
* the promise will resolve) after they do. If they don't have permission to
|
||||
* logged in, they will be prompted. If they don't have permission to
|
||||
* reply, the promise will be rejected.
|
||||
*
|
||||
* @param {Boolean} goToLast Whether or not to scroll down to the last post if
|
||||
@ -147,15 +146,8 @@ export default {
|
||||
replyAction(goToLast, forceRefresh) {
|
||||
const deferred = m.deferred();
|
||||
|
||||
// Define a function that will check the user's permission to reply, and
|
||||
// either open the reply composer for this discussion and resolve the
|
||||
// promise, or reject it.
|
||||
const reply = () => {
|
||||
if (app.session.user) {
|
||||
if (this.canReply()) {
|
||||
if (goToLast && app.viewingDiscussion(this)) {
|
||||
app.current.stream.goToLast();
|
||||
}
|
||||
|
||||
let component = app.composer.component;
|
||||
if (!app.composingReplyTo(this) || forceRefresh) {
|
||||
component = new ReplyComposer({
|
||||
@ -166,23 +158,16 @@ export default {
|
||||
}
|
||||
app.composer.show();
|
||||
|
||||
if (goToLast && app.viewingDiscussion(this)) {
|
||||
app.current.stream.goToNumber('reply');
|
||||
}
|
||||
|
||||
deferred.resolve(component);
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
};
|
||||
|
||||
// If the user is logged in, then we can run that function right away. But
|
||||
// if they're not, we'll prompt them to log in and then run the function
|
||||
// after the discussion has reloaded.
|
||||
if (app.session.user) {
|
||||
reply();
|
||||
} else {
|
||||
app.modal.show(
|
||||
new LogInModal({
|
||||
onlogin: () => app.current.one('loaded', reply)
|
||||
})
|
||||
);
|
||||
app.modal.show(new LogInModal());
|
||||
}
|
||||
|
||||
return deferred.promise;
|
||||
|
Loading…
x
Reference in New Issue
Block a user