@go-avro/avro-js 0.0.8-beta.4 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,7 +39,7 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
39
39
  }
40
40
  return JSON.parse(text);
41
41
  }
42
- if (response.status === 401 && this.config.authManager.refreshTokens && retryCount === 0) {
42
+ if (response.status === 401 && this.config.authManager.refreshTokens && retryCount === 0 && this.getAuthState() === AuthState.AUTHENTICATED) {
43
43
  await this.config.authManager.refreshTokens();
44
44
  return this._fetch(method, path, body, cancelToken, headers, isIdempotent, 1);
45
45
  }
@@ -79,7 +79,7 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
79
79
  console.error('Non-StandardError caught:', message);
80
80
  throw new StandardError(0, `An unexpected error occurred: ${message}`);
81
81
  }
82
- if (error.status === 401 && this.config.authManager.refreshTokens && attempt === 0) {
82
+ if (error.status === 401 && this.config.authManager.refreshTokens && attempt === 0 && this.getAuthState() === AuthState.AUTHENTICATED) {
83
83
  console.log('Attempting to refresh tokens due to 401 response');
84
84
  try {
85
85
  await this.config.authManager.refreshTokens();
@@ -45,9 +45,12 @@ AvroQueryClient.prototype.useCreateMessage = function (chatId) {
45
45
  });
46
46
  return message;
47
47
  },
48
- onMutate: (message) => {
48
+ onSuccess: (message) => {
49
49
  queryClient.setQueryData(['message', message.id], message);
50
+ },
51
+ onSettled: () => {
50
52
  queryClient.invalidateQueries({ queryKey: ['messages', chatId] });
53
+ queryClient.invalidateQueries({ queryKey: ['chats'] });
51
54
  },
52
55
  });
53
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.8-beta.4",
3
+ "version": "0.0.8",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",