tensorgrid-ui 1.1.4 → 1.1.5
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.
- package/lib/client.js +16 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -1946,6 +1946,18 @@ window.__ModuleLoader__.load({
|
|
|
1946
1946
|
const [busy, setBusy] = React.useState(false)
|
|
1947
1947
|
const [draft, setDraft] = React.useState('')
|
|
1948
1948
|
|
|
1949
|
+
// Функция перевода приходит от рантайма НОВОЙ при каждом рендере —
|
|
1950
|
+
// в поставочном коде это обычная стрелка, не мемоизированная. Если
|
|
1951
|
+
// поставить её в зависимости запроса, цепочка t → send → refresh
|
|
1952
|
+
// пересоздаётся каждый раз, эффект с [refresh] срабатывает снова, и
|
|
1953
|
+
// строка уходит в бесконечный цикл рендеров и обращений к Host.
|
|
1954
|
+
// Такой цикл подвешивает всю вкладку, а не только настройки.
|
|
1955
|
+
//
|
|
1956
|
+
// Поэтому перевод берётся через ссылку: она всегда указывает на
|
|
1957
|
+
// свежую функцию, но сама себя не меняет.
|
|
1958
|
+
const translate = React.useRef(t)
|
|
1959
|
+
translate.current = t
|
|
1960
|
+
|
|
1949
1961
|
const send = React.useCallback(async (body) => {
|
|
1950
1962
|
const response = body === undefined
|
|
1951
1963
|
? await fetch(AUTH_PATH)
|
|
@@ -1961,16 +1973,17 @@ window.__ModuleLoader__.load({
|
|
|
1961
1973
|
// не JSON. Без этой проверки строка молча показывала пустоту.
|
|
1962
1974
|
const type = response.headers.get('content-type') || ''
|
|
1963
1975
|
if (!type.includes('application/json')) {
|
|
1976
|
+
const say = translate.current
|
|
1964
1977
|
return {
|
|
1965
1978
|
available: true,
|
|
1966
1979
|
providers: [],
|
|
1967
1980
|
problem: response.status === 401 || response.status === 404
|
|
1968
|
-
?
|
|
1969
|
-
:
|
|
1981
|
+
? say('auth.needsRestart')
|
|
1982
|
+
: say('auth.badResponse').replace('{status}', String(response.status)),
|
|
1970
1983
|
}
|
|
1971
1984
|
}
|
|
1972
1985
|
return response.json()
|
|
1973
|
-
}, [
|
|
1986
|
+
}, [])
|
|
1974
1987
|
|
|
1975
1988
|
const refresh = React.useCallback(async (body) => {
|
|
1976
1989
|
setBusy(true)
|
package/package.json
CHANGED