on master help sign in
Fix messages not being received by threading poll cursor through client state
fa9d38aiko
client/ApiClient.fs+3−3
@@ -81,16 +81,16 @@ module ApiClient =
81 c.Timeout <- System.Threading.Timeout.InfiniteTimeSpan
81 c.Timeout <- System.Threading.Timeout.InfiniteTimeSpan
82 c
82 c
83
83
84− let poll (serverUrl: string) (token: string) =
84+ let poll (serverUrl: string) (token: string) (cursor: int64) =
85 async {
85 async {
86− let request = new HttpRequestMessage(HttpMethod.Get, $"{serverUrl}/poll?timeout=30")
86+ let request = new HttpRequestMessage(HttpMethod.Get, $"{serverUrl}/poll?cursor={cursor}&timeout=30")
87 request.Headers.Add("Authorization", $"Bearer {token}")
87 request.Headers.Add("Authorization", $"Bearer {token}")
88
88
89 let! response = pollClient.SendAsync(request) |> Async.AwaitTask
89 let! response = pollClient.SendAsync(request) |> Async.AwaitTask
90 let! text = response.Content.ReadAsStringAsync() |> Async.AwaitTask
90 let! text = response.Content.ReadAsStringAsync() |> Async.AwaitTask
91 let doc = JsonDocument.Parse(text)
91 let doc = JsonDocument.Parse(text)
92 let root = expectObject doc "/poll"
92 let root = expectObject doc "/poll"
93− let cursor = root.GetProperty("cursor").GetString()
93+ let cursor = root.GetProperty("cursor").GetInt64()
94
94
95 // Knot runtime wraps relations as [[record1, record2, ...]]
95 // Knot runtime wraps relations as [[record1, record2, ...]]
96 let eventsOuter = root.GetProperty("events")
96 let eventsOuter = root.GetProperty("events")
client/App.fs+16−14
@@ -46,7 +46,8 @@ module App =
46 ComposeText: string
46 ComposeText: string
47 NewPubkey: string
47 NewPubkey: string
48 NewNickname: string
48 NewNickname: string
49− Error: string option }
49+ Error: string option
50+ PollCursor: int64 }
50
51
51 // ── Msg ──
52 // ── Msg ──
52
53
@@ -66,7 +67,7 @@ module App =
66 | SetNewNickname of string
67 | SetNewNickname of string
67 | DoSaveContact
68 | DoSaveContact
68 | DoDeleteContact of string
69 | DoDeleteContact of string
69− | PollResult of (string * string * int64 * string) list * string
70+ | PollResult of (string * string * int64 * string) list * string * int64
70 | DoPoll
71 | DoPoll
71 | CopyPubKey
72 | CopyPubKey
72 | DismissError
73 | DismissError
@@ -84,7 +85,7 @@ module App =
84 pubKeyHex: string *
85 pubKeyHex: string *
85 recipPubHex: string *
86 recipPubHex: string *
86 text: string
87 text: string
87− | CmdPoll of url: string * token: string * privKey: byte[]
88+ | CmdPoll of url: string * token: string * privKey: byte[] * cursor: int64
88 | CmdCopyToClipboard of string
89 | CmdCopyToClipboard of string
89
90
90 // ── Helpers ──
91 // ── Helpers ──
@@ -112,7 +113,8 @@ module App =
112 ComposeText = ""
113 ComposeText = ""
113 NewPubkey = ""
114 NewPubkey = ""
114 NewNickname = ""
115 NewNickname = ""
115− Error = None },
116+ Error = None
117+ PollCursor = 0L },
116 []
118 []
117
119
118 // ── Update ──
120 // ── Update ──
@@ -143,7 +145,7 @@ module App =
143 Conn = Online token
145 Conn = Online token
144 Page = Conversations
146 Page = Conversations
145 Error = None },
147 Error = None },
146− [ CmdPoll(model.ServerUrl, token, model.PrivKey.Value) ]
148+ [ CmdPoll(model.ServerUrl, token, model.PrivKey.Value, model.PollCursor) ]
147
149
148 | AuthErr err -> { model with Conn = Offline; Error = Some err }, []
150 | AuthErr err -> { model with Conn = Offline; Error = Some err }, []
149
151
@@ -170,7 +172,7 @@ module App =
170
172
171 | Sent _ -> model, []
173 | Sent _ -> model, []
172
174
173− | PollResult(incoming, status) ->
175+ | PollResult(incoming, status, newCursor) ->
174 let model' =
176 let model' =
175 incoming
177 incoming
176 |> List.fold
178 |> List.fold
@@ -195,15 +197,15 @@ module App =
195 { m with
197 { m with
196 Contacts = contacts
198 Contacts = contacts
197 Messages = m.Messages |> Map.add fromPk (msgs @ [ newMsg ]) })
199 Messages = m.Messages |> Map.add fromPk (msgs @ [ newMsg ]) })
198− { model with PollStatus = status }
200+ { model with PollStatus = status; PollCursor = newCursor }
199
201
200 match model'.Conn with
202 match model'.Conn with
201− | Online token -> model', [ CmdPoll(model'.ServerUrl, token, model'.PrivKey.Value) ]
203+ | Online token -> model', [ CmdPoll(model'.ServerUrl, token, model'.PrivKey.Value, model'.PollCursor) ]
202 | _ -> model', []
204 | _ -> model', []
203
205
204 | DoPoll ->
206 | DoPoll ->
205 match model.Conn, model.PrivKey with
207 match model.Conn, model.PrivKey with
206− | Online token, Some priv -> model, [ CmdPoll(model.ServerUrl, token, priv) ]
208+ | Online token, Some priv -> model, [ CmdPoll(model.ServerUrl, token, priv, model.PollCursor) ]
207 | _ -> model, []
209 | _ -> model, []
208
210
209 | SetNewPubkey pk -> { model with NewPubkey = pk }, []
211 | SetNewPubkey pk -> { model with NewPubkey = pk }, []
@@ -294,10 +296,10 @@ module App =
294 return DismissError // TODO: show send errors properly
296 return DismissError // TODO: show send errors properly
295 })
297 })
296
298
297− | CmdPoll(url, token, privKey) ->
299+ | CmdPoll(url, token, privKey, cursor) ->
298 asyncCmd (async {
300 asyncCmd (async {
299 try
301 try
300− let! (events, _) = ApiClient.poll url token
302+ let! (events, newCursor) = ApiClient.poll url token cursor
301 let messages = ResizeArray()
303 let messages = ResizeArray()
302 let ackIds = ResizeArray()
304 let ackIds = ResizeArray()
303 let errors = ResizeArray()
305 let errors = ResizeArray()
@@ -335,15 +337,15 @@ module App =
335 $"[{now}] evts:{events.Length} msgs:{messages.Count} errs:{errors.Count}"
337 $"[{now}] evts:{events.Length} msgs:{messages.Count} errs:{errors.Count}"
336 + (if errors.Count > 0 then $" [{errors.[0]}]" else "")
338 + (if errors.Count > 0 then $" [{errors.[0]}]" else "")
337
339
338− return PollResult(Seq.toList messages, status)
340+ return PollResult(Seq.toList messages, status, newCursor)
339 with
341 with
340 | :? System.Threading.Tasks.TaskCanceledException ->
342 | :? System.Threading.Tasks.TaskCanceledException ->
341 // Normal timeout from long poll — just retry
343 // Normal timeout from long poll — just retry
342− return PollResult([], "polling...")
344+ return PollResult([], "polling...", cursor)
343 | ex ->
345 | ex ->
344 let now = DateTimeOffset.UtcNow.ToString("HH:mm:ss")
346 let now = DateTimeOffset.UtcNow.ToString("HH:mm:ss")
345 do! Async.Sleep 3000
347 do! Async.Sleep 3000
346− return PollResult([], $"[{now}] poll error: {ex.Message}")
348+ return PollResult([], $"[{now}] poll error: {ex.Message}", cursor)
347 })
349 })
348
350
349 | CmdCopyToClipboard text ->
351 | CmdCopyToClipboard text ->
client/bin/Debug/net10.0-ios/iossimulator-arm64/Skrepka.app/Skrepka.dll

