2
2
using UnityEngine ;
3
3
using UnityEditor ;
4
4
using System . Linq ;
5
+ using GitHub . Logging ;
5
6
6
7
namespace GitHub . Unity
7
8
{
@@ -70,19 +71,29 @@ public static void CheckForUpdates()
70
71
{
71
72
try
72
73
{
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 ;
77
77
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 ) )
80
81
{
81
- TaskManager . Instance . RunInUI ( ( ) =>
82
- {
83
- NotifyOfNewUpdate ( current , package ) ;
84
- } ) ;
82
+ LogHelper . Info ( "Skipping GitHub for Unity update v" + newVersion ) ;
83
+ return ;
85
84
}
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
+ } ) ;
86
97
}
87
98
catch ( Exception ex )
88
99
{
@@ -103,7 +114,6 @@ private static void NotifyOfNewUpdate(TheVersion currentVersion, Package package
103
114
private const string windowTitle = "GitHub for Unity Update Check" ;
104
115
private const string newUpdateMessage = "There is a new version of GitHub for Unity available.\n \n Current version is {0}\n New version is {1}" ;
105
116
private const string skipThisVersionMessage = "Skip new version" ;
106
- private const string remingMeTomorrowMessage = "Remind me tomorrow" ;
107
117
private const string downloadNewVersionMessage = "Download new version" ;
108
118
private const string browseReleaseNotes = "Browse the release notes" ;
109
119
@@ -112,7 +122,6 @@ private static void NotifyOfNewUpdate(TheVersion currentVersion, Package package
112
122
private static GUIContent guiPackageReleaseNotes ;
113
123
private static GUIContent guiPackageMessage ;
114
124
private static GUIContent guiSkipThisVersion ;
115
- private static GUIContent guiRemindMeTomorrow ;
116
125
private static GUIContent guiDownloadNewVersion ;
117
126
private static GUIContent guiBrowseReleaseNotes ;
118
127
@@ -188,14 +197,6 @@ private void OnGUI()
188
197
this . Close ( ) ;
189
198
}
190
199
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
-
199
200
EditorGUILayout . EndHorizontal ( ) ;
200
201
EditorGUILayout . EndVertical ( ) ;
201
202
@@ -214,7 +215,6 @@ private void LoadContents()
214
215
guiLogo = new GUIContent ( Styles . BigLogo ) ;
215
216
guiNewUpdate = new GUIContent ( String . Format ( newUpdateMessage , currentVersion , package . Package . Version . ToString ( ) ) ) ;
216
217
guiSkipThisVersion = new GUIContent ( skipThisVersionMessage ) ;
217
- guiRemindMeTomorrow = new GUIContent ( remingMeTomorrowMessage ) ;
218
218
guiDownloadNewVersion = new GUIContent ( downloadNewVersionMessage ) ;
219
219
guiBrowseReleaseNotes = new GUIContent ( browseReleaseNotes ) ;
220
220
hasMessage = ! String . IsNullOrEmpty ( package . Package . Message ) ;
0 commit comments