#Pages disappear when versioning is turned on

1 messages · Page 1 of 1 (latest)

next hemlock
#

Hey! I think I must be doing something stupid, but every time I turn on versioning all my pages disappear from my collection. I suspect that its only showing published pages or something? How can I display my unpublished pages?

As soon as I disable versioning for the collection all the pages re-appear in the list. Also, possibly as a side effect of whatever I have done, server-side live preview only updates when I publish, not when it auto-saves (I know this because somehow at one point I had one of my pages displaying in the list but now its gone again 🤷‍♂️ )

I'm activating versioning using this in my collection:

 access: {
    read: ({ req }) => {
      // If there is a user logged in,
      // let them retrieve all documents
      if (req.user) return true;

      // If there is no user,
      // restrict the documents that are returned
      // to only those where `_status` is equal to `published`
      return {
        _status: {
          equals: "published"
        }
      };
    }
  },
  versions: {
    drafts: {
      autosave: {
        interval: 375
      }
    }
  },
undone trenchBOT
nimble mountain
#

Basically all your docs don't have a _status field yet (until you resave each of them).

You can either run a script that iterates over all docs in your collection and simply updates them with no changes (thus adding the _status field), or you can temporarily adjust your access control and go through and re-save them yourself manually.

next hemlock
#

I did try to do this and it didn't help, but I'm going to have another go 👍

#

Maybe I have to do it before enabling versions

next hemlock
#

Aha!

#

Thanks very much

#

Could this also be why live preview wasn't working with autosave?

daring cedar
#

Potentially yeah, not sure as there could be lots of things

next hemlock
#

How do I actually run that? It doesn't have an up and down so I guess its not a normal migration

daring cedar
#

Right that's for v2, idk if there's one that accounts for changes in v3, but if you don't have a lot of pages one thing you could do is grab the id's of each page and just navigate to them in the admin ui and hit publish

next hemlock
#

I just tried to do that, but there was no publish button 😦

#

I'll have another go

#

Ah, ok now I have a process that works

#

Thanks very much for your help

#

Luckily I only have 6 pages 🙂

#

Unfortunately live reload is still not working with autosave, only when I press publish. Any ideas what I can do to fix that?

#

This is my config:

    livePreview: {
      url: ({ data }) => {
        return `http://localhost:3000/${data.url}`;
      },
      breakpoints: [
        {
          label: "Mobile",
          name: "mobile",
          width: 480,
          height: 980
        },
        {
          label: "Desktop",
          name: "desktop",
          width: 1440,
          height: 900
        }
      ],
      collections: ["page"]
    }
#

Maybe its something to do with my url?

daring cedar
#

I would double check that url, maybe log it out to stdout before returning?

next hemlock
#

Its definitely correct, but maybe its the URL for the published version and not the latest draft version or something like that?

#

The pages have user-defineable URLs, so data.url is something that someone has actually entered into the page manually

#

i.e. its a text field on the collection

next hemlock
#

I was hoping 3.5.0 would fix it because there is something about live preview URLs but sadly not 😦