Binary file not shown.

client/bin/Debug/net10.0-ios/iossimulator-arm64/Skrepka.app/Skrepka.pdb

Binary file not shown.

client/bin/Debug/net10.0-ios/iossimulator-arm64/Skrepka.app/_CodeSignature/CodeResources+4−4
@@ -162,11 +162,11 @@
162 </data>
162 </data>
163 <key>Skrepka.dll</key>
163 <key>Skrepka.dll</key>
164 <data>
164 <data>
165− cLMiN59WETvez5dx0uXUZoSTPb4=
165+ ihxkdJmILCX2rvNfx8IAKfrjiRw=
166 </data>
166 </data>
167 <key>Skrepka.pdb</key>
167 <key>Skrepka.pdb</key>
168 <data>
168 <data>
169− ldyZfrWrMd9ycj/oEBvJhDAsVME=
169+ 5Ef95J0Y0SPaPbiv94B4OI5dvt4=
170 </data>
170 </data>
171 <key>Sodium.Core.dll</key>
171 <key>Sodium.Core.dll</key>
172 <data>
172 <data>
@@ -1382,14 +1382,14 @@
1382 <dict>
1382 <dict>
1383 <key>hash2</key>
1383 <key>hash2</key>
1384 <data>
1384 <data>
1385− t+CLPQktYsiTOLd72KrLk+9R6smlb9kRcl3LVv+EYBY=
1385+ jA699ETKlhsSyP0dr9yKgsVa246KniFBNn6h+H093lI=
1386 </data>
1386 </data>
1387 </dict>
1387 </dict>
1388 <key>Skrepka.pdb</key>
1388 <key>Skrepka.pdb</key>
1389 <dict>
1389 <dict>
1390 <key>hash2</key>
1390 <key>hash2</key>
1391 <data>
1391 <data>
1392− GvVY1szkv9OBBCgEdAZqPqj+Taow0e372j3aKZx1csQ=
1392+ 9xCu8W4xbM0EJu+r0fyBhBs95Lz7i0LEqYeCvuPHiYQ=
1393 </data>
1393 </data>
1394 </dict>
1394 </dict>
1395 <key>Sodium.Core.dll</key>
1395 <key>Sodium.Core.dll</key>
client/bin/Debug/net10.0-ios/iossimulator-arm64/Skrepka.dll

