datlechin Not! only standard settings.

luceos Yes, this is my new community that I just started setting up, at first everything was fine, but at the moment when I test created my first draft and the number 1 appeared on the logo, the icon seemed to have moved a little to the bottom ... after deleting the draft, everything remained the same. ..
I currently use browsers such as Safari and Chrome

    mix0nSPb are you able to reproduce this on your community consistently? And if so, can you repeat it here and see it happen too? We would probably need the output of php flarum info by the way.

    16 days later

    tohsakarat `

    Hello! the problem still exists, so I fixed it by myself with some slight changes on draft scadule model.
    Hope they can be merged in the next version^ ^

    import Alert from 'flarum/common/components/Alert';
    import Button from 'flarum/common/components/Button';
    import Modal from 'flarum/common/components/Modal';
    import LoadingIndicator from 'flarum/common/components/LoadingIndicator';
    
    const CurrentDate = dayjs().format('YYYY/MM/DD');
    const CurrentTime = dayjs().format('HH:mm');
    
    export default class ScheduleDraftModal extends Modal {
      loading = false;
    
      date;
      time;
    
      previewFormatString;
    
      oninit(vnode) {
        super.oninit(vnode);
    
        this.date = this.isScheduled() ? dayjs(this.attrs.draft.scheduledFor()).format('YYYY/MM/DD') : CurrentDate;
        this.time = this.isScheduled() ? dayjs(this.attrs.draft.scheduledFor()).format('HH:mm') : CurrentTime;
    
        this.previewFormatString = app.translator.trans('fof-drafts.forum.schedule_draft_modal.schedule_time_preview_formatter')[0];
      }
    
      className() {
        return 'ScheduleDraftModal';
      }
    
      title() {
        return app.translator.trans('fof-drafts.forum.schedule_draft_modal.title');
      }
    
      content() {
        if (this.loading) {
          return <LoadingIndicator />;
        }
    
        return [
          this.attrs.draft.scheduledFor() ? (
            <div className="Modal-alert">
              <Alert type="success" dismissible={false}>
                {app.translator.trans('fof-drafts.forum.schedule_draft_modal.scheduled_text', {
                  datetime: this.formattedDateTime(),
                })}
              </Alert>
            </div>
          ) : (
            ''
          ),
          this.attrs.draft.scheduledValidationError() ? (
            <div className="Modal-alert">
              <Alert type="error" dismissible={false}>
                {app.translator.trans('fof-drafts.forum.schedule_draft_modal.scheduled_error', {
                  error: this.attrs.draft.scheduledValidationError(),
                })}
              </Alert>
            </div>
          ) : (
            ''
          ),
    
          <input style="display: none"></input>,
    
          <div className="Modal-body">
            <div className="Form Form--centered">
              <p className="helpText">{app.translator.trans('fof-drafts.forum.schedule_draft_modal.text')}</p>
              <div className="Form-group ScheduleDraftModal-timeDateGroup">
                <input
                  name="scheduledForDate"
                  className="FormControl"
                  type="date"
                  min={CurrentDate}
                  value={this.date.replaceAll('/','-')}
                  onchange={(e) => (this.date = e.target.value.replaceAll('-','/'))}
                />
                <input name="scheduledForTime" className="FormControl" type="time" value={this.time} onchange={(e) => (this.time = e.target.value)} />
              </div>
    
              {/* Date time preview */}
              <div class="Form-group ScheduleDraftModal-datePreview">
                {app.translator.trans('fof-drafts.forum.schedule_draft_modal.schedule_time_preview', {
                  datetime: this.formattedDateTime(),
                })}
              </div>
    
              <div className="Form-group ScheduleDraftModal-submitButtons">
                {/* Unschedule button */}
                {this.isScheduled() && (
                  <Button
                    className="ScheduleDraftModal-unscheduleBtn Button Button--block Button--danger"
                    loading={this.loading}
                    onclick={this.unschedule.bind(this)}
                  >
                    {app.translator.trans('fof-drafts.forum.schedule_draft_modal.unschedule_button')}
                  </Button>
                )}
    
                {/* Schedule/reschedule button */}
                <Button
                  className="ScheduleDraftModal-scheduleBtn Button Button--block Button--primary"
                  type="submit"
                  loading={this.loading}
                  disabled={!this.changed()}
                >
                  {this.isScheduled()
                    ? app.translator.trans('fof-drafts.forum.schedule_draft_modal.reschedule_button')
                    : app.translator.trans('fof-drafts.forum.schedule_draft_modal.schedule_button')}
                </Button>
              </div>
            </div>
          </div>,
        ];
      }
    
      /**
       * Returns a Date object for currently entered values in the modal.
       */
      scheduledFor() {
        const date = new Date(`${this.date} ${this.time}`);
    
        return date || null;
      }
    
      /**
       * Whether the modal's details have been modified.
       */
      changed() {
        const getTimeOrNull = (date) => (date ? date.getTime() || null : null);
    
        return getTimeOrNull(this.scheduledFor()) !== getTimeOrNull(this.attrs.draft.scheduledFor());
      }
    
      isScheduled() {
        return !!this.attrs.draft.scheduledFor();
      }
    
      formattedDateTime() {
        const date = dayjs(this.scheduledFor());
    
        // if (!date) {
        //     return app.translator.trans('fof-drafts.forum.schedule_draft_modal.schedule_time_preview_invalid');
        // }
    
        const formatted = date.format(this.previewFormatString);
    
        return formatted;
      }
    
      unschedule(e) {
        e.preventDefault();
    
        this.loading = true;
    
        // Save draft with no scheduled post time
        if (confirm(app.translator.trans('fof-drafts.forum.schedule_draft_modal.unschedule_warning'))) {
          this.attrs.draft
            .save({ scheduledFor: null, clearValidationError: true, scheduledValidationError: '' })
            .then(() => {
              this.success = true;
              this.hide.call(this);
            })
            .catch(() => {})
            .then(this.loaded.bind(this));
        }
      }
    
      onsubmit(e) {
        e.preventDefault();
    
        this.loading = true;
    
        this.attrs.draft
          .save({ scheduledFor: this.scheduledFor(), clearValidationError: true, scheduledValidationError: '' })
          .then(() => (this.success = true))
          .catch(() => {})
          .then(this.loaded.bind(this));
      }
    }

      tohsakarat are you able to submit a PR on GitHub? That would be great!

      Otherwise can you share a diff or just the lines that contain changes? I don't know enough about the source code to guess what part of the code you modified.

        clarkwinkelmann
        Hello, the changes includes those lines.
        And there are still some problem on IOS when the first time using schadule, and show the CurrentTime. At least the schedule can be setted.
        …………
        const CurrentDate = dayjs().format('YYYY/MM/DD');
        const CurrentTime = dayjs().format('HH:mm');
        …………
        this.date = this.isScheduled() ? dayjs(this.attrs.draft.scheduledFor()).format('YYYY/MM/DD') : CurrentDate;
        …………

        <div className="Form-group ScheduleDraftModal-timeDateGroup">
        <input
        name="scheduledForDate"
        className="FormControl"
        type="date"
        min={CurrentDate}
        value={this.date.replaceAll('/','-')}
        onchange={(e) => (this.date = e.target.value.replaceAll('-','/'))}
        />
        …………

          19 days later
          2 months later

          I encountered a bug, not sure if it's caused by this extension:

          reproduce:
          save the draft of a post with tags and subtags.
          refresh the browser, then the draft will encounter error and sub tags will disappear.

          The error log in the console:

          forum.js?v=9d1a9396:1 TypeError: Cannot read properties of undefined (reading 'isQnA')
              at forum.js?v=9d1a9396:454:239931
              at Array.some (<anonymous>)
              at e.<anonymous> (forum.js?v=9d1a9396:454:239904)
              at Wr.forEach.t.<computed> (forum.js?v=9d1a9396:1:363194)
              at Wr.forEach.t.<computed> [as headerItems] (forum.js?v=9d1a9396:1:363164)
              at n.view (forum.js?v=9d1a9396:1:204942)
              at Wr.forEach.t.<computed> [as view] (forum.js?v=9d1a9396:1:363164)
              at Function.a (forum.js?v=9d1a9396:1:145079)
              at forum.js?v=9d1a9396:1:151518
              at p (forum.js?v=9d1a9396:1:151905)
            a month later

            Hey, I don't think anyone has asked or at least I can't find it in the search, the option "Use 'onOneServer()' directive for the task scheduler (requires Redis/Memcache)" what does it do?

            If I use Redis is it advisable to enable it, is there any benefit?

              18 days later

              1.2.0

              🩹 🐛 This is a bug squashing release

              Updating
              composer require fof/drafts
              php flarum cache:clear

              Darkle the option "Use 'onOneServer()' directive for the task scheduler (requires Redis/Memcache)" what does it do?

              When Flarum is running in a vertically scaled environment, this option will ensure only one Flarum instance publishes any pending drafts, rather than potentially two or more publishing the same content at the same time.

              For single instance Flarum installations, this option will do nothing..

              lichengkun135 reproduce:
              save the draft of a post with tags and subtags.
              refresh the browser, then the draft will encounter error and sub tags will disappear.

              The error log in the console:

              Thanks for the latest update! Unfortunately, this problem seems persists

              • IanM replied to this.

                IanM I tested again after clearing the cache, seems working now 😄 Thanks for the efforts!

                  Hi, the draft saving works perfectly for me when creating a new discussion, but during saving replying as a draft in a discussion, there will be errors like this:

                  [2022-12-03 01:11:42] flarum.ERROR: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null in /www/wwwroot/xxxx/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:117
                  Stack trace:
                  #0 /www/wwwroot/xxxx/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php(117): PDOStatement->execute()
                  #1 /www/wwwroot/xxxx/vendor/illuminate/database/Connection.php(501): Doctrine\DBAL\Driver\PDOStatement->execute()
                  #2 /www/wwwroot/xxxx/vendor/illuminate/database/Connection.php(705): Illuminate\Database\Connection->Illuminate\Database\{closure}()
                  #3 /www/wwwroot/xxxx/vendor/illuminate/database/Connection.php(672): Illuminate\Database\Connection->runQueryCallback()
                  #4 /www/wwwroot/xxxx/vendor/illuminate/database/Connection.php(502): Illuminate\Database\Connection->run()
                  #5 /www/wwwroot/xxxx/vendor/illuminate/database/Connection.php(454): Illuminate\Database\Connection->statement()
                  #6 /www/wwwroot/xxxx/vendor/illuminate/database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert()
                  #7 /www/wwwroot/xxxx/vendor/illuminate/database/Query/Builder.php(3028): Illuminate\Database\Query\Processors\Processor->processInsertGetId()
                  #8 /www/wwwroot/xxxx/vendor/illuminate/database/Eloquent/Builder.php(1657): Illuminate\Database\Query\Builder->insertGetId()
                  #9 /www/wwwroot/xxxx/vendor/illuminate/database/Eloquent/Model.php(1188): Illuminate\Database\Eloquent\Builder->__call()
                  #10 /www/wwwroot/xxxx/vendor/illuminate/database/Eloquent/Model.php(1153): Illuminate\Database\Eloquent\Model->insertAndSetId()
                  #11 /www/wwwroot/xxxx/vendor/illuminate/database/Eloquent/Model.php(994): Illuminate\Database\Eloquent\Model->performInsert()
                  ...

                    lichengkun135 Same problem on my forum those days (it's a freeflarum, in case it changes something)

                    • IanM replied to this.

                      1.2.2

                      Fixes saving of draft replies issue introduced in 1.2.0 TB54 lichengkun135

                      Updating
                      composer update fof/drafts
                      php flarum migrate
                      php flarum cache:clear
                      2 months later

                      Very useful extension, but it seems to have a bug.

                      1. start new discussion, fill in everything but don't assign any tags
                      2. save as draft
                      3. reload page and open created draft
                      4. click on "Post Discussion"
                      5. the overlay to assign tags to the discussion appears. If you now close and cancel, for example to change some text in the draft, you lose the entire draft.
                      2 months later

                      Saw this log in draft-publish log.
                      How to fix it.
                      thanks

                      Starting...
                      PHP Warning:  Undefined array key "discussion" in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      PHP Warning:  Trying to access array offset on value of type null in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      PHP Warning:  Trying to access array offset on value of type null in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      Publishing draft reply for discussion 
                      PHP Warning:  Undefined property: Flarum\Discussion\Event\Saving::$user in /var/www/flarum/vendor/ziiven/flarum-pay-to-see/src/Listeners/AddPayToSee.php on line 24
                      Published draft discussion: 936
                      PHP Warning:  Undefined array key "discussion" in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      PHP Warning:  Trying to access array offset on value of type null in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      PHP Warning:  Trying to access array offset on value of type null in /var/www/flarum/vendor/fof/drafts/src/Console/PublishDrafts.php on line 64
                      Publishing draft reply for discussion 

                        kebindong there's nothing in there you need to worry about. Those are messages for the extension developers but don't prevent the program from working as expected.

                        It's recommended to hide PHP warnings in php.ini in production.

                        Is there any issue with drafts not publishing correctly ?