Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 8696dd4

Browse files
committed
Tweak the update check UI
1 parent 77317e1 commit 8696dd4

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UpdateCheck.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using UnityEngine;
33
using UnityEditor;
44
using System.Linq;
5+
using GitHub.Logging;
56

67
namespace GitHub.Unity
78
{
@@ -70,19 +71,29 @@ public static void CheckForUpdates()
7071
{
7172
try
7273
{
73-
var package = result.ReadAllText().FromJson<Package>(lowerCase: true, onlyPublic: false);
74-
var current = TheVersion.Parse(ApplicationInfo.Version);
75-
var versionsToSkip = EntryPoint.ApplicationManager.UserSettings.Get<TheVersion[]>(Constants.SkipVersionKey, new TheVersion[] { });
76-
var newVersion = package.Version;
74+
Package package = result.ReadAllText().FromJson<Package>(lowerCase: true, onlyPublic: false);
75+
TheVersion current = TheVersion.Parse(ApplicationInfo.Version);
76+
TheVersion newVersion = package.Version;
7777

78-
Debug.LogFormat("newVersion:{0} current:{1} versionsToSkip:{2}", newVersion, current, versionsToSkip != null ? versionsToSkip.Length : 0);
79-
if (newVersion > current && (!versionsToSkip.Any(x => x == newVersion)))
78+
TheVersion[] versionsToSkip = EntryPoint.ApplicationManager.UserSettings.Get<TheVersion[]>(Constants.SkipVersionKey);
79+
versionsToSkip = versionsToSkip == null ? new TheVersion[] {} : versionsToSkip;
80+
if (versionsToSkip.Any(x => x == newVersion))
8081
{
81-
TaskManager.Instance.RunInUI(() =>
82-
{
83-
NotifyOfNewUpdate(current, package);
84-
});
82+
LogHelper.Info("Skipping GitHub for Unity update v" + newVersion);
83+
return;
8584
}
85+
86+
if (newVersion <= current)
87+
{
88+
LogHelper.Trace("Skipping GitHub for Unity update v" + newVersion + ", we already have it");
89+
return;
90+
}
91+
92+
93+
TaskManager.Instance.RunInUI(() =>
94+
{
95+
NotifyOfNewUpdate(current, package);
96+
});
8697
}
8798
catch(Exception ex)
8899
{
@@ -103,7 +114,6 @@ private static void NotifyOfNewUpdate(TheVersion currentVersion, Package package
103114
private const string windowTitle = "GitHub for Unity Update Check";
104115
private const string newUpdateMessage = "There is a new version of GitHub for Unity available.\n\nCurrent version is {0}\nNew version is {1}";
105116
private const string skipThisVersionMessage = "Skip new version";
106-
private const string remingMeTomorrowMessage = "Remind me tomorrow";
107117
private const string downloadNewVersionMessage = "Download new version";
108118
private const string browseReleaseNotes = "Browse the release notes";
109119

@@ -112,7 +122,6 @@ private static void NotifyOfNewUpdate(TheVersion currentVersion, Package package
112122
private static GUIContent guiPackageReleaseNotes;
113123
private static GUIContent guiPackageMessage;
114124
private static GUIContent guiSkipThisVersion;
115-
private static GUIContent guiRemindMeTomorrow;
116125
private static GUIContent guiDownloadNewVersion;
117126
private static GUIContent guiBrowseReleaseNotes;
118127

@@ -188,14 +197,6 @@ private void OnGUI()
188197
this.Close();
189198
}
190199

191-
if (GUILayout.Button(guiRemindMeTomorrow, GUILayout.Width(200)))
192-
{
193-
var settings = EntryPoint.ApplicationManager.UserSettings;
194-
var tomorrow = DateTimeOffset.Now.AddDays(1).ToString(Constants.Iso8601Format);
195-
settings.Set<string>(Constants.UpdateReminderDateKey, tomorrow);
196-
this.Close();
197-
}
198-
199200
EditorGUILayout.EndHorizontal();
200201
EditorGUILayout.EndVertical();
201202

@@ -214,7 +215,6 @@ private void LoadContents()
214215
guiLogo = new GUIContent(Styles.BigLogo);
215216
guiNewUpdate = new GUIContent(String.Format(newUpdateMessage, currentVersion, package.Package.Version.ToString()));
216217
guiSkipThisVersion = new GUIContent(skipThisVersionMessage);
217-
guiRemindMeTomorrow = new GUIContent(remingMeTomorrowMessage);
218218
guiDownloadNewVersion = new GUIContent(downloadNewVersionMessage);
219219
guiBrowseReleaseNotes = new GUIContent(browseReleaseNotes);
220220
hasMessage = !String.IsNullOrEmpty(package.Package.Message);

0 commit comments

Comments
 (0)