Binary file not shown.

client/bin/Debug/net10.0-ios/iossimulator-arm64/Skrepka.pdb

Binary file not shown.

client/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.app/Contents/MonoBundle/Skrepka.dll

Binary file not shown.

client/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.app/Contents/MonoBundle/Skrepka.pdb

Binary file not shown.

client/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.app/Contents/_CodeSignature/CodeResources+2−2
@@ -240,14 +240,14 @@
240 <dict>
240 <dict>
241 <key>hash2</key>
241 <key>hash2</key>
242 <data>
242 <data>
243− 0IwboWcxGg+igGOs/iPuXTnkrFWofjpU2HruAF/Cz1Y=
243+ SkrTLt6NpdxkCOrg3x+0va15w21CQqSaHXDAj+klfQY=
244 </data>
244 </data>
245 </dict>
245 </dict>
246 <key>MonoBundle/Skrepka.pdb</key>
246 <key>MonoBundle/Skrepka.pdb</key>
247 <dict>
247 <dict>
248 <key>hash2</key>
248 <key>hash2</key>
249 <data>
249 <data>
250− aaf14lJ3aUAY1W3Za3iFIIq7GWlqrVjZxVYmH/Px/ps=
250+ 1pt18PVRQANYqIOx8PEoowFdG5ubKia23BbX/3qPn2Q=
251 </data>
251 </data>
252 </dict>
252 </dict>
253 <key>MonoBundle/Sodium.Core.dll</key>
253 <key>MonoBundle/Sodium.Core.dll</key>
client/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.dll

Binary file not shown.

