| 71 | } |
| 72 | |
| 73 | void UpdateCheck::checkForUpdate(bool inShowNotificationOnLatestVersion) |
| 74 | { |
| 75 | // Call async because of issue on Windows with spinning cursor. |
| 76 | MessageManager::callAsync([this, inShowNotificationOnLatestVersion] { |
| 77 | Thread::launch([this,inShowNotificationOnLatestVersion] { |
| 78 | const URL url("https://api.github.com/repos/DamRsn/NeuralNote/releases/latest"); |
| 79 | |
| 80 | const auto result = url.readEntireTextStream(); |
| 81 | |
| 82 | if (result.isEmpty()) { |
| 83 | return; |
| 84 | } |
| 85 | |
| 86 | auto json = JSON::parse(result); |
| 87 | |
| 88 | if (json.isObject()) { |
| 89 | const auto current_version_str = String("v") + String(JucePlugin_VersionString).trim(); |
| 90 | |
| 91 | // Uncomment this line to test the new version available notification |
| 92 | // const auto current_version_str = String("v0.0.1"); |
| 93 | |
| 94 | const auto latest_version = json.getProperty("tag_name", "unknown").toString().trim(); |
| 95 | |
| 96 | MessageManager::callAsync( |
| 97 | [current_version_str, latest_version, inShowNotificationOnLatestVersion, this] { |
| 98 | if (!current_version_str.equalsIgnoreCase(latest_version)) { |
| 99 | _showNewVersionAvailableNotification(); |
| 100 | } else if (inShowNotificationOnLatestVersion) { |
| 101 | _showOnLatestVersionNotification(); |
| 102 | } |
| 103 | }); |
| 104 | } else { |
| 105 | jassertfalse; |
| 106 | } |
| 107 | }); |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | void UpdateCheck::_showNewVersionAvailableNotification() |
| 112 | { |