Displaying message on module only on update?

Hello! I’m hoping to show release notes in my module when it’s updated, like so:

I only want this message to display once, then only appear again once there’s a new version. My first attempt looks like,

  UpdatesVisualizerWidget()
  {
    std::string path = asset::plugin(pluginInstance, "res/release_notes/groovebox.txt");
    std::ifstream ifs(path);

    // If the release notes cannot be found, this means that the file was already
    // viewed and renamed, so don't view it again.
    if(ifs.fail())
    {
      module->show_updates_visualizer = false;
    }
    // Show the release notes
    else
    {
      // Read the release notes from the file.  The release notes will be
      // displayed in the drawLayer(...) function
      release_notes.assign((std::istreambuf_iterator<char>(ifs)),
        (std::istreambuf_iterator<char>()) );

      // Rename updates file so it isn't shown next time the module is loaded
      std::string destination = asset::plugin(pluginInstance, "res/release_notes/groovebox_viewed.txt");
      if(std::rename(path.c_str(), destination.c_str()) != 0)
      {
        DEBUG("unable to rename file to ");
        DEBUG(destination.c_str());
      }
    }
  }

In short, the code is saying:

  • If the res/release_notes/groovebox.txt file exists, read the content, rename the file, and display the release notes.
  • Otherwise, don’t show the release notes.

Maybe I’m on the right track, but my attempt to rename the res/release_notes/groovebox.txt file is failing. I can’t tell if that’s because Rack doesn’t have permissions to update that file. Any suggestions would be much appreciated!

Thanks,
Bret

2 Likes

You could also do it by tracking a value in json. Basically increment a number every release. Then check when you load the module if the numbers dont match, and set a boolean the module you can use to know if you should show patchnotes.

I like your idea.

It looks like …

asset::user("PluginSlug.json")

…is the proper place to store information that’s shared amongst my modules. It also looks like there’s a way to read the current version: VCV Rack API: rack::plugin::Plugin Struct Reference

I should be able to store the latest version in a voxglitch.json file, and upon load, check if the version has changed. I’ll give it a shot!

1 Like

It might be nice to put an item on your right-click menu. So that a user can access the latest release notes if they missed them, or want to refer back to them.

4 Likes

Proper

In the short term, this might be the way I implement it. It’s surprisingly involved to create a system for tracking all of the module’s “newness”, and I don’t have time to sink into that right now. I might just have the right-click option to display the release notes. :+1:

VCV Rack already has this feature. Simply set "changelogUrl" in your plugin manifest.

2022-06-27T12:43:20-04:00

3 Likes

Ah ha! Thank you!

1 Like

Has that been there since 1.0?

No, version 1.1.6 doesn’t have it.

1 Like