@@ -42,42 +42,62 @@ let authorizeKey (context : vscode.ExtensionContext) key =
4242 ax.post( " https://api.gumroad.com/v2/licenses/verify" , args)
4343 |> Promise.map ( fun n ->
4444 let res = n.data
45- let dataS = unbox< string> res?purchase?created_ at
46- let data = dataS.Substring( 0 , 10 )
47- context.globalState.update( " productDate" , data)
48- data
45+ if !! res?purchase?subscription_ cancelled_ at = null && !! res?purchase?subscription_ failed_ at = null then
46+ context.globalState.update( " lastTimeCheck" , DateTime.Now.ToShortDateString())
47+ true
48+ else
49+ false
4950 )
5051
5152let checkKey ( context : vscode.ExtensionContext ) =
5253 let uri = vscode.Uri.parse " https://gumroad.com/l/NeptunePlugin"
5354 match context.globalState.get " productKey" with
5455 | Some key ->
55- match context.globalState.get " productDate " with
56+ match context.globalState.get " lastTimeCheck " with
5657 | Some s ->
5758 let d = DateTime.Parse s
58- let shouldCheck = DateTime.Now >= d.AddDays( 1 .)
59+ let shouldCheck = DateTime.Now >= d.AddDays( 3 .)
5960 if shouldCheck then
6061 authorizeKey context key
6162 |> Promise.either
6263 ( fun data ->
63- let ds = DateTime.Parse data
64- if DateTime.Now <= ds.AddDays( 1. ) then
64+ if data then
6565 Promise.lift true
6666 else
67- vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired." , " Buy Neptune" )
67+ vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired." , " Buy Neptune" , " Enter License " )
6868 |> Promise.onSuccess ( fun n ->
6969 if n = " Buy Neptune" then
7070 vscode.commands.executeCommand( " vscode.open" , uri)
7171 |> ignore
72+ elif n = " Enter License" then
73+ let opts = createEmpty< InputBoxOptions>
74+ opts.prompt <- Some " License Key"
75+ vscode.window.showInputBox( opts)
76+ |> Promise.onSuccess ( fun n ->
77+ if JS.isDefined n then
78+ context.globalState.update( " productKey" , n)
79+ |> ignore
80+
81+ ) |> ignore
7282 )
7383 |> ignore
7484 Promise.lift false )
7585 ( fun _ ->
76- vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired." , " Buy Neptune" )
86+ vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired." , " Buy Neptune" , " Enter License " )
7787 |> Promise.onSuccess ( fun n ->
7888 if n = " Buy Neptune" then
7989 vscode.commands.executeCommand( " vscode.open" , uri)
8090 |> ignore
91+ elif n = " Enter License" then
92+ let opts = createEmpty< InputBoxOptions>
93+ opts.prompt <- Some " License Key"
94+ vscode.window.showInputBox( opts)
95+ |> Promise.onSuccess ( fun n ->
96+ if JS.isDefined n then
97+ context.globalState.update( " productKey" , n)
98+ |> ignore
99+
100+ ) |> ignore
81101 )
82102 |> ignore
83103 Promise.lift false )
@@ -88,8 +108,7 @@ let checkKey (context : vscode.ExtensionContext) =
88108 authorizeKey context key
89109 |> Promise.either
90110 ( fun data ->
91- let ds = DateTime.Parse data
92- if DateTime.Now <= ds.AddDays( 1. ) then
111+ if data then
93112 Promise.lift true
94113 else
95114 vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired." , " Buy Neptune" )
@@ -101,7 +120,7 @@ let checkKey (context : vscode.ExtensionContext) =
101120 |> ignore
102121 Promise.lift false )
103122 ( fun _ ->
104- vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired. " , " Buy Neptune" )
123+ vscode.window.showWarningMessage( " Neptune is paid extension. Your subscription has expired" , " Buy Neptune" )
105124 |> Promise.onSuccess ( fun n ->
106125 if n = " Buy Neptune" then
107126 vscode.commands.executeCommand( " vscode.open" , uri)
@@ -132,7 +151,7 @@ let checkKey (context : vscode.ExtensionContext) =
132151 vscode.window.showInputBox( opts)
133152 |> Promise.onSuccess ( fun n ->
134153 if JS.isDefined n then
135- context.globalState.update( " productDate " , n)
154+ context.globalState.update( " productKey " , n)
136155 |> ignore
137156
138157 ) |> ignore
@@ -152,7 +171,7 @@ let checkKey (context : vscode.ExtensionContext) =
152171 vscode.window.showInputBox( opts)
153172 |> Promise.onSuccess ( fun n ->
154173 if JS.isDefined n then
155- context.globalState.update( " productDate " , n)
174+ context.globalState.update( " productKey " , n)
156175 |> ignore
157176
158177 ) |> ignore
@@ -166,7 +185,6 @@ let activate (context : vscode.ExtensionContext) =
166185 let df = createEmpty< DocumentFilter>
167186 df.language <- Some " fsharp"
168187 let df ' : DocumentSelector = df |> U3.Case2
169-
170188 notifyTelemetry context |> ignore
171189 checkKey context
172190 |> Promise.onSuccess ( fun n ->
0 commit comments