client/bin/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.pdb

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/Skrepka.AssemblyInfo.fs+1−1
@@ -10,7 +10,7 @@ open System.Reflection
10[<assembly: System.Reflection.AssemblyCompanyAttribute("Skrepka")>]
10[<assembly: System.Reflection.AssemblyCompanyAttribute("Skrepka")>]
11[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
11[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
12[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
12[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
13−[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0+346c12ecffe87438fdad84bea4dff973f4fc9eec")>]
13+[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0+1025ec42bdc63a36e82c2b05547b3ddfc72a0761")>]
14[<assembly: System.Reflection.AssemblyProductAttribute("Skrepka")>]
14[<assembly: System.Reflection.AssemblyProductAttribute("Skrepka")>]
15[<assembly: System.Reflection.AssemblyTitleAttribute("Skrepka")>]
15[<assembly: System.Reflection.AssemblyTitleAttribute("Skrepka")>]
16[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
16[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
client/obj/Debug/net10.0-ios/iossimulator-arm64/Skrepka.AssemblyInfoInputs.cache+1−1
@@ -1 +1 @@
1−6a753f697574f344344f60a7ce91110bcf66456ca91f9a28f3d6610430ec814d
1+608be3485c5b02f0859bc57c944a7d90f027c871f4620f1b2625c376aa40ab39
client/obj/Debug/net10.0-ios/iossimulator-arm64/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/Skrepka.pdb

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/Skrepka.sourcelink.json+1−1
@@ -1 +1 @@
1−{"documents":{"/Users/iko/Developer/skrepka/*":"https://raw.githubusercontent.com/ilyakooo0/skrepka/346c12ecffe87438fdad84bea4dff973f4fc9eec/*"}}
1+{"documents":{"/Users/iko/Developer/skrepka/*":"https://raw.githubusercontent.com/ilyakooo0/skrepka/1025ec42bdc63a36e82c2b05547b3ddfc72a0761/*"}}
client/obj/Debug/net10.0-ios/iossimulator-arm64/linked/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/linked/Skrepka.pdb

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/ref/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-ios/iossimulator-arm64/refint/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.AssemblyInfo.fs+1−1
@@ -10,7 +10,7 @@ open System.Reflection
10[<assembly: System.Reflection.AssemblyCompanyAttribute("Skrepka")>]
10[<assembly: System.Reflection.AssemblyCompanyAttribute("Skrepka")>]
11[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
11[<assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")>]
12[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
12[<assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")>]
13−[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0+346c12ecffe87438fdad84bea4dff973f4fc9eec")>]
13+[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0+1025ec42bdc63a36e82c2b05547b3ddfc72a0761")>]
14[<assembly: System.Reflection.AssemblyProductAttribute("Skrepka")>]
14[<assembly: System.Reflection.AssemblyProductAttribute("Skrepka")>]
15[<assembly: System.Reflection.AssemblyTitleAttribute("Skrepka")>]
15[<assembly: System.Reflection.AssemblyTitleAttribute("Skrepka")>]
16[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
16[<assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")>]
client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.AssemblyInfoInputs.cache+1−1
@@ -1 +1 @@
1−a4046d7b839a68f608d1c269bcb1a56b4af044b840ddb7c5384c5348a63f2bce
1+6ce084ea2001e68a95078f1ad7ce56a873907d46e9df803c23a3c8e674e8ede8
client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.pdb

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/Skrepka.sourcelink.json+1−1
@@ -1 +1 @@
1−{"documents":{"/Users/iko/Developer/skrepka/*":"https://raw.githubusercontent.com/ilyakooo0/skrepka/346c12ecffe87438fdad84bea4dff973f4fc9eec/*"}}
1+{"documents":{"/Users/iko/Developer/skrepka/*":"https://raw.githubusercontent.com/ilyakooo0/skrepka/1025ec42bdc63a36e82c2b05547b3ddfc72a0761/*"}}
client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/linked/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/linked/Skrepka.pdb

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/ref/Skrepka.dll

Binary file not shown.

client/obj/Debug/net10.0-maccatalyst/maccatalyst-arm64/refint/Skrepka.dll

Binary file not shown.