nsarrazin HF staff commited on
Commit
ba449a4
1 Parent(s): d8e839e

Fix Error: Ancestor Not Found issue (#884)

Browse files

There were some issues with invalidating load functions, this should now
be fixed.

src/routes/conversation/[id]/+page.svelte CHANGED
@@ -4,10 +4,9 @@
4
  import { isAborted } from "$lib/stores/isAborted";
5
  import { onMount } from "svelte";
6
  import { page } from "$app/stores";
7
- import { goto, invalidate } from "$app/navigation";
8
  import { base } from "$app/paths";
9
  import { shareConversation } from "$lib/shareConversation";
10
- import { UrlDependency } from "$lib/types/UrlDependency";
11
  import { ERROR_MESSAGES, error } from "$lib/stores/errors";
12
  import { findCurrentModel } from "$lib/utils/models";
13
  import { webSearchParameters } from "$lib/stores/webSearchParameters";
@@ -22,14 +21,7 @@
22
 
23
  export let data;
24
 
25
- let messages = data.messages;
26
- let lastLoadedMessages = data.messages;
27
-
28
- // Since we modify the messages array locally, we don't want to reset it if an old version is passed
29
- $: if (data.messages !== lastLoadedMessages) {
30
- messages = data.messages;
31
- lastLoadedMessages = data.messages;
32
- }
33
 
34
  let loading = false;
35
  let pending = false;
@@ -265,10 +257,8 @@
265
 
266
  if (update.type === "finalAnswer") {
267
  finalAnswer = update.text;
268
- reader.cancel();
269
  loading = false;
270
  pending = false;
271
- invalidate(UrlDependency.Conversation);
272
  } else if (update.type === "stream") {
273
  pending = false;
274
  messageToWriteTo.content += update.token;
@@ -307,7 +297,6 @@
307
  }
308
 
309
  messageToWriteTo.updates = messageUpdates;
310
- await invalidate(UrlDependency.ConversationList);
311
  } catch (err) {
312
  if (err instanceof Error && err.message.includes("overloaded")) {
313
  $error = "Too much traffic, please try again.";
@@ -322,7 +311,7 @@
322
  } finally {
323
  loading = false;
324
  pending = false;
325
- await invalidate(UrlDependency.Conversation);
326
  }
327
  }
328
 
 
4
  import { isAborted } from "$lib/stores/isAborted";
5
  import { onMount } from "svelte";
6
  import { page } from "$app/stores";
7
+ import { goto, invalidateAll } from "$app/navigation";
8
  import { base } from "$app/paths";
9
  import { shareConversation } from "$lib/shareConversation";
 
10
  import { ERROR_MESSAGES, error } from "$lib/stores/errors";
11
  import { findCurrentModel } from "$lib/utils/models";
12
  import { webSearchParameters } from "$lib/stores/webSearchParameters";
 
21
 
22
  export let data;
23
 
24
+ $: ({ messages } = data);
 
 
 
 
 
 
 
25
 
26
  let loading = false;
27
  let pending = false;
 
257
 
258
  if (update.type === "finalAnswer") {
259
  finalAnswer = update.text;
 
260
  loading = false;
261
  pending = false;
 
262
  } else if (update.type === "stream") {
263
  pending = false;
264
  messageToWriteTo.content += update.token;
 
297
  }
298
 
299
  messageToWriteTo.updates = messageUpdates;
 
300
  } catch (err) {
301
  if (err instanceof Error && err.message.includes("overloaded")) {
302
  $error = "Too much traffic, please try again.";
 
311
  } finally {
312
  loading = false;
313
  pending = false;
314
+ await invalidateAll();
315
  }
316
  }
317