14 days later

For some reason, the draft will save once, then future ones bring up a permission_denied error.
Debug Output

fof/drafts: 0.1.11
Flarum 0.1.0-beta.13
PHP: 7.3.19


    Working great on my forum. However small enhancement idea: Only save the draft when something has changed in the recent. If the message hasn't been changed, there are still useless requests being fired to the server.

    Additionally, when the message is being discarded, the draft could be deleted as well.

    Kulga sakibarifin I've been a bit confused by this for a while, as I can't seem to replicate it. One new step I've gotten to is that the issue is being caused here:

    if ($actor->id !== $draft->user_id) {
         throw new PermissionDeniedException();
     }

    Is there any reason why you might be editing the draft of another user? Perhaps you might be using fof impersonate or something else? Could you check that the draft's user_id field corresponds with the user's id?

      Kulga sakibarifin

      0.1.12

      • Fix permission denied error when saving an updated draft.

      askvortsov The issue was that the draft user_id is sometimes a string so that check would fail due to int comparing to string. I just evaluated both values to an int.

        I'm not sure if it it's just me but a lot of the time a draft will not go away after I posted a reply. I'm using pusher together with drafts with automatic draft saving every 6 seconds.

          nixpc I think I'm experiencing the same here since we enabled the extension on Discuss. My drafts are filling up even though I didn't manually save any.

            12 days later

            screenshot

            There seems to be a issue when using Polls and Dafts: a long title will get behind the save button. I was about to open an issue on GitHub, but I don't know if this should be on Drafts or Polls...

            I tried to fix it with these lines of LESS code, I'm not sure if this is the best way to do it though...

            @media @tablet-up {
            	.ComposerBody-header {
            		// restets the default value, the margin will come from each individual element, this way when there
            		// is a second line, the elements have a gap betwen them.
            		margin: 0;
            		& > li {
            			margin-bottom: 10px;
            		}
            
            		// We want to prevent the items from this container to go too much to the right.
            		// Therefore we add a floated element that will make elements that don't fit break to the next line.
            		&:before {
            			content: '';
            			float: right;
            			width: 144px; // width of `$('.Composer-controls')`
            			height: 1px; // if not set, the :before element has no effect
            			visibility: hidden;
            		}
            	}
            }
            a month later

            Kyrne Very nice! I had implemented a dirty workaround to make such a thing, but now tI can rewrite in a clean way! Thank you 🙏

            Kyrne I'm wondering why the extra flied is so limited in the DB ('length' => 255). To make it more flexible, this extra field could be a blob (as it is for the users.preferences field).

            (I had no problems with length yet, but I just think about possible future issues...)

            Can we have a button to let user delete all draft at once?

            4 days later

            @Kyrne Loading icon that inside of draft window is appearing when I click discard removing article.

            2 months later

            Having some issues today with this extension today:

            TypeError: Cannot read property 'substring' of undefined
            at truncate(webpack://@flarum/core/./src/common/utils/string.js:10:44)
            at ? (webpack://@fof/drafts/./src/forum/components/DraftsList.js:82:90)
            at Array.map(<anonymous>)
            at view(webpack://@fof/drafts/./src/forum/components/DraftsList.js:46:36)
            at render(webpack://@flarum/core/./src/common/Component.js:100:61)
            at getMenu(webpack://@flarum/core/./src/forum/components/NotificationsDropdown.js:47:35)
            at view(webpack://@flarum/core/./src/common/components/Dropdown.js:42:15)
            at render(webpack://@flarum/core/./src/common/Component.js:100:61)
            at view(webpack://@flarum/core/./src/common/Component.js:186:24)
            at checkView(webpack://@flarum/core/./node_modules/mithril/mithril.js:806:16)
            at markViews(webpack://@flarum/core/./node_modules/mithril/mithril.js:822:11)
            at buildObject(webpack://@flarum/core/./node_modules/mithril/mithril.js:847:10)
            at build(webpack://@flarum/core/./node_modules/mithril/mithril.js:1000:11)
            at buildArray(webpack://@flarum/core/./node_modules/mithril/mithril.js:630:15)
            at build(webpack://@flarum/core/./node_modules/mithril/mithril.js:989:11)
            at buildUpdatedNode(webpack://@flarum/core/./node_modules/mithril/mithril.js:469:21)
            at buildObject(webpack://@flarum/core/./node_modules/mithril/mithril.js:891:11)
            at build(webpack://@flarum/core/./node_modules/mithril/mithril.js:1000:11)
            at buildArray(webpack://@flarum/core/./node_modules/mithril/mithril.js:630:15)
            at build(webpack://@flarum/core/./node_modules/mithril/mithril.js:989:11)
            at buildUpdatedNode(webpack://@flarum/core/./node_modules/mithril/mithril.js:469:21)
            at buildObject(webpack://@flarum/core/./node_modules/mithril/mithril.js:891:11)
            at build(webpack://@flarum/core/./node_modules/mithril/mithril.js:1000:11)
            at render(webpack://@flarum/core/./node_modules/mithril/mithril.js:1340:19)
            at f(webpack://@flarum/core/./node_modules/mithril/mithril.js:1567:7)
            at forEach(webpack://@flarum/core/./node_modules/mithril/mithril.js:189:39)
            at redraw(webpack://@flarum/core/./node_modules/mithril/mithril.js:1563:3)

              MikeJones after some quick testing I disabled the recahe plugin and this one is workign fine again. @Kyrne looks like recache doesnt play nice with fof/drafts.

                MikeJones Looks like it's not a recache issue. Likely one of those disguised issues.

                0.2.0

                • Beta 14 ready 🥳
                Updating
                composer require fof/drafts
                php flarum cache:clear

                  karaok omg Thank youu!!! so many extensions suddently updated to beta 14 😄 😆 😁 🤗 ❤️ (I hope the next one on the list is POLLS >.<)

                    16 days later

                    Ideas 💡

                    • Don’t save blank drafts or drafts with only a few characters.
                    • Auto-delete super old drafts (optional setting)

                    Edit: Could be as simple as event listening for keyboard activity as step 1. No keyboard activity, no reason to trigger saving. I don’t know though. Just throwing thoughts out into the realm of FoF devs. Or, could be that the code says... do not start saving for at least 30 seconds no matter what. But I guess the ultimate solution might be if the code could say... if someone clicks the X and discards a draft, then it should be discarded. Because there’s a warning message too... if you don’t type much, exit the composer, then click the final X to discard the draft, plus say OK to the warning pop up, then you lose your draft. Sorry, but you had plenty of opportunities to instead do something else.

                      010101

                      I like these ideas, I always have blank drafts and old ones I need to go clean up regularly.

                      I'm going to turn Drafts off in Beta 14, it is saving way too many drafts (and multiples for the same thread).

                        10 days later

                        I don't think this extension is all that useful or necessary for a forum. The draft saves as long as you don't leave the page as a feature from Core.

                        @MikeJones

                        What other extensions holding you back?

                          cmwetherell I don't think this extension is all that useful or necessary for a forum. The draft saves as long as you don't leave the page as a feature from Core.

                          When you use your flarum as a blog this extension is super useful.

                          I am waiting on bbcode details but apparently it doesn't need to be updated but that makes me nervous for some reason lol

                          I still need to check if the upload extension has been updated.

                          I don't think Cookie consent has been updated either.

                          Lastly recache but I think that will be updated soon 😃

                            MikeJones Upload works. BBCode stuff didn't break with beta14. Drafts works, it’s just that sometimes a post may be saved as a draft that you didn’t want to save. But, I think this happened before with past versions of Drafts.

                            Another idea for this extension: add a setting so that one can turn auto save off. You must manually tap save in order to save a draft. This prevents drafts with just a few words from being saved. But, if you’re writing a very long post, you still benefit from manually saving at times.

                            MikeJones

                            I asked (I can't find the post for some reason) and luceos and tannerkiller assured me that BBCode was compatible, they just didn't tag an update for Beta 14. My forum is currently on 14.1 with bbcode enabled and bbcode works fine.

                            I think Upload has been updated, since I am using it on 14.1 🙂

                            0.2.1

                            • Replace deprecated code with new equivalents (one eye on beta 15 😉 )
                            Updating
                            composer require fof/drafts