mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: prevents double set in the same computation (#31348)
The current code was doing: - initial value for `showPreview` - setting another default value in `_setupPreview` The fix is to move all the computation in one initial step when initializing the property.
This commit is contained in:
parent
04531f1443
commit
7779cf1e90
@ -4,7 +4,7 @@ import { alias, and, or, reads } from "@ember/object/computed";
|
||||
import { cancel, scheduleOnce } from "@ember/runloop";
|
||||
import Service, { service } from "@ember/service";
|
||||
import { isEmpty } from "@ember/utils";
|
||||
import { observes, on } from "@ember-decorators/object";
|
||||
import { observes } from "@ember-decorators/object";
|
||||
import $ from "jquery";
|
||||
import { Promise } from "rsvp";
|
||||
import DiscardDraftModal from "discourse/components/modal/discard-draft";
|
||||
@ -107,7 +107,11 @@ export default class ComposerService extends Service {
|
||||
@service siteSettings;
|
||||
@service store;
|
||||
|
||||
@tracked showPreview = true;
|
||||
@tracked
|
||||
showPreview = this.site.mobileView
|
||||
? false
|
||||
: (this.keyValueStore.get("composer.showPreview") || "true") === "true";
|
||||
|
||||
@tracked allowPreview = true;
|
||||
checkedMessages = false;
|
||||
messageCount = null;
|
||||
@ -154,14 +158,6 @@ export default class ComposerService extends Service {
|
||||
return NEW_PRIVATE_MESSAGE_KEY + "_" + new Date().getTime();
|
||||
}
|
||||
|
||||
@on("init")
|
||||
_setupPreview() {
|
||||
const val = this.site.mobileView
|
||||
? false
|
||||
: this.keyValueStore.get("composer.showPreview") || "true";
|
||||
this.set("showPreview", val === "true");
|
||||
}
|
||||
|
||||
@computed(
|
||||
"model.loading",
|
||||
"isUploading",
|
||||
|
Loading…
Reference in New Issue
Block a user