DEV: removes a setTimeout and ensure shorcut is not propagated (#9702)
This commit is contained in:
parent
e46bf15407
commit
646bee2efe
|
@ -23,7 +23,7 @@ import { shortDate } from "discourse/lib/formatter";
|
||||||
import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer";
|
import { SAVE_LABELS, SAVE_ICONS } from "discourse/models/composer";
|
||||||
import { Promise } from "rsvp";
|
import { Promise } from "rsvp";
|
||||||
import ENV from "discourse-common/config/environment";
|
import ENV from "discourse-common/config/environment";
|
||||||
import EmberObject, { computed } from "@ember/object";
|
import EmberObject, { computed, action } from "@ember/object";
|
||||||
import deprecated from "discourse-common/lib/deprecated";
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
function loadDraft(store, opts) {
|
function loadDraft(store, opts) {
|
||||||
|
@ -219,26 +219,26 @@ export default Controller.extend({
|
||||||
isWhispering: or("replyingToWhisper", "model.whisper"),
|
isWhispering: or("replyingToWhisper", "model.whisper"),
|
||||||
|
|
||||||
@discourseComputed("model.action", "isWhispering")
|
@discourseComputed("model.action", "isWhispering")
|
||||||
saveIcon(action, isWhispering) {
|
saveIcon(modelAction, isWhispering) {
|
||||||
if (isWhispering) return "far-eye-slash";
|
if (isWhispering) return "far-eye-slash";
|
||||||
|
|
||||||
return SAVE_ICONS[action];
|
return SAVE_ICONS[modelAction];
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("model.action", "isWhispering", "model.editConflict")
|
@discourseComputed("model.action", "isWhispering", "model.editConflict")
|
||||||
saveLabel(action, isWhispering, editConflict) {
|
saveLabel(modelAction, isWhispering, editConflict) {
|
||||||
if (editConflict) return "composer.overwrite_edit";
|
if (editConflict) return "composer.overwrite_edit";
|
||||||
else if (isWhispering) return "composer.create_whisper";
|
else if (isWhispering) return "composer.create_whisper";
|
||||||
|
|
||||||
return SAVE_LABELS[action];
|
return SAVE_LABELS[modelAction];
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("isStaffUser", "model.action")
|
@discourseComputed("isStaffUser", "model.action")
|
||||||
canWhisper(isStaffUser, action) {
|
canWhisper(isStaffUser, modelAction) {
|
||||||
return (
|
return (
|
||||||
this.siteSettings.enable_whispers &&
|
this.siteSettings.enable_whispers &&
|
||||||
isStaffUser &&
|
isStaffUser &&
|
||||||
Composer.REPLY === action
|
Composer.REPLY === modelAction
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -329,6 +329,20 @@ export default Controller.extend({
|
||||||
return uploadIcon(this.currentUser.staff);
|
return uploadIcon(this.currentUser.staff);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
openIfDraft(event) {
|
||||||
|
if (this.get("model.viewDraft")) {
|
||||||
|
// when called from shortcut, ensure we don't propagate the key to
|
||||||
|
// the composer input title
|
||||||
|
if (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.set("model.composeState", Composer.OPEN);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
togglePreview() {
|
togglePreview() {
|
||||||
this.toggleProperty("showPreview");
|
this.toggleProperty("showPreview");
|
||||||
|
@ -368,8 +382,8 @@ export default Controller.extend({
|
||||||
this.set("model.uploadCancelled", true);
|
this.set("model.uploadCancelled", true);
|
||||||
},
|
},
|
||||||
|
|
||||||
onPopupMenuAction(action) {
|
onPopupMenuAction(menuAction) {
|
||||||
this.send(action);
|
this.send(menuAction);
|
||||||
},
|
},
|
||||||
|
|
||||||
storeToolbarState(toolbarEvent) {
|
storeToolbarState(toolbarEvent) {
|
||||||
|
@ -539,12 +553,6 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
openIfDraft() {
|
|
||||||
if (this.get("model.viewDraft")) {
|
|
||||||
this.set("model.composeState", Composer.OPEN);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
groupsMentioned(groups) {
|
groupsMentioned(groups) {
|
||||||
if (
|
if (
|
||||||
!this.get("model.creatingPrivateMessage") &&
|
!this.get("model.creatingPrivateMessage") &&
|
||||||
|
@ -1161,8 +1169,8 @@ export default Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("model.action")
|
@discourseComputed("model.action")
|
||||||
canEdit(action) {
|
canEdit(modelAction) {
|
||||||
return action === "edit" && this.currentUser.can_edit;
|
return modelAction === "edit" && this.currentUser.can_edit;
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("model.composeState")
|
@discourseComputed("model.composeState")
|
||||||
|
|
|
@ -3,7 +3,7 @@ import DiscourseURL from "discourse/lib/url";
|
||||||
import Composer from "discourse/models/composer";
|
import Composer from "discourse/models/composer";
|
||||||
import { minimumOffset } from "discourse/lib/offset-calculator";
|
import { minimumOffset } from "discourse/lib/offset-calculator";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { throttle } from "@ember/runloop";
|
import { throttle, schedule } from "@ember/runloop";
|
||||||
import { INPUT_DELAY } from "discourse-common/config/environment";
|
import { INPUT_DELAY } from "discourse-common/config/environment";
|
||||||
|
|
||||||
const DEFAULT_BINDINGS = {
|
const DEFAULT_BINDINGS = {
|
||||||
|
@ -330,12 +330,17 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
focusComposer() {
|
focusComposer(event) {
|
||||||
const composer = this.container.lookup("controller:composer");
|
const composer = this.container.lookup("controller:composer");
|
||||||
if (composer.get("model.viewOpen")) {
|
if (composer.get("model.viewOpen")) {
|
||||||
setTimeout(() => $("textarea.d-editor-input").focus(), 0);
|
preventKeyboardEvent(event);
|
||||||
|
|
||||||
|
schedule("afterRender", () => {
|
||||||
|
const input = document.querySelector("textarea.d-editor-input");
|
||||||
|
input && input.focus();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
composer.send("openIfDraft");
|
composer.openIfDraft(event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue