mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 10:42:45 +08:00
DEV: Work around topic-timer data flow issues (#27207)
This commit is contained in:
parent
f76d143919
commit
96305ec9a6
|
@ -7,13 +7,15 @@
|
|||
class="edit-topic-timer-modal"
|
||||
>
|
||||
<:body>
|
||||
<EditTopicTimerForm
|
||||
@topic={{@model.topic}}
|
||||
@topicTimer={{this.topicTimer}}
|
||||
@timerTypes={{this.publicTimerTypes}}
|
||||
@onChangeStatusType={{this.onChangeStatusType}}
|
||||
@onChangeInput={{this.onChangeInput}}
|
||||
/>
|
||||
{{#if this.topicTimer}}
|
||||
<EditTopicTimerForm
|
||||
@topic={{@model.topic}}
|
||||
@topicTimer={{this.topicTimer}}
|
||||
@timerTypes={{this.publicTimerTypes}}
|
||||
@onChangeStatusType={{this.onChangeStatusType}}
|
||||
@onChangeInput={{this.onChangeInput}}
|
||||
/>
|
||||
{{/if}}
|
||||
</:body>
|
||||
<:footer>
|
||||
<DButton
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import { next } from "@ember/runloop";
|
||||
import { service } from "@ember/service";
|
||||
import { TrackedObject } from "@ember-compat/tracked-built-ins";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
|
@ -19,13 +20,23 @@ export const DELETE_REPLIES_TYPE = "delete_replies";
|
|||
export default class EditTopicTimer extends Component {
|
||||
@service currentUser;
|
||||
|
||||
@tracked
|
||||
topicTimer = new TrackedObject(
|
||||
this.args.model.topic?.topic_timer || this.createDefaultTimer()
|
||||
);
|
||||
@tracked topicTimer;
|
||||
@tracked loading = false;
|
||||
@tracked flash;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
||||
if (this.args.model.topic?.topic_timer) {
|
||||
this.topicTimer = new TrackedObject(this.args.model.topic?.topic_timer);
|
||||
} else {
|
||||
// TODO: next() is a hack, to-be-removed
|
||||
next(() => {
|
||||
this.topicTimer = new TrackedObject(this.createDefaultTimer());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
get defaultStatusType() {
|
||||
return this.publicTimerTypes[0].id;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Component from "@ember/component";
|
||||
import { cancel } from "@ember/runloop";
|
||||
import { cancel, next } from "@ember/runloop";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { DELETE_REPLIES_TYPE } from "discourse/components/modal/edit-topic-timer";
|
||||
import Category from "discourse/models/category";
|
||||
|
@ -78,7 +78,8 @@ export default Component.extend({
|
|||
// The topic status has just been toggled, so we can hide the timer info.
|
||||
this.set("showTopicTimer", null);
|
||||
// The timer has already been removed on the back end. The front end is not aware of the change yet.
|
||||
this.set("executeAt", null);
|
||||
// TODO: next() is a hack, to-be-removed
|
||||
next(() => this.set("executeAt", null));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user