From 15d307075479cf93ea199be0f25820003ddbe27c Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 09:30:48 +0200 Subject: [PATCH 1/9] Fix some API calls that should not use an API token (#30401) --- app/javascript/mastodon/api.ts | 4 ++-- app/javascript/mastodon/components/admin/Counter.jsx | 2 +- app/javascript/mastodon/components/admin/Dimension.jsx | 2 +- app/javascript/mastodon/components/admin/ImpactReport.jsx | 2 +- .../mastodon/components/admin/ReportReasonSelector.jsx | 4 ++-- app/javascript/mastodon/components/admin/Retention.jsx | 2 +- app/javascript/mastodon/components/admin/Trends.jsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/javascript/mastodon/api.ts b/app/javascript/mastodon/api.ts index ccff68c373..2ccf178f00 100644 --- a/app/javascript/mastodon/api.ts +++ b/app/javascript/mastodon/api.ts @@ -40,11 +40,11 @@ const authorizationTokenFromInitialState = (): RawAxiosRequestHeaders => { }; // eslint-disable-next-line import/no-default-export -export default function api() { +export default function api(withAuthorization = true) { return axios.create({ headers: { ...csrfHeader, - ...authorizationTokenFromInitialState(), + ...(withAuthorization ? authorizationTokenFromInitialState() : {}), }, transformResponse: [ diff --git a/app/javascript/mastodon/components/admin/Counter.jsx b/app/javascript/mastodon/components/admin/Counter.jsx index 6ce23c9f05..e4d21da627 100644 --- a/app/javascript/mastodon/components/admin/Counter.jsx +++ b/app/javascript/mastodon/components/admin/Counter.jsx @@ -48,7 +48,7 @@ export default class Counter extends PureComponent { componentDidMount () { const { measure, start_at, end_at, params } = this.props; - api().post('/api/v1/admin/measures', { keys: [measure], start_at, end_at, [measure]: params }).then(res => { + api(false).post('/api/v1/admin/measures', { keys: [measure], start_at, end_at, [measure]: params }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/mastodon/components/admin/Dimension.jsx b/app/javascript/mastodon/components/admin/Dimension.jsx index bfda6c93d7..56557ad8e8 100644 --- a/app/javascript/mastodon/components/admin/Dimension.jsx +++ b/app/javascript/mastodon/components/admin/Dimension.jsx @@ -26,7 +26,7 @@ export default class Dimension extends PureComponent { componentDidMount () { const { start_at, end_at, dimension, limit, params } = this.props; - api().post('/api/v1/admin/dimensions', { keys: [dimension], start_at, end_at, limit, [dimension]: params }).then(res => { + api(false).post('/api/v1/admin/dimensions', { keys: [dimension], start_at, end_at, limit, [dimension]: params }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/mastodon/components/admin/ImpactReport.jsx b/app/javascript/mastodon/components/admin/ImpactReport.jsx index c27ee0ab08..add54134b6 100644 --- a/app/javascript/mastodon/components/admin/ImpactReport.jsx +++ b/app/javascript/mastodon/components/admin/ImpactReport.jsx @@ -27,7 +27,7 @@ export default class ImpactReport extends PureComponent { include_subdomains: true, }; - api().post('/api/v1/admin/measures', { + api(false).post('/api/v1/admin/measures', { keys: ['instance_accounts', 'instance_follows', 'instance_followers'], start_at: null, end_at: null, diff --git a/app/javascript/mastodon/components/admin/ReportReasonSelector.jsx b/app/javascript/mastodon/components/admin/ReportReasonSelector.jsx index 90f4334a6e..cc05e5c163 100644 --- a/app/javascript/mastodon/components/admin/ReportReasonSelector.jsx +++ b/app/javascript/mastodon/components/admin/ReportReasonSelector.jsx @@ -105,7 +105,7 @@ class ReportReasonSelector extends PureComponent { }; componentDidMount() { - api().get('/api/v1/instance').then(res => { + api(false).get('/api/v1/instance').then(res => { this.setState({ rules: res.data.rules, }); @@ -122,7 +122,7 @@ class ReportReasonSelector extends PureComponent { return; } - api().put(`/api/v1/admin/reports/${id}`, { + api(false).put(`/api/v1/admin/reports/${id}`, { category, rule_ids: category === 'violation' ? rule_ids : [], }).catch(err => { diff --git a/app/javascript/mastodon/components/admin/Retention.jsx b/app/javascript/mastodon/components/admin/Retention.jsx index 1e8ef48b7a..87746e9f49 100644 --- a/app/javascript/mastodon/components/admin/Retention.jsx +++ b/app/javascript/mastodon/components/admin/Retention.jsx @@ -34,7 +34,7 @@ export default class Retention extends PureComponent { componentDidMount () { const { start_at, end_at, frequency } = this.props; - api().post('/api/v1/admin/retention', { start_at, end_at, frequency }).then(res => { + api(false).post('/api/v1/admin/retention', { start_at, end_at, frequency }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/mastodon/components/admin/Trends.jsx b/app/javascript/mastodon/components/admin/Trends.jsx index c69b4a8cba..fd6db106d5 100644 --- a/app/javascript/mastodon/components/admin/Trends.jsx +++ b/app/javascript/mastodon/components/admin/Trends.jsx @@ -22,7 +22,7 @@ export default class Trends extends PureComponent { componentDidMount () { const { limit } = this.props; - api().get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { + api(false).get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { this.setState({ loading: false, data: res.data, From 5b5a35cf96de51b5ef44f69dcde1e3dc2acb9dd6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 23 May 2024 10:26:29 +0200 Subject: [PATCH 2/9] New Crowdin Translations (automated) (#30402) Co-authored-by: GitHub Actions --- app/javascript/mastodon/locales/be.json | 1 + app/javascript/mastodon/locales/lv.json | 2 +- config/locales/an.yml | 1 - config/locales/ar.yml | 1 - config/locales/ast.yml | 2 - config/locales/be.yml | 1 - config/locales/bg.yml | 2 +- config/locales/ca.yml | 2 +- config/locales/ckb.yml | 1 - config/locales/co.yml | 1 - config/locales/cs.yml | 1 - config/locales/cy.yml | 3 +- config/locales/da.yml | 2 +- config/locales/de.yml | 2 +- config/locales/devise.lt.yml | 2 +- config/locales/el.yml | 1 - config/locales/en-GB.yml | 1 - config/locales/eo.yml | 1 - config/locales/es-AR.yml | 2 +- config/locales/es-MX.yml | 2 +- config/locales/es.yml | 2 +- config/locales/et.yml | 1 - config/locales/eu.yml | 1 - config/locales/fa.yml | 1 - config/locales/fi.yml | 1 - config/locales/fo.yml | 2 +- config/locales/fr-CA.yml | 1 - config/locales/fr.yml | 1 - config/locales/fy.yml | 1 - config/locales/gd.yml | 1 - config/locales/gl.yml | 2 +- config/locales/he.yml | 2 +- config/locales/hu.yml | 2 +- config/locales/ia.yml | 2 +- config/locales/id.yml | 1 - config/locales/ie.yml | 1 - config/locales/io.yml | 1 - config/locales/is.yml | 2 +- config/locales/it.yml | 2 +- config/locales/ja.yml | 1 - config/locales/kk.yml | 1 - config/locales/ko.yml | 2 +- config/locales/ku.yml | 1 - config/locales/lad.yml | 1 - config/locales/lt.yml | 148 ++++++++++++++++++++---- config/locales/lv.yml | 1 - config/locales/ms.yml | 1 - config/locales/my.yml | 1 - config/locales/nl.yml | 2 +- config/locales/nn.yml | 1 - config/locales/no.yml | 1 - config/locales/oc.yml | 1 - config/locales/pl.yml | 2 +- config/locales/pt-BR.yml | 1 - config/locales/pt-PT.yml | 2 +- config/locales/ru.yml | 1 - config/locales/sc.yml | 1 - config/locales/sco.yml | 1 - config/locales/si.yml | 1 - config/locales/simple_form.lt.yml | 7 ++ config/locales/simple_form.nl.yml | 4 +- config/locales/simple_form.sr-Latn.yml | 10 +- config/locales/simple_form.sr.yml | 12 +- config/locales/sk.yml | 1 - config/locales/sl.yml | 2 +- config/locales/sq.yml | 3 +- config/locales/sr-Latn.yml | 8 +- config/locales/sr.yml | 8 +- config/locales/sv.yml | 1 - config/locales/th.yml | 1 - config/locales/tr.yml | 2 +- config/locales/uk.yml | 1 - config/locales/vi.yml | 1 - config/locales/zh-CN.yml | 2 +- config/locales/zh-HK.yml | 1 - config/locales/zh-TW.yml | 2 +- 76 files changed, 182 insertions(+), 113 deletions(-) diff --git a/app/javascript/mastodon/locales/be.json b/app/javascript/mastodon/locales/be.json index 2b7673312f..61e96e4b58 100644 --- a/app/javascript/mastodon/locales/be.json +++ b/app/javascript/mastodon/locales/be.json @@ -469,6 +469,7 @@ "notification.follow": "{name} падпісаўся на вас", "notification.follow_request": "{name} адправіў запыт на падпіску", "notification.mention": "{name} згадаў вас", + "notification.moderation-warning.learn_more": "Даведацца больш", "notification.own_poll": "Ваша апытанне скончылася", "notification.poll": "Апытанне, дзе вы прынялі ўдзел, скончылася", "notification.reblog": "{name} пашырыў ваш допіс", diff --git a/app/javascript/mastodon/locales/lv.json b/app/javascript/mastodon/locales/lv.json index e7ab114909..b61a2c0c36 100644 --- a/app/javascript/mastodon/locales/lv.json +++ b/app/javascript/mastodon/locales/lv.json @@ -491,7 +491,7 @@ "onboarding.actions.go_to_home": "Dodieties uz manu mājas plūsmu", "onboarding.compose.template": "Sveiki, #Mastodon!", "onboarding.follows.empty": "Diemžēl pašlaik nevar parādīt rezultātus. Vari mēģināt izmantot meklēšanu vai pārlūkot izpētes lapu, lai atrastu cilvēkus, kuriem sekot, vai vēlāk mēģināt vēlreiz.", - "onboarding.follows.lead": "Tava mājas plūsma ir galvenais veids, kā izbaudīt Mastodon. Jo vairāk cilvēku sekosi, jo aktīvāk un interesantāk tas būs. Lai sāktu, šeit ir daži ieteikumi:", + "onboarding.follows.lead": "Tava mājas plūsma ir galvenais veids, kā pieredzēt Mastodon. Jo vairāk cilvēkiem sekosi, jo dzīvīgāka un aizraujošāka tā būs. Lai sāktu, šeit ir daži ieteikumi:", "onboarding.follows.title": "Pielāgo savu mājas barotni", "onboarding.profile.discoverable": "Padarīt manu profilu atklājamu", "onboarding.profile.display_name": "Attēlojamais vārds", diff --git a/config/locales/an.yml b/config/locales/an.yml index 068a20187d..637aa8c8b3 100644 --- a/config/locales/an.yml +++ b/config/locales/an.yml @@ -852,7 +852,6 @@ an: delete: Borrar edit_preset: Editar aviso predeterminau empty: Encara no has definiu garra preajuste d'alvertencia. - title: Editar configuración predeterminada d'avisos webhooks: add_new: Anyadir endpoint delete: Eliminar diff --git a/config/locales/ar.yml b/config/locales/ar.yml index 02ba56d0b2..2ca7538c32 100644 --- a/config/locales/ar.yml +++ b/config/locales/ar.yml @@ -1013,7 +1013,6 @@ ar: delete: حذف edit_preset: تعديل نموذج التحذير empty: لم تحدد أي إعدادات تحذير مسبقة بعد. - title: إدارة نماذج التحذير webhooks: add_new: إضافة نقطة نهاية delete: حذف diff --git a/config/locales/ast.yml b/config/locales/ast.yml index 816858d4a0..9e6ec6d233 100644 --- a/config/locales/ast.yml +++ b/config/locales/ast.yml @@ -400,8 +400,6 @@ ast: usable: Pue usase title: Tendencies trending: En tendencia - warning_presets: - title: Xestión d'alvertencies preconfiguraes webhooks: add_new: Amestar un estremu delete: Desaniciar diff --git a/config/locales/be.yml b/config/locales/be.yml index 13daa9897e..6f1f189523 100644 --- a/config/locales/be.yml +++ b/config/locales/be.yml @@ -983,7 +983,6 @@ be: delete: Выдаліць edit_preset: Рэдагаваць шаблон папярэджання empty: Вы яшчэ не вызначылі ніякіх шаблонаў папярэджанняў. - title: Кіраванне шаблонамі папярэджанняў webhooks: add_new: Дадаць канцавую кропку delete: Выдаліць diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 51180bc66f..5aca8ad0fd 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -951,7 +951,7 @@ bg: delete: Изтриване edit_preset: Редакция на предварителните настройки empty: Все още няма предварителни настройки за предупрежденията. - title: Управление на предварителните настройки + title: Предупредителни образци webhooks: add_new: Добавяне на крайна точка delete: Изтриване diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 34fd900851..ec32f771e9 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -951,7 +951,7 @@ ca: delete: Elimina edit_preset: Edita l'avís predeterminat empty: Encara no has definit cap preavís. - title: Gestiona les configuracions predefinides dels avisos + title: Predefinicions d'avís webhooks: add_new: Afegir extrem delete: Elimina diff --git a/config/locales/ckb.yml b/config/locales/ckb.yml index dfa035eca8..93eea8273f 100644 --- a/config/locales/ckb.yml +++ b/config/locales/ckb.yml @@ -548,7 +548,6 @@ ckb: add_new: زیادکردنی نوێ delete: سڕینەوە edit_preset: دەستکاریکردنی ئاگاداری پێشگریمان - title: بەڕێوەبردنی ئاگادارکردنەوە پێش‌سازدان admin_mailer: new_pending_account: body: وردەکاریهەژمارە نوێیەکە لە خوارەوەیە. دەتوانیت ئەم نەرمەکالا پەسەند بکەیت یان ڕەت بکەیتەوە. diff --git a/config/locales/co.yml b/config/locales/co.yml index 7d8abcd112..6edbbc95ff 100644 --- a/config/locales/co.yml +++ b/config/locales/co.yml @@ -510,7 +510,6 @@ co: add_new: Aghjunghje delete: Sguassà edit_preset: Cambià a preselezzione d'avertimentu - title: Amministrà e preselezzione d'avertimentu admin_mailer: new_pending_account: body: I ditagli di u novu contu sò quì sottu. Pudete appruvà o righjittà a dumanda. diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 5693077319..17c743f1de 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -984,7 +984,6 @@ cs: delete: Smazat edit_preset: Upravit předlohu pro varování empty: Zatím jste nedefinovali žádné předlohy varování. - title: Spravovat předlohy pro varování webhooks: add_new: Přidat koncový bod delete: Smazat diff --git a/config/locales/cy.yml b/config/locales/cy.yml index f96068f212..35ed5ade8a 100644 --- a/config/locales/cy.yml +++ b/config/locales/cy.yml @@ -297,6 +297,7 @@ cy: update_custom_emoji_html: Mae %{name} wedi diweddaru emoji %{target} update_domain_block_html: Mae %{name} wedi diweddaru bloc parth %{target} update_ip_block_html: Mae %{name} wedi newid rheol IP %{target} + update_report_html: Mae %{name} wedi diweddaru adroddiad %{target} update_status_html: Mae %{name} wedi diweddaru postiad gan %{target} update_user_role_html: Mae %{name} wedi newid rôl %{target} deleted_account: cyfrif wedi'i ddileu @@ -1018,7 +1019,7 @@ cy: delete: Dileu edit_preset: Golygu rhagosodiad rhybudd empty: Nid ydych wedi diffinio unrhyw ragosodiadau rhybudd eto. - title: Rheoli rhagosodiadau rhybudd + title: Rhagosodiadau rhybuddion webhooks: add_new: Ychwanegu diweddbwynt delete: Dileu diff --git a/config/locales/da.yml b/config/locales/da.yml index 17d3037a75..f37086264f 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -951,7 +951,7 @@ da: delete: Slet edit_preset: Redigér advarselsforvalg empty: Ingen advarselsforvalg defineret endnu. - title: Håndtérr advarselsforvalg + title: Præindstillinger for advarsel webhooks: add_new: Tilføj endepunkt delete: Slet diff --git a/config/locales/de.yml b/config/locales/de.yml index dd2129584f..11460c3b40 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -951,7 +951,7 @@ de: delete: Löschen edit_preset: Warnvorlage bearbeiten empty: Du hast noch keine Warnvorlagen hinzugefügt. - title: Warnvorlagen verwalten + title: Warnvorlagen webhooks: add_new: Endpunkt hinzufügen delete: Löschen diff --git a/config/locales/devise.lt.yml b/config/locales/devise.lt.yml index ec5b852727..e36e60a758 100644 --- a/config/locales/devise.lt.yml +++ b/config/locales/devise.lt.yml @@ -22,7 +22,7 @@ lt: action: Patvirtinti el. pašto adresą action_with_app: Patvirtinti ir grįžti į %{app} explanation: Šiuo el. pašto adresu sukūrei paskyrą %{host}. Iki jos aktyvavimo liko vienas paspaudimas. Jei tai buvo ne tu, ignoruok šį el. laišką. - explanation_when_pending: Šiuo el. pašto adresu pateikei paraišką pakvietimui į %{host}. Kai patvirtinsi savo el. pašto adresą, mes peržiūrėsime tavo paraišką. Gali prisijungti ir pakeisti savo duomenis arba ištrinti paskyrą, tačiau negalėsi naudotis daugeliu funkcijų, kol tavo paskyra nebus patvirtinta. Jei tavo paraiška bus atmesta, duomenys bus pašalinti, todėl jokių papildomų veiksmų iš tavęs nereikės. Jei tai buvo ne tu, ignoruok šį el. laišką. + explanation_when_pending: Šiuo el. pašto adresu pateikei paraišką pakvietimui į %{host}. Kai patvirtinsi savo el. pašto adresą, mes peržiūrėsime tavo paraišką. Gali prisijungti ir pakeisti savo duomenis arba ištrinti paskyrą, bet negalėsi naudotis daugeliu funkcijų, kol tavo paskyra nebus patvirtinta. Jei tavo paraiška bus atmesta, duomenys bus pašalinti, todėl jokių papildomų veiksmų iš tavęs nereikės. Jei tai buvo ne tu, ignoruok šį el. laišką. extra_html: Taip pat peržiūrėk serverio taisykles ir mūsų paslaugų teikimo sąlygas. subject: 'Mastodon: patvirtinimo instrukcijos %{instance}' title: Patvirtinti el. pašto adresą diff --git a/config/locales/el.yml b/config/locales/el.yml index 2e7ac87463..47b2250f0e 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -903,7 +903,6 @@ el: delete: Διαγραφή edit_preset: Ενημέρωση προκαθορισμένης προειδοποίησης empty: Δεν έχετε ακόμη ορίσει κάποια προκαθορισμένη προειδοποίηση. - title: Διαχείριση προκαθορισμένων προειδοποιήσεων webhooks: add_new: Προσθήκη σημείου τερματισμού delete: Διαγραφή diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index 7cd888b373..07eb84ebbe 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -950,7 +950,6 @@ en-GB: delete: Delete edit_preset: Edit warning preset empty: You haven't defined any warning presets yet. - title: Warning presets webhooks: add_new: Add endpoint delete: Delete diff --git a/config/locales/eo.yml b/config/locales/eo.yml index 749f80687d..95e3dd5a8d 100644 --- a/config/locales/eo.yml +++ b/config/locales/eo.yml @@ -919,7 +919,6 @@ eo: delete: Forigi edit_preset: Redakti avertan antaŭagordon empty: Vi ankoraŭ ne difinis iun ajn antaŭagordon de averto. - title: Administri avertajn antaŭagordojn webhooks: add_new: Aldoni finpunkton delete: Forigi diff --git a/config/locales/es-AR.yml b/config/locales/es-AR.yml index 302be44112..d6bfb60a19 100644 --- a/config/locales/es-AR.yml +++ b/config/locales/es-AR.yml @@ -951,7 +951,7 @@ es-AR: delete: Eliminar edit_preset: Editar preajuste de advertencia empty: Aún no ha definido ningún preajuste de advertencia. - title: Administrar preajustes de advertencia + title: Preajustes de advertencia webhooks: add_new: Agregar punto final delete: Eliminar diff --git a/config/locales/es-MX.yml b/config/locales/es-MX.yml index 10806c6b6c..8f4aa183d8 100644 --- a/config/locales/es-MX.yml +++ b/config/locales/es-MX.yml @@ -951,7 +951,7 @@ es-MX: delete: Borrar edit_preset: Editar aviso predeterminado empty: Aún no has definido ningún preajuste de advertencia. - title: Editar configuración predeterminada de avisos + title: Preajustes de advertencia webhooks: add_new: Añadir endpoint delete: Eliminar diff --git a/config/locales/es.yml b/config/locales/es.yml index 840bc2ce9b..343f6f5a63 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -951,7 +951,7 @@ es: delete: Borrar edit_preset: Editar aviso predeterminado empty: Aún no has definido ningún preajuste de advertencia. - title: Editar configuración predeterminada de avisos + title: Preajustes de advertencia webhooks: add_new: Añadir endpoint delete: Eliminar diff --git a/config/locales/et.yml b/config/locales/et.yml index a544d8063d..172aad25b9 100644 --- a/config/locales/et.yml +++ b/config/locales/et.yml @@ -949,7 +949,6 @@ et: delete: Kustuta edit_preset: Hoiatuse eelseadistuse muutmine empty: Hoiatuste eelseadeid pole defineeritud. - title: Halda hoiatuste eelseadistusi webhooks: add_new: Lisa lõpp-punkt delete: Kustuta diff --git a/config/locales/eu.yml b/config/locales/eu.yml index 22ca8135d5..67da357e1d 100644 --- a/config/locales/eu.yml +++ b/config/locales/eu.yml @@ -952,7 +952,6 @@ eu: delete: Ezabatu edit_preset: Editatu abisu aurre-ezarpena empty: Ez duzu abisu aurrezarpenik definitu oraindik. - title: Kudeatu abisu aurre-ezarpenak webhooks: add_new: Gehitu amaiera-puntua delete: Ezabatu diff --git a/config/locales/fa.yml b/config/locales/fa.yml index d93d2e7d5f..509d69fcba 100644 --- a/config/locales/fa.yml +++ b/config/locales/fa.yml @@ -808,7 +808,6 @@ fa: delete: زدودن edit_preset: ویرایش هشدار پیش‌فرض empty: هنز هیچ پیش‌تنظیم هشداری را تعریف نکرده‌اید. - title: مدیریت هشدارهای پیش‌فرض webhooks: add_new: افزودن نقطهٔ پایانی delete: حذف diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 53db0232aa..3a75066d5b 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -951,7 +951,6 @@ fi: delete: Poista edit_preset: Muokkaa varoituksen esiasetusta empty: Et ole vielä määrittänyt yhtäkään varoitusten esiasetusta. - title: Hallitse varoitusten esiasetuksia webhooks: add_new: Lisää päätepiste delete: Poista diff --git a/config/locales/fo.yml b/config/locales/fo.yml index 57caff4d71..0372d3dca3 100644 --- a/config/locales/fo.yml +++ b/config/locales/fo.yml @@ -951,7 +951,7 @@ fo: delete: Strika edit_preset: Rætta ávaringar-undanstilling empty: Tú hevur ikki ásett nakrar ávaringar-undanstillingar enn. - title: Stýr ávaringar-undanstillingar + title: Undanstillingar fyri ávaring webhooks: add_new: Legg endapunkt afturat delete: Strika diff --git a/config/locales/fr-CA.yml b/config/locales/fr-CA.yml index 05d6b8864d..f297e8bfde 100644 --- a/config/locales/fr-CA.yml +++ b/config/locales/fr-CA.yml @@ -949,7 +949,6 @@ fr-CA: delete: Supprimer edit_preset: Éditer les avertissements prédéfinis empty: Vous n'avez pas encore créé de paramètres prédéfinis pour les avertissements. - title: Gérer les avertissements prédéfinis webhooks: add_new: Ajouter un point de terminaison delete: Supprimer diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 6ab4208801..33cdcd44cc 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -949,7 +949,6 @@ fr: delete: Supprimer edit_preset: Éditer les avertissements prédéfinis empty: Vous n'avez pas encore créé de paramètres prédéfinis pour les avertissements. - title: Gérer les avertissements prédéfinis webhooks: add_new: Ajouter un point de terminaison delete: Supprimer diff --git a/config/locales/fy.yml b/config/locales/fy.yml index 1f1a27fec4..c8e287732a 100644 --- a/config/locales/fy.yml +++ b/config/locales/fy.yml @@ -949,7 +949,6 @@ fy: delete: Fuortsmite edit_preset: Foarynstelling foar warskôging bewurkje empty: Jo hawwe noch gjin foarynstellingen foar warskôgingen tafoege. - title: Foarynstellingen foar warskôgingen beheare webhooks: add_new: Einpunt tafoegje delete: Fuortsmite diff --git a/config/locales/gd.yml b/config/locales/gd.yml index 70bace05cf..52b25e2854 100644 --- a/config/locales/gd.yml +++ b/config/locales/gd.yml @@ -983,7 +983,6 @@ gd: delete: Sguab às edit_preset: Deasaich rabhadh ro-shuidhichte empty: Cha do mhìnich thu ro-sheataichean rabhaidhean fhathast. - title: Stiùirich na rabhaidhean ro-shuidhichte webhooks: add_new: Cuir puing-dheiridh ris delete: Sguab às diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 2c85dc89ae..a8489e425f 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -951,7 +951,7 @@ gl: delete: Eliminar edit_preset: Editar aviso preestablecido empty: Non definiches os avisos prestablecidos. - title: Xestionar avisos preestablecidos + title: Preestablecidos de advertencia webhooks: add_new: Engadir punto de extremo delete: Eliminar diff --git a/config/locales/he.yml b/config/locales/he.yml index 3613a9f0b3..9088f48218 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -985,7 +985,7 @@ he: delete: למחוק edit_preset: ערוך/י טקסט מוכן מראש לאזהרה empty: לא הגדרת עדיין שום טקסט מוכן מראש לאזהרה. - title: ניהול טקסטים מוכנים מראש לאזהרות + title: תצורת אזהרות webhooks: add_new: הוספת נקודת קצה delete: מחיקה diff --git a/config/locales/hu.yml b/config/locales/hu.yml index dd57830515..d79bca7ff7 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -951,7 +951,7 @@ hu: delete: Törlés edit_preset: Figyelmeztetés szerkesztése empty: Nem definiáltál még egyetlen figyelmeztetést sem. - title: Figyelmeztetések + title: Figyelmeztető szövegek webhooks: add_new: Végpont hozzáadása delete: Törlés diff --git a/config/locales/ia.yml b/config/locales/ia.yml index 8af676454f..f8834136b9 100644 --- a/config/locales/ia.yml +++ b/config/locales/ia.yml @@ -951,7 +951,7 @@ ia: delete: Deler edit_preset: Rediger aviso predefinite empty: Tu non ha ancora definite alcun avisos predefinite. - title: Gerer avisos predefinite + title: Predefinitiones de avisos webhooks: add_new: Adder terminal delete: Deler diff --git a/config/locales/id.yml b/config/locales/id.yml index bee282fa83..aae790f481 100644 --- a/config/locales/id.yml +++ b/config/locales/id.yml @@ -831,7 +831,6 @@ id: delete: Hapus edit_preset: Sunting preset peringatan empty: Anda belum mendefinisikan peringatan apapun. - title: Kelola preset peringatan webhooks: add_new: Tambah titik akhir delete: Hapus diff --git a/config/locales/ie.yml b/config/locales/ie.yml index 473d7b750f..432e7d031b 100644 --- a/config/locales/ie.yml +++ b/config/locales/ie.yml @@ -950,7 +950,6 @@ ie: delete: Deleter edit_preset: Modificar prefiguration de avise empty: Vu ancor ha definit null prefigurationes de avise. - title: Modificar prefigurationes de avise webhooks: add_new: Adjunter punctu terminal delete: Deleter diff --git a/config/locales/io.yml b/config/locales/io.yml index ed0d0d6345..bccdcb3cc5 100644 --- a/config/locales/io.yml +++ b/config/locales/io.yml @@ -928,7 +928,6 @@ io: delete: Efacez edit_preset: Modifikez avertfixito empty: Vu ne fixis irga avertfixito til nun. - title: Jerez avertfixiti webhooks: add_new: Insertez finpunto delete: Efacez diff --git a/config/locales/is.yml b/config/locales/is.yml index 9977752969..75950e572d 100644 --- a/config/locales/is.yml +++ b/config/locales/is.yml @@ -953,7 +953,7 @@ is: delete: Eyða edit_preset: Breyta forstilltri aðvörun empty: Þú hefur ekki enn skilgreint neinar aðvaranaforstillingar. - title: Sýsla með forstilltar aðvaranir + title: Forstilltar aðvaranir webhooks: add_new: Bæta við endapunkti delete: Eyða diff --git a/config/locales/it.yml b/config/locales/it.yml index 5b75e7af7d..c3389f59c6 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -951,7 +951,7 @@ it: delete: Cancella edit_preset: Modifica avviso predefinito empty: Non hai ancora definito alcun avviso preimpostato. - title: Gestisci avvisi predefiniti + title: Preimpostazioni di avviso webhooks: add_new: Aggiungi endpoint delete: Elimina diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 0712ba380a..6c0fba259c 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -933,7 +933,6 @@ ja: delete: 削除 edit_preset: プリセット警告文を編集 empty: まだプリセット警告文が作成されていません。 - title: プリセット警告文を管理 webhooks: add_new: エンドポイントを追加 delete: 削除 diff --git a/config/locales/kk.yml b/config/locales/kk.yml index f08d8ead1a..2695127f0a 100644 --- a/config/locales/kk.yml +++ b/config/locales/kk.yml @@ -299,7 +299,6 @@ kk: add_new: Add nеw delete: Deletе edit_preset: Edit warning prеset - title: Manage warning presеts admin_mailer: new_pending_account: body: Жаңа есептік жазба туралы мәліметтер төменде берілген. Бұл қолданбаны мақұлдауыңызға немесе қабылдамауыңызға болады. diff --git a/config/locales/ko.yml b/config/locales/ko.yml index b104e31fc0..9de2f6ca53 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -936,7 +936,7 @@ ko: delete: 삭제 edit_preset: 경고 프리셋 편집 empty: 아직 어떤 경고 틀도 정의되지 않았습니다. - title: 경고 틀 관리 + title: 경고 프리셋 webhooks: add_new: 엔드포인트 추가 delete: 삭제 diff --git a/config/locales/ku.yml b/config/locales/ku.yml index 74dcd6f8f3..c24337dd7c 100644 --- a/config/locales/ku.yml +++ b/config/locales/ku.yml @@ -849,7 +849,6 @@ ku: delete: Jê bibe edit_preset: Hişyariyên pêşsazkirî serrast bike empty: Te hin tu hişyariyên pêşsazkirî destnîşan nekirine. - title: Hişyariyên pêşsazkirî bi rêve bibe webhooks: add_new: Xala dawîbûnê tevlî bike delete: Jê bibe diff --git a/config/locales/lad.yml b/config/locales/lad.yml index 9c165472cd..d0657e73f9 100644 --- a/config/locales/lad.yml +++ b/config/locales/lad.yml @@ -950,7 +950,6 @@ lad: delete: Efasa edit_preset: Edita avizo predeterminado empty: Ainda no tienes definido ningun avizo predeterminado. - title: Edita konfigurasyon predeterminada de avizos webhooks: add_new: Adjusta endpoint delete: Efasa diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 3e514a547b..8e32ed07bd 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -451,7 +451,7 @@ lt: filter: all: Visi available: Pasiekiamas - expired: Pasibaigęs + expired: Nebegaliojantis title: Filtras title: Kvietimai relays: @@ -505,9 +505,15 @@ lt: unresolved: Neišspręsti updated_at: Atnaujinti roles: + categories: + invites: Kvietimai everyone: Numatytieji leidimai everyone_full_description_html: Tai – bazinis vaidmuo, turintis įtakos visiems naudotojams, net ir tiems, kurie neturi priskirto vaidmens. Visi kiti vaidmenys iš jo paveldi teises. privileges: + invite_users: Kviesti naudotojus + invite_users_description: Leidžia naudotojams pakviesti naujus žmones į serverį. + manage_invites: Tvarkyti kvietimus + manage_invites_description: Leidžia naudotojams naršyti ir deaktyvuoti kvietimų nuorodas. manage_taxonomies_description: Leidžia naudotojams peržiūrėti tendencingą turinį ir atnaujinti saitažodžių nustatymus settings: captcha_enabled: @@ -522,12 +528,34 @@ lt: registrations: moderation_recommandation: Prieš atidarant registraciją visiems, įsitikink, kad turi tinkamą ir reaguojančią prižiūrėjimo komandą! software_updates: - description: Rekomenduojama nuolat atnaujinti Mastodon diegyklę, kad galėtum naudotis naujausiais pataisymais ir funkcijomis. Be to, kartais labai svarbu laiku naujinti Mastodon, kad būtų išvengta saugumo problemų. Dėl šių priežasčių Mastodon kas 30 minučių tikrina, ar yra atnaujinimų, ir praneša tau apie tai pagal tavo el. pašto pranešimų parinktis. + description: Rekomenduojama nuolat atnaujinti Mastodon diegyklę, kad galėtum naudotis naujausiais pataisymais ir funkcijomis. Be to, kartais labai svarbu laiku atnaujinti Mastodon, kad būtų išvengta saugumo problemų. Dėl šių priežasčių Mastodon kas 30 minučių tikrina, ar yra naujinimų, ir praneša tau apie tai pagal tavo el. pašto pranešimų parinktis. + documentation_link: Sužinoti daugiau + release_notes: Leidimo informacija + title: Galimi naujinimai + type: Tipas + types: + major: Pagrindinis leidimas + minor: Nedidelis leidimas + patch: Pataiso leidimas – riktų taisymai ir lengvai pritaikomi pakeitimai + version: Versija statuses: + account: Autorius (-ė) + application: Programa back_to_account: Grįžti į paskyros puslapį + back_to_report: Grįžti į ataskaitos puslapį + batch: + remove_from_report: Pašalinti iš ataskaitos + deleted: Ištrinta + favourites: Mėgstami + history: Versijų istorija + in_reply_to: Atsakydant į + language: Kalba media: title: Medija - no_status_selected: Jokie statusai nebuvo pakeisti, nes niekas nepasirinkta + metadata: Metaduomenys + no_status_selected: Jokie įrašai nebuvo pakeisti, nes nė vienas buvo pasirinktas + open: Atidaryti įrašą + original_status: Originalus įrašas title: Paskyros statusai trending: Tendencinga with_media: Su medija @@ -537,6 +565,7 @@ lt: elasticsearch_preset: message_html: Tavo Elasticsearch klasteris turi daugiau nei vieną mazgą, bet Mastodon nėra sukonfigūruotas juos naudoti. elasticsearch_preset_single_node: + action: Žiūrėti dokumentaciją message_html: Tavo Elasticsearch klasteris turi tik vieną mazgą, ES_PRESET turėtų būti nustatyta į single_node_cluster. title: Administracija trends: @@ -571,8 +600,20 @@ lt: disallow_account: Neleisti autorių (-ę) no_status_selected: Jokie tendencingi įrašai nebuvo pakeisti, nes nė vienas iš jų nebuvo pasirinktas not_discoverable: Autorius (-ė) nesutiko, kad būtų galima juos atrasti + shared_by: + few: Bendrinta arba pamėgta %{friendly_count} kartus + many: Bendrinta arba pamėgta %{friendly_count} karto + one: Bendrinta arba pamėgta vieną kartą + other: Bendrinta arba pamėgta %{friendly_count} kartų title: Tendencingi įrašai tags: + dashboard: + tag_accounts_measure: unikalūs naudojimai + tag_languages_dimension: Populiariausios kalbos + tag_servers_dimension: Populiariausi serveriai + tag_servers_measure: skirtingi serveriai + tag_uses_measure: bendri naudojimai + listable: Gali būti siūloma not_trendable: Nepasirodys tendencijose title: Tendencingos saitažodžiai trendable: Gali pasirodyti tendencijose @@ -583,7 +624,6 @@ lt: add_new: Pridėti naują delete: Ištrinti edit_preset: Keisti įspėjimo nustatymus - title: Valdyti įspėjimo nustatymus webhooks: description_html: "Webhook leidžia Mastodon siųsti realaus laiko pranešimus apie pasirinktus įvykius į tavo programą, kad programa galėtų automatiškai paleisti reakcijas." events: Įvykiai @@ -627,21 +667,32 @@ lt: warning: Būkite atsargūs su šia informacija. Niekada jos nesidalinkite! your_token: Tavo prieigos raktas auth: + confirmations: + welcome_title: Sveiki, %{name}! delete_account: Ištrinti paskyrą delete_account_html: Jeigu norite ištrinti savo paskyrą, galite eiti čia. Jūsų prašys patvirtinti pasirinkimą. + description: + prefix_invited_by_user: "@%{name} kviečia prisijungti prie šio Mastodon serverio!" + prefix_sign_up: Užsiregistruok Mastodon šiandien! + didnt_get_confirmation: Negavai patvirtinimo nuorodos? dont_have_your_security_key: Neturi saugumo rakto? - forgot_password: Pamiršote slaptažodį? - invalid_reset_password_token: Slaptažodžio atkūrimo žetonas netinkamas arba jo galiojimo laikas pasibaigęs. Prašykite naujo žetono. + forgot_password: Pamiršai slaptažodį? + invalid_reset_password_token: Slaptažodžio atkūrimo raktas yra netinkamas arba nebegaliojantis. Paprašyk naujo. + log_in_with: Prisijungti su login: Prisijungti logout: Atsijungti migrate_account: Prisijungti prie kitos paskyros migrate_account_html: Jeigu norite nukreipti šią paskyrą į kita, galite tai konfiguruoti čia. or_log_in_with: Arba prisijungti su + providers: + cas: CAS + saml: SAML register: Užsiregistruoti reset_password: Atstatyti slaptažodį rules: invited_by: 'Gali prisijungti prie %{domain} pagal kvietimą, kurį gavai iš:' preamble_invited: Prieš tęsiant, atsižvelk į pagrindines taisykles, kurias nustatė %{domain} prižiūrėtojai. + title_invited: Esi pakviestas. security: Apsauga set_new_password: Nustatyti naują slaptažodį status: @@ -673,6 +724,9 @@ lt: success_msg: Tavo paskyra buvo sėkmingai ištrinta disputes: strikes: + created_at: Data + title_actions: + none: Įspėjimas your_appeal_approved: Tavo apeliacija buvo patvirtinta your_appeal_pending: Pateikei apeliaciją your_appeal_rejected: Tavo apeliacija buvo atmesta @@ -699,6 +753,8 @@ lt: request: Prašyti savo archyvo size: Dydis blocks: Jūs blokuojate + bookmarks: Žymės + csv: CSV domain_blocks: Domeno blokai lists: Sąrašai mutes: Jūs tildote @@ -708,11 +764,14 @@ lt: hint_html: "Savo profilyje parodyk svarbiausius saitažodžius. Tai puikus įrankis kūrybiniams darbams ir ilgalaikiams projektams sekti, todėl svarbiausios saitažodžiai rodomi matomoje vietoje profilyje ir leidžia greitai pasiekti tavo paties įrašus." filters: contexts: - home: Namų laiko juosta - notifications: Priminimai + account: Profiliai + home: Pagrindinis ir sąrašai + notifications: Pranešimai public: Viešieji laiko skalės thread: Pokalbiai edit: + add_keyword: Pridėti raktažodį + keywords: Raktažodžiai title: Keisti filtrą errors: invalid_context: Jokio arba netinkamas pateiktas kontekstas @@ -726,9 +785,14 @@ lt: all: Visi changes_saved_msg: Pakeitimai sėkmingai išsaugoti! copy: Kopijuoti + delete: Ištrinti + deselect: Panaikinti visus žymėjimus order_by: Tvarkyti pagal save_changes: Išsaugoti pakeitimus + today: šiandien imports: + errors: + too_large: Failas per didelis. modes: merge: Sulieti merge_long: Išsaugoti esančius įrašus ir pridėti naujus @@ -744,7 +808,7 @@ lt: upload: Įkelti invites: delete: Deaktyvuoti - expired: Pasibaigė + expired: Nebegaliojantis expires_in: '1800': 30 minučių '21600': 6 valandų @@ -753,28 +817,29 @@ lt: '604800': 1 savaitės '86400': 1 dienos expires_in_prompt: Niekada - generate: Generuoti + generate: Generuoti kvietimo nuorodą invalid: Šis kvietimas negalioja. - invited_by: 'Jus pakvietė:' + invited_by: 'Tave pakvietė:' max_uses: few: "%{count} naudojimai" many: "%{count} naudojimo" one: 1 naudojimas other: "%{count} naudojimų" - max_uses_prompt: Nėra limito + max_uses_prompt: Nėra ribojimo prompt: Generuok ir bendrink nuorodas su kitais, kad suteiktum prieigą prie šio serverio table: expires_at: Baigsis uses: Naudojimai - title: Pakviesti žmones + title: Kviesti žmones media_attachments: validations: images_and_video: Negalima pridėti video prie statuso, kuris jau turi nuotrauką too_many: Negalima pridėti daugiau nei 4 failų migrations: - acct: slapyvardis@domenas naujam vartotojui + acct: Perkelta į + cancel: Atšaukti nukreipimą moderation: - title: Moderacija + title: Prižiūrėjimas notification_mailer: favourite: body: 'Tavo įrašą pamėgo %{name}:' @@ -801,11 +866,19 @@ lt: notifications: email_events: Įvykiai, skirti el. laiško pranešimams email_events_hint: 'Pasirink įvykius, apie kuriuos nori gauti pranešimus:' + number: + human: + decimal_units: + units: + billion: mlrd. + million: mln. + thousand: tūkst. pagination: newer: Naujesnis next: Kitas older: Senesnis prev: Ankstesnis + truncate: "…" preferences: other: Kita posting_defaults: Skelbimo numatytosios nuostatos @@ -829,6 +902,7 @@ lt: dormant: Neaktyvus followers: Sekėjai following: Sekama + invited: Pakviestas last_active: Paskutinį kartą aktyvus most_recent: Naujausias moved: Perkelta @@ -851,24 +925,35 @@ lt: date: Data description: "%{browser} ant %{platform}" explanation: Čia rodomos web naršyklės prijungtos prie Jūsų Mastodon paskyros. + ip: IP platforms: + adobe_air: Adobe Air android: Android + blackberry: BlackBerry + chrome_os: ChromeOS + firefox_os: Firefox OS ios: iOS kai_os: KaiOS + linux: Linux mac: macOS + unknown_platform: Nežinoma platforma windows: Windows windows_mobile: Windows Mobile windows_phone: Windows Phone - revoke: Atšaukti + revoke: Naikinti revoke_success: Seansas sėkmingai panaikintas. title: Seansai settings: - authorized_apps: Autorizuotos aplikacijos + account: Paskyra + account_settings: Paskyros nustatymai + aliases: Paskyros pseudonimai + appearance: Išvaizda + authorized_apps: Leidžiamos programėlės back: Grįžti į Mastodon delete: Paskyros trynimas - development: Plėtojimas - edit_profile: Keisti profilį - export: Informacijos eksportas + development: Kūrimas + edit_profile: Redaguoti profilį + export: Duomenų eksportas featured_tags: Rodomi saitažodžiai import: Importuoti migrate: Paskyros migracija @@ -879,10 +964,22 @@ lt: severed_relationships: Nutrūkę sąryšiai two_factor_authentication: Dviejų veiksnių autentikacija severed_relationships: + download: Atsisiųsti (%{count}) preamble: Užblokavus domeną arba prižiūrėtojams nusprendus pristabdyti nuotolinio serverio veiklą, gali prarasti sekimus ir sekėjus. Kai taip atsitiks, galėsi atsisiųsti nutrauktų sąryšių sąrašus, kad juos patikrinti ir galbūt importuoti į kitą serverį. + type: Įvykis statuses: attached: + audio: + few: "%{count} garso įrašai" + many: "%{count} garso įrašo" + one: "%{count} garso įrašas" + other: "%{count} garso įrašų" description: 'Pridėta: %{attached}' + image: + few: "%{count} vaizdai" + many: "%{count} vaizdo" + one: "%{count} vaizdas" + other: "%{count} vaizdų" boosted_from_html: Pakelta iš %{acct_link} content_warning: 'Turinio įspėjimas: %{warning}' open_in_web: Atidaryti naudojan Web @@ -891,11 +988,14 @@ lt: limit: Jūs jau prisegėte maksimalų toot'ų skaičų ownership: Kitų vartotojų toot'ai negali būti prisegti reblog: Pakeltos žinutės negali būti prisegtos - show_more: Daugiau + poll: + vote: Balsuoti + show_more: Rodyti daugiau + show_thread: Rodyti giją visibilities: private: Tik sekėjams private_long: rodyti tik sekėjams - public: Viešas + public: Vieša public_long: visi gali matyti unlisted: Neįtrauktas į sąrašus unlisted_long: matyti gali visi, bet nėra išvardyti į viešąsias laiko skales @@ -904,6 +1004,7 @@ lt: keep_polls_hint: Neištrina jokių tavo apklausų keep_self_bookmark: Laikyti įrašus, kuriuos pažymėjai keep_self_bookmark_hint: Neištrina tavo pačių įrašų, jei esi juos pažymėjęs (-usi) + keep_self_fav_hint: Neištrina tavo pačių įrašų, jei esi juos pamėgęs (-usi) stream_entries: sensitive_content: Jautrus turinys themes: @@ -912,7 +1013,8 @@ lt: mastodon-light: Mastodon (šviesi) system: Automatinis (naudoti sistemos temą) two_factor_authentication: - disable: Išjungti + add: Pridėti + disable: Išjungti 2FA enabled: Dviejų veiksnių autentikacija įjungta enabled_success: Dviejų veiksnių autentikacija sėkmingai įjungta generate_recovery_codes: Sugeneruoti atkūrimo kodus diff --git a/config/locales/lv.yml b/config/locales/lv.yml index f4f0aa9db2..5a071eba86 100644 --- a/config/locales/lv.yml +++ b/config/locales/lv.yml @@ -961,7 +961,6 @@ lv: delete: Dzēst edit_preset: Labot iepriekš iestatītus brīdinājumus empty: Tu vēl neesi definējis iepriekš iestatītos brīdinājumus. - title: Pārvaldīt brīdinājuma iestatījumus webhooks: add_new: Pievienot galapunktu delete: Dzēst diff --git a/config/locales/ms.yml b/config/locales/ms.yml index f39c26a5c1..a778d0c28f 100644 --- a/config/locales/ms.yml +++ b/config/locales/ms.yml @@ -924,7 +924,6 @@ ms: delete: Padam edit_preset: Edit pratetap amaran empty: Anda belum menentukan sebarang pratetap amaran lagi. - title: Urus pratetap amaran webhooks: add_new: Tambah titik akhir delete: Padam diff --git a/config/locales/my.yml b/config/locales/my.yml index 4ac9ecdd45..f28458360b 100644 --- a/config/locales/my.yml +++ b/config/locales/my.yml @@ -909,7 +909,6 @@ my: delete: ဖျက်ပါ edit_preset: ကြိုသတိပေးချက်ကို ပြင်ဆင်ပါ empty: ကြိုသတိပေးချက်များကို မသတ်မှတ်ရသေးပါ။ - title: ကြိုသတိပေးချက်များကို စီမံပါ webhooks: add_new: ဆုံးမှတ် ထည့်ပါ delete: ဖျက်ပါ diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 3452f80994..a527fdb5a7 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -951,7 +951,7 @@ nl: delete: Verwijderen edit_preset: Preset voor waarschuwing bewerken empty: Je hebt nog geen presets voor waarschuwingen toegevoegd. - title: Presets voor waarschuwingen beheren + title: Presets voor waarschuwingen webhooks: add_new: Eindpunt toevoegen delete: Verwijderen diff --git a/config/locales/nn.yml b/config/locales/nn.yml index 013674ca51..9291ba2c2c 100644 --- a/config/locales/nn.yml +++ b/config/locales/nn.yml @@ -950,7 +950,6 @@ nn: delete: Slett edit_preset: Endr åtvaringsoppsett empty: Du har ikke definert noen forhåndsinnstillinger for advarsler enda. - title: Handsam åtvaringsoppsett webhooks: add_new: Legg til endepunkt delete: Slett diff --git a/config/locales/no.yml b/config/locales/no.yml index c71dffc636..537552ea98 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -944,7 +944,6 @@ delete: Slett edit_preset: Rediger advarsel forhåndsinnstilling empty: Du har ikke definert noen forhåndsinnstillinger for varsler enda. - title: Endre forhåndsinnstillinger for advarsler webhooks: add_new: Legg til endepunkt delete: Slett diff --git a/config/locales/oc.yml b/config/locales/oc.yml index 0a653ea46c..d2bea55bd3 100644 --- a/config/locales/oc.yml +++ b/config/locales/oc.yml @@ -430,7 +430,6 @@ oc: add_new: N’ajustar un nòu delete: Escafar edit_preset: Modificar lo tèxt predefinit d’avertiment - title: Gerir los tèxtes predefinits webhooks: delete: Suprimir disable: Desactivar diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 1c3fda8d03..4c7af82b94 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -985,7 +985,7 @@ pl: delete: Usuń edit_preset: Edytuj szablon ostrzeżenia empty: Nie zdefiniowano jeszcze żadnych szablonów ostrzegawczych. - title: Zarządzaj szablonami ostrzeżeń + title: Zapisane ostrzeżenia webhooks: add_new: Dodaj punkt końcowy delete: Usuń diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 60730d53e9..6b80edb24e 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -950,7 +950,6 @@ pt-BR: delete: Excluir edit_preset: Editar o aviso pré-definido empty: Você ainda não definiu nenhuma predefinição de alerta. - title: Gerenciar os avisos pré-definidos webhooks: add_new: Adicionar endpoint delete: Excluir diff --git a/config/locales/pt-PT.yml b/config/locales/pt-PT.yml index b4669e24d8..49522b7414 100644 --- a/config/locales/pt-PT.yml +++ b/config/locales/pt-PT.yml @@ -951,7 +951,7 @@ pt-PT: delete: Eliminar edit_preset: Editar o aviso predefinido empty: Ainda não definiu nenhum aviso predefinido. - title: Gerir os avisos predefinidos + title: Predefinições de aviso webhooks: add_new: Adicionar endpoint delete: Eliminar diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 85d8a7a540..d6b8726ba4 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -978,7 +978,6 @@ ru: delete: Удалить edit_preset: Удалить шаблон предупреждения empty: Вы еще не определили пресеты предупреждений. - title: Управление шаблонами предупреждений webhooks: add_new: Добавить конечную точку delete: Удалить diff --git a/config/locales/sc.yml b/config/locales/sc.yml index 01c355794d..449d8d9c7f 100644 --- a/config/locales/sc.yml +++ b/config/locales/sc.yml @@ -535,7 +535,6 @@ sc: delete: Cantzella edit_preset: Modìfica s'avisu predefinidu empty: No as cunfiguradu ancora perunu avisu predefinidu. - title: Gesti is cunfiguratziones predefinidas de is avisos webhooks: delete: Cantzella disable: Disativa diff --git a/config/locales/sco.yml b/config/locales/sco.yml index 2a7b1e3e70..7c733b71b5 100644 --- a/config/locales/sco.yml +++ b/config/locales/sco.yml @@ -842,7 +842,6 @@ sco: delete: Delete edit_preset: Edit warnin preset empty: Ye huvnae definit onie warnin presets yit. - title: Manage warnin presets webhooks: add_new: Add enpynt delete: Delete diff --git a/config/locales/si.yml b/config/locales/si.yml index f5e65fda8d..0f714ee146 100644 --- a/config/locales/si.yml +++ b/config/locales/si.yml @@ -726,7 +726,6 @@ si: delete: මකන්න edit_preset: අනතුරු ඇඟවීමේ පෙර සැකසුම සංස්කරණය කරන්න empty: ඔබ තවම කිසිදු අනතුරු ඇඟවීමේ පෙරසිටුවක් නිර්වචනය කර නැත. - title: අනතුරු ඇඟවීමේ පෙරසිටුවීම් කළමනාකරණය කරන්න webhooks: add_new: අන්ත ලක්ෂ්‍යය එක් කරන්න delete: මකන්න diff --git a/config/locales/simple_form.lt.yml b/config/locales/simple_form.lt.yml index 1c73ce0a84..789121be42 100644 --- a/config/locales/simple_form.lt.yml +++ b/config/locales/simple_form.lt.yml @@ -79,6 +79,7 @@ lt: mascot: Pakeičia išplėstinės žiniatinklio sąsajos iliustraciją. media_cache_retention_period: Nuotolinių naudotojų įrašytų įrašų medijos failai talpinami tavo serveryje. Nustačius teigiamą reikšmę, medijos bus ištrinamos po nurodyto dienų skaičiaus. Jei medijos duomenų bus paprašyta po to, kai jie bus ištrinti, jie bus atsiųsti iš naujo, jei šaltinio turinys vis dar prieinamas. Dėl apribojimų, susijusių su nuorodų peržiūros kortelių apklausos dažnumu trečiųjų šalių svetainėse, rekomenduojama nustatyti šią reikšmę ne trumpesnę kaip 14 dienų, kitaip nuorodų peržiūros kortelės nebus atnaujinamos pagal pareikalavimą iki to laiko. peers_api_enabled: Domenų pavadinimų sąrašas, su kuriais šis serveris susidūrė fediverse. Čia nėra duomenų apie tai, ar tu bendrauji su tam tikru serveriu, tik apie tai, kad tavo serveris apie jį žino. Tai naudojama tarnybose, kurios renka federacijos statistiką bendrąja prasme. + require_invite_text: Kai registraciją reikia patvirtinti rankiniu būdu, teksto įvesties laukelį „Kodėl nori prisijungti?“ padaryk privalomą, o ne pasirenkamą site_contact_email: Kaip žmonės gali su tavimi susisiekti teisiniais ar pagalbos užklausimais. site_contact_username: Kaip žmonės gali tave pasiekti Mastodon. site_extended_description: Bet kokia papildoma informacija, kuri gali būti naudinga lankytojams ir naudotojams. Gali būti struktūrizuota naudojant Markdown sintaksę. @@ -86,6 +87,8 @@ lt: timeline_preview: Atsijungę lankytojai galės naršyti naujausius viešus įrašus, esančius serveryje. trends: Trendai rodo, kurios įrašai, saitažodžiai ir naujienų istorijos tavo serveryje sulaukia didžiausio susidomėjimo. trends_as_landing_page: Rodyti tendencingą turinį atsijungusiems naudotojams ir lankytojams vietoj šio serverio aprašymo. Reikia, kad tendencijos būtų įjungtos. + invite_request: + text: Tai padės mums peržiūrėti tavo paraišką rule: hint: Pasirinktinai. Pateik daugiau informacijos apie taisyklę. sessions: @@ -108,6 +111,7 @@ lt: admin_account_action: include_statuses: Įtraukti praneštus įrašus į el. laišką defaults: + autofollow: Kviesti sekti tavo paskyrą avatar: Profilio nuotrauka bot: Tai automatinė paskyra chosen_languages: Filtruoti kalbas @@ -163,6 +167,7 @@ lt: custom_css: Pasirinktinis CSS mascot: Pasirinktinis talismanas (pasenęs) registrations_mode: Kas gali užsiregistruoti + require_invite_text: Reikalauti priežasties prisijungti show_domain_blocks_rationale: Rodyti, kodėl domenai buvo užblokuoti site_extended_description: Išplėstas aprašymas site_short_description: Serverio aprašymas @@ -173,6 +178,8 @@ lt: trendable_by_default: Leisti tendencijas be išankstinės peržiūros trends: Įjungti tendencijas trends_as_landing_page: Naudoti tendencijas kaip nukreipimo puslapį + invite: + comment: Komentuoti invite_request: text: Kodėl nori prisijungti? notification_emails: diff --git a/config/locales/simple_form.nl.yml b/config/locales/simple_form.nl.yml index 8bc717fe1f..2271d7037e 100644 --- a/config/locales/simple_form.nl.yml +++ b/config/locales/simple_form.nl.yml @@ -28,7 +28,7 @@ nl: sensitive: Forceer dat alle mediabijlagen van deze gebruiker als gevoelig worden gemarkeerd. silence: Voorkom dat de gebruiker berichten kan plaatsen met openbare zichtbaarheid, verberg diens berichten en meldingen van mensen die de gebruiker niet volgen. Sluit alle rapportages tegen dit account af. suspend: Voorkom interactie van of naar dit account en verwijder de inhoud. Dit is omkeerbaar binnen 30 dagen. Dit sluit alle rapporten tegen dit account af. - warning_preset_id: Optioneel. Je kunt nog steeds handmatig tekst toevoegen aan het eind van de voorinstelling + warning_preset_id: Optioneel. Je kunt nog steeds handmatig tekst toevoegen aan het eind van de preset announcement: all_day: Wanneer dit is aangevinkt worden alleen de datums binnen het tijdvak getoond ends_at: Optioneel. De publicatie van de mededeling wordt op dit tijdstip automatisch beëindigd @@ -168,7 +168,7 @@ nl: sensitive: Gevoelig silence: Beperken suspend: Opschorten en onomkeerbaar accountgegevens verwijderen - warning_preset_id: Gebruik een voorinstelling van een waarschuwing + warning_preset_id: Een preset voor een waarschuwing gebruiken announcement: all_day: Gedurende de hele dag ends_at: Eindigt diff --git a/config/locales/simple_form.sr-Latn.yml b/config/locales/simple_form.sr-Latn.yml index 8dd1986563..710f81e84f 100644 --- a/config/locales/simple_form.sr-Latn.yml +++ b/config/locales/simple_form.sr-Latn.yml @@ -20,7 +20,7 @@ sr-Latn: admin_account_action: include_statuses: Korisnik će videti koje su objave prouzrokovale moderacijsku radnju ili upozorenje send_email_notification: Korisnik će dobiti objašnjenje toga šta mu se desilo sa nalogom - text_html: Opcionalno. Možete koristiti sintaksu objava. Možete dodati unapred određene postavke upozorenja za uštedu vremena + text_html: Opciono. Možete koristiti sintaksu objava. Možete dodati predefinisana upozorenja za uštedu vremena type_html: Izaberite šta da radite sa %{acct} types: disable: Sprečava korisnika da koristi svoj nalog, ali ne briše niti sakriva njegove sadržaje. @@ -28,7 +28,7 @@ sr-Latn: sensitive: Učini da svi medijski prilozi ovog korisnika prisilno budu označeni kao osetljivi. silence: Sprečava korisnika da pravi javne objave, sakriva njegove objave i obaveštenja od ljudi koji ga ne prate. Zatvara sve prijave podnete protiv ovog naloga. suspend: Sprečava svu interakciju od ovog naloga i ka ovom nalogu i briše njegov sadržaj. Opozivo u roku od 30 dana. Zatvara sve prijave podnete protiv ovog naloga. - warning_preset_id: Opcionalno. Možete i dalje dodati prilagođeni tekst na kraj preseta + warning_preset_id: Opciono. Možete i dalje dodati prilagođeni tekst na kraj predefinisane vrednosti announcement: all_day: Kada je ova opcija označena, samo datumi iz vremenskog opsega će biti prikazani ends_at: Opciono. Objava će biti automatski opozvana u ovom trenutku @@ -118,7 +118,7 @@ sr-Latn: sign_up_requires_approval: Nove registracije će zahtevati Vaše odobrenje severity: Izaberite šta će se desiti sa zahtevima sa ove IP adrese rule: - hint: Opcionalno. Pružite više detalja o pravilu + hint: Opciono. Pružite više detalja o pravilu text: Opišite pravilo ili uslov za korisnike na ovom serveru. Potrudite se da opis bude kratak i jednostavan sessions: otp: 'Unesite dvofaktorski kod sa Vašeg telefona ili koristite jedan od kodova za oporavak:' @@ -155,7 +155,7 @@ sr-Latn: account_migration: acct: Ručica (@) novog naloga account_warning_preset: - text: Tekst preseta + text: Tekst predefinisane vrednosti title: Naslov admin_account_action: include_statuses: Uključi prijavljene objave u e-poštu @@ -168,7 +168,7 @@ sr-Latn: sensitive: Osetljivo silence: Utišaj suspend: Obustavite i nepovratno izbrišite podatke o nalogu - warning_preset_id: Koristi upozoravajući preset + warning_preset_id: Koristi predefinisano upozorenje announcement: all_day: Celodnevni događaj ends_at: Kraj događaja diff --git a/config/locales/simple_form.sr.yml b/config/locales/simple_form.sr.yml index e88a99df13..c5fbc9185a 100644 --- a/config/locales/simple_form.sr.yml +++ b/config/locales/simple_form.sr.yml @@ -20,7 +20,7 @@ sr: admin_account_action: include_statuses: Корисник ће видети које су објаве проузроковале модерацијску радњу или упозорење send_email_notification: Корисник ће добити објашњење тога шта му се десило са налогом - text_html: Опционално. Можете користити синтаксу објава. Можете додати унапред одређене поставке упозорења за уштеду времена + text_html: Опционо. Можете користити синтаксу објава. Можете додати предефинисана упозорења за уштеду времена type_html: Изаберите шта да радите са %{acct} types: disable: Спречава корисника да користи свој налог, али не брише нити сакрива његове садржаје. @@ -28,7 +28,7 @@ sr: sensitive: Учини да сви медијски прилози овог корисника присилно буду означени као осетљиви. silence: Спречава корисника да прави јавне објаве, сакрива његове објаве и обавештења од људи који га не прате. Затвара све пријаве поднете против овог налога. suspend: Спречава сву интеракцију од овог налога и ка овом налогу и брише његов садржај. Опозиво у року од 30 дана. Затвара све пријаве поднете против овог налога. - warning_preset_id: Опционално. Можете и даље додати прилагођени текст на крај пресета + warning_preset_id: Опционо. Можете и даље додати прилагођени текст на крај предефинисане вредности announcement: all_day: Када је ова опција означена, само датуми из временског опсега ће бити приказани ends_at: Опционо. Објава ће бити аутоматски опозвана у овом тренутку @@ -88,7 +88,7 @@ sr: media_cache_retention_period: Медијске датотеке из објава удаљених корисника се кеширају на вашем серверу. Када се подеси на позитивну вредност, медији ће бити избрисани након наведеног броја дана. Ако се медијски подаци захтевају након брисања, биће поново преузети, ако је изворни садржај и даље доступан. Због ограничења колико често картице за преглед веза анкетирају сајтове трећих страна, препоручује се да ову вредност поставите на најмање 14 дана, иначе картице за преглед веза неће бити ажуриране на захтев пре тог времена. peers_api_enabled: Листа домена са којима се овај сервер сусрео у федиверзуму. Овде нису садржани подаци о томе да ли се Ваш сервер федерише са другим серверима, већ само да Ваш сервер зна за њих. Ове информације користе сервиси који прикупљају податке и воде статистику о федерацији у ширем смислу. profile_directory: Директоријум профила наводи све кориснике који су се определили да буду видљиви. - require_invite_text: Када регистрације захтевају ручно одобрење, поставите да одговор на „Зашто желите да се придружите?“ буде обавезан, а не опционалан + require_invite_text: Када регистрације захтевају ручно одобрење, постави да унос текста „Зашто желиш да се придружиш?“ буде обавезан, а не опциони site_contact_email: Како корисници могу да контактирају са Вама за правна питања или питања у вези подршке. site_contact_username: Како корисници могу да контактирају са вама на Mastodon-у. site_extended_description: Било какве додатне информације које могу бити корисне посетиоцима и Вашим корисницима. Могу се структурирати помоћу Markdown синтаксе. @@ -118,7 +118,7 @@ sr: sign_up_requires_approval: Нове регистрације ће захтевати Ваше одобрење severity: Изаберите шта ће се десити са захтевима са ове IP адресе rule: - hint: Опционално. Пружите више детаља о правилу + hint: Опционо. Пружите више детаља о правилу text: Опишите правило или услов за кориснике на овом серверу. Потрудите се да опис буде кратак и једноставан sessions: otp: 'Унесите двофакторски код са Вашег телефона или користите један од кодова за опоравак:' @@ -155,7 +155,7 @@ sr: account_migration: acct: Ручица (@) новог налога account_warning_preset: - text: Текст пресета + text: Текст предефинисане вредности title: Наслов admin_account_action: include_statuses: Укључи пријављене објаве у е-пошту @@ -168,7 +168,7 @@ sr: sensitive: Осетљиво silence: Утишај suspend: Обуставите и неповратно избришите податке о налогу - warning_preset_id: Користи упозоравајући пресет + warning_preset_id: Користи предефинисано упозорење announcement: all_day: Целодневни догађај ends_at: Крај догађаја diff --git a/config/locales/sk.yml b/config/locales/sk.yml index f05887dc33..f10815129d 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -763,7 +763,6 @@ sk: add_new: Pridaj nové delete: Vymaž edit_preset: Uprav varovnú predlohu - title: Spravuj varovné predlohy webhooks: delete: Vymaž disable: Vypni diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 329ce5a29b..1e4e254cf1 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -985,7 +985,7 @@ sl: delete: Izbriši edit_preset: Uredi prednastavitev opozoril empty: Zaenkrat še niste določili nobenih opozorilnih prednastavitev. - title: Upravljaj prednastavitev opozoril + title: Pred-nastavitve opozoril webhooks: add_new: Dodaj končno točko delete: Izbriši diff --git a/config/locales/sq.yml b/config/locales/sq.yml index 8319cfcaec..5439f08a04 100644 --- a/config/locales/sq.yml +++ b/config/locales/sq.yml @@ -285,6 +285,7 @@ sq: update_custom_emoji_html: "%{name} përditësoi emoxhin %{target}" update_domain_block_html: "%{name} përditësoi bllokim përkatësish për %{target}" update_ip_block_html: "%{name} ndryshoi rregull për IP-në %{target}" + update_report_html: "%{name} përditësoi raportimin %{target}" update_status_html: "%{name} përditësoi gjendjen me %{target}" update_user_role_html: "%{name} ndryshoi rolin për %{target}" deleted_account: fshiu llogarinë @@ -946,7 +947,7 @@ sq: delete: Fshije edit_preset: Përpunoni sinjalizim të paracaktuar empty: S’keni përcaktuar ende sinjalizime të gatshme. - title: Administroni sinjalizime të paracaktuara + title: Paracaktime sinjalizimesh webhooks: add_new: Shtoni pikëmbarim delete: Fshije diff --git a/config/locales/sr-Latn.yml b/config/locales/sr-Latn.yml index 808a10e729..718d1c0f84 100644 --- a/config/locales/sr-Latn.yml +++ b/config/locales/sr-Latn.yml @@ -869,7 +869,7 @@ sr-Latn: action: Pogledaj dokumentaciju message_html: Vaš Elasticsearch klaster ima samo jedan čvor, ES_PRESETtreba postaviti nasingle_node_cluster. elasticsearch_reset_chewy: - message_html: Vaš Elasticsearch klaster ima samo jedan čvor, ES_PRESETtreba postaviti nasingle_node_cluster. + message_html: Indeks Elasticsearch sistema je zastareo zbog promene podešavanja. Pokrenite tootctl search deploy --reset-chewyda biste ga ažurirali. elasticsearch_running_check: message_html: Povezivanje na Elasticsearch nije bilo moguće. Molimo Vas proverite da li je pokrenut, ili onemogućite pretragu celog teksta elasticsearch_version_check: @@ -966,9 +966,9 @@ sr-Latn: warning_presets: add_new: Dodaj novi delete: Izbriši - edit_preset: Uredi preset upozorenja - empty: Još uvek niste definisali nijedan šablon upozorenja. - title: Upravljaj presetima upozorenja + edit_preset: Uredi predefinisana upozorenja + empty: Još uvek niste definisali nijedno upozorenje. + title: Predefinisana upozorenja webhooks: add_new: Dodaj krajnju tačku delete: Izbriši diff --git a/config/locales/sr.yml b/config/locales/sr.yml index f03c6e878a..c9a67b1936 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -869,7 +869,7 @@ sr: action: Погледај документацију message_html: Ваш Elasticsearch кластер има само један чвор, ES_PRESETтреба поставити наsingle_node_cluster. elasticsearch_reset_chewy: - message_html: Ваш Elasticsearch кластер има само један чвор, ES_PRESETтреба поставити наsingle_node_cluster. + message_html: Индекс Elasticsearch система је застарео због промене подешавања. Покрените tootctl search deploy --reset-chewyда бисте га ажурирали. elasticsearch_running_check: message_html: Повезивање на Elasticsearch није било могуће. Молимо Вас проверите да ли је покренут, или онемогућите претрагу целог текста elasticsearch_version_check: @@ -966,9 +966,9 @@ sr: warning_presets: add_new: Додај нови delete: Избриши - edit_preset: Уреди пресет упозорења - empty: Још увек нисте дефинисали ниједан шаблон упозорења. - title: Управљај пресетима упозорења + edit_preset: Уреди предефинисана упозорења + empty: Још увек нисте дефинисали ниједно упозорење. + title: Предефинисна упозорења webhooks: add_new: Додај крајњу тачку delete: Избриши diff --git a/config/locales/sv.yml b/config/locales/sv.yml index 9f0de4a723..cf68cdd563 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -951,7 +951,6 @@ sv: delete: Radera edit_preset: Redigera varningsförval empty: Du har inte definierat några varningsförval ännu. - title: Hantera varningsförval webhooks: add_new: Lägg till slutpunkt delete: Ta bort diff --git a/config/locales/th.yml b/config/locales/th.yml index 5711f68ff8..3ca4f09733 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -934,7 +934,6 @@ th: delete: ลบ edit_preset: แก้ไขคำเตือนที่ตั้งไว้ล่วงหน้า empty: คุณยังไม่ได้กำหนดคำเตือนที่ตั้งไว้ล่วงหน้าใด ๆ - title: จัดการคำเตือนที่ตั้งไว้ล่วงหน้า webhooks: add_new: เพิ่มปลายทาง delete: ลบ diff --git a/config/locales/tr.yml b/config/locales/tr.yml index 469f2c5ad8..3ce12fec87 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -951,7 +951,7 @@ tr: delete: Sil edit_preset: Uyarı ön-ayarını düzenle empty: Henüz önceden ayarlanmış bir uyarı tanımlanmadı. - title: Uyarı ön-ayarlarını yönet + title: Uyarı Önayarları webhooks: add_new: Uç nokta ekle delete: Sil diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 71e84a1d54..5baaa93870 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -984,7 +984,6 @@ uk: delete: Видалити edit_preset: Редагувати шаблон попередження empty: Ви ще не визначили жодних попереджень. - title: Керування шаблонами попереджень webhooks: add_new: Додати кінцеву точку delete: Видалити diff --git a/config/locales/vi.yml b/config/locales/vi.yml index 05f3157ec9..4265c1a33a 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -934,7 +934,6 @@ vi: delete: Xóa bỏ edit_preset: Sửa mẫu có sẵn empty: Bạn chưa thêm mẫu cảnh cáo nào cả. - title: Quản lý mẫu cảnh cáo webhooks: add_new: Thêm endpoint delete: Xóa bỏ diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml index 12b6197938..b668c23d29 100644 --- a/config/locales/zh-CN.yml +++ b/config/locales/zh-CN.yml @@ -934,7 +934,7 @@ zh-CN: delete: 删除 edit_preset: 编辑预置警告 empty: 你尚未定义任何警告预设。 - title: 管理预设警告 + title: 预设警告 webhooks: add_new: 新增对端 delete: 删除 diff --git a/config/locales/zh-HK.yml b/config/locales/zh-HK.yml index 1bfbe38bb5..ddc6571e6d 100644 --- a/config/locales/zh-HK.yml +++ b/config/locales/zh-HK.yml @@ -933,7 +933,6 @@ zh-HK: delete: 刪除 edit_preset: 設定警告預設 empty: 您尚未定義任何預設警告 - title: 管理警告預設 webhooks: add_new: 新增端點 delete: 刪除 diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index ac633a201d..14f54f9a12 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -936,7 +936,7 @@ zh-TW: delete: 刪除 edit_preset: 編輯預設警告 empty: 您尚未定義任何預設警告。 - title: 管理預設警告 + title: 預設警告內容 webhooks: add_new: 新增端點 delete: 刪除 From 3a862439dfc989c6c5741e007c2f4e0335fffe33 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 23 May 2024 04:26:58 -0400 Subject: [PATCH 3/9] Remove unused account record in api/v2/admin/accounts spec (#30397) --- spec/requests/api/v2/admin/accounts_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/requests/api/v2/admin/accounts_spec.rb b/spec/requests/api/v2/admin/accounts_spec.rb index fb04850bb7..f5db93233c 100644 --- a/spec/requests/api/v2/admin/accounts_spec.rb +++ b/spec/requests/api/v2/admin/accounts_spec.rb @@ -8,7 +8,6 @@ RSpec.describe 'API V2 Admin Accounts' do let(:scopes) { 'admin:read admin:write' } let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } - let(:account) { Fabricate(:account) } describe 'GET #index' do let!(:remote_account) { Fabricate(:account, domain: 'example.org') } From 10ec421dd4e0da987e69a3dd7f4f696f9c5878e0 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 11:50:13 +0200 Subject: [PATCH 4/9] Proposal: a modern & typed way of writing Redux actions doing API requests (#30270) --- .../mastodon/actions/account_notes.ts | 21 +- .../mastodon/actions/interactions.js | 86 +------- .../mastodon/actions/interactions_typed.ts | 30 +++ app/javascript/mastodon/api.ts | 16 +- app/javascript/mastodon/api/accounts.ts | 7 + app/javascript/mastodon/api/interactions.ts | 10 + .../mastodon/containers/status_container.jsx | 4 +- .../containers/account_note_container.js | 2 +- .../containers/notification_container.js | 4 +- .../picture_in_picture/components/footer.jsx | 4 +- .../containers/detailed_status_container.js | 4 +- .../mastodon/features/status/index.jsx | 4 +- app/javascript/mastodon/reducers/statuses.js | 28 +-- .../mastodon/store/typed_functions.ts | 186 ++++++++++++++++++ 14 files changed, 281 insertions(+), 125 deletions(-) create mode 100644 app/javascript/mastodon/actions/interactions_typed.ts create mode 100644 app/javascript/mastodon/api/accounts.ts create mode 100644 app/javascript/mastodon/api/interactions.ts diff --git a/app/javascript/mastodon/actions/account_notes.ts b/app/javascript/mastodon/actions/account_notes.ts index acd9ecf410..bf4f93dca9 100644 --- a/app/javascript/mastodon/actions/account_notes.ts +++ b/app/javascript/mastodon/actions/account_notes.ts @@ -1,18 +1,9 @@ -import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships'; -import { createAppAsyncThunk } from 'mastodon/store/typed_functions'; +import { apiSubmitAccountNote } from 'mastodon/api/accounts'; +import { createDataLoadingThunk } from 'mastodon/store/typed_functions'; -import api from '../api'; - -export const submitAccountNote = createAppAsyncThunk( +export const submitAccountNote = createDataLoadingThunk( 'account_note/submit', - async (args: { id: string; value: string }) => { - const response = await api().post( - `/api/v1/accounts/${args.id}/note`, - { - comment: args.value, - }, - ); - - return { relationship: response.data }; - }, + (accountId: string, note: string) => apiSubmitAccountNote(accountId, note), + (relationship) => ({ relationship }), + { skipLoading: true }, ); diff --git a/app/javascript/mastodon/actions/interactions.js b/app/javascript/mastodon/actions/interactions.js index fe7c911b61..57f2459c01 100644 --- a/app/javascript/mastodon/actions/interactions.js +++ b/app/javascript/mastodon/actions/interactions.js @@ -3,10 +3,6 @@ import api, { getLinks } from '../api'; import { fetchRelationships } from './accounts'; import { importFetchedAccounts, importFetchedStatus } from './importer'; -export const REBLOG_REQUEST = 'REBLOG_REQUEST'; -export const REBLOG_SUCCESS = 'REBLOG_SUCCESS'; -export const REBLOG_FAIL = 'REBLOG_FAIL'; - export const REBLOGS_EXPAND_REQUEST = 'REBLOGS_EXPAND_REQUEST'; export const REBLOGS_EXPAND_SUCCESS = 'REBLOGS_EXPAND_SUCCESS'; export const REBLOGS_EXPAND_FAIL = 'REBLOGS_EXPAND_FAIL'; @@ -15,10 +11,6 @@ export const FAVOURITE_REQUEST = 'FAVOURITE_REQUEST'; export const FAVOURITE_SUCCESS = 'FAVOURITE_SUCCESS'; export const FAVOURITE_FAIL = 'FAVOURITE_FAIL'; -export const UNREBLOG_REQUEST = 'UNREBLOG_REQUEST'; -export const UNREBLOG_SUCCESS = 'UNREBLOG_SUCCESS'; -export const UNREBLOG_FAIL = 'UNREBLOG_FAIL'; - export const UNFAVOURITE_REQUEST = 'UNFAVOURITE_REQUEST'; export const UNFAVOURITE_SUCCESS = 'UNFAVOURITE_SUCCESS'; export const UNFAVOURITE_FAIL = 'UNFAVOURITE_FAIL'; @@ -51,83 +43,7 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST'; export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS'; export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; -export function reblog(status, visibility) { - return function (dispatch) { - dispatch(reblogRequest(status)); - - api().post(`/api/v1/statuses/${status.get('id')}/reblog`, { visibility }).then(function (response) { - // The reblog API method returns a new status wrapped around the original. In this case we are only - // interested in how the original is modified, hence passing it skipping the wrapper - dispatch(importFetchedStatus(response.data.reblog)); - dispatch(reblogSuccess(status)); - }).catch(function (error) { - dispatch(reblogFail(status, error)); - }); - }; -} - -export function unreblog(status) { - return (dispatch) => { - dispatch(unreblogRequest(status)); - - api().post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => { - dispatch(importFetchedStatus(response.data)); - dispatch(unreblogSuccess(status)); - }).catch(error => { - dispatch(unreblogFail(status, error)); - }); - }; -} - -export function reblogRequest(status) { - return { - type: REBLOG_REQUEST, - status: status, - skipLoading: true, - }; -} - -export function reblogSuccess(status) { - return { - type: REBLOG_SUCCESS, - status: status, - skipLoading: true, - }; -} - -export function reblogFail(status, error) { - return { - type: REBLOG_FAIL, - status: status, - error: error, - skipLoading: true, - }; -} - -export function unreblogRequest(status) { - return { - type: UNREBLOG_REQUEST, - status: status, - skipLoading: true, - }; -} - -export function unreblogSuccess(status) { - return { - type: UNREBLOG_SUCCESS, - status: status, - skipLoading: true, - }; -} - -export function unreblogFail(status, error) { - return { - type: UNREBLOG_FAIL, - status: status, - error: error, - skipLoading: true, - }; -} +export * from "./interactions_typed"; export function favourite(status) { return function (dispatch) { diff --git a/app/javascript/mastodon/actions/interactions_typed.ts b/app/javascript/mastodon/actions/interactions_typed.ts new file mode 100644 index 0000000000..5180806087 --- /dev/null +++ b/app/javascript/mastodon/actions/interactions_typed.ts @@ -0,0 +1,30 @@ +import { apiReblog, apiUnreblog } from 'mastodon/api/interactions'; +import type { StatusVisibility } from 'mastodon/models/status'; +import { createDataLoadingThunk } from 'mastodon/store/typed_functions'; + +import { importFetchedStatus } from './importer'; + +export const reblog = createDataLoadingThunk( + 'status/reblog', + (statusId: string, visibility: StatusVisibility) => + apiReblog(statusId, visibility), + (data, { dispatch, discardLoadData }) => { + // The reblog API method returns a new status wrapped around the original. In this case we are only + // interested in how the original is modified, hence passing it skipping the wrapper + dispatch(importFetchedStatus(data.reblog)); + + // The payload is not used in any actions + return discardLoadData; + }, +); + +export const unreblog = createDataLoadingThunk( + 'status/unreblog', + (statusId: string) => apiUnreblog(statusId), + (data, { dispatch, discardLoadData }) => { + dispatch(importFetchedStatus(data)); + + // The payload is not used in any actions + return discardLoadData; + }, +); diff --git a/app/javascript/mastodon/api.ts b/app/javascript/mastodon/api.ts index 2ccf178f00..4e5ccef08c 100644 --- a/app/javascript/mastodon/api.ts +++ b/app/javascript/mastodon/api.ts @@ -1,4 +1,4 @@ -import type { AxiosResponse, RawAxiosRequestHeaders } from 'axios'; +import type { AxiosResponse, Method, RawAxiosRequestHeaders } from 'axios'; import axios from 'axios'; import LinkHeader from 'http-link-header'; @@ -58,3 +58,17 @@ export default function api(withAuthorization = true) { ], }); } + +export async function apiRequest( + method: Method, + url: string, + params?: unknown, +) { + const { data } = await api().request({ + method, + url, + params, + }); + + return data; +} diff --git a/app/javascript/mastodon/api/accounts.ts b/app/javascript/mastodon/api/accounts.ts new file mode 100644 index 0000000000..51b1f4f8de --- /dev/null +++ b/app/javascript/mastodon/api/accounts.ts @@ -0,0 +1,7 @@ +import { apiRequest } from 'mastodon/api'; +import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships'; + +export const apiSubmitAccountNote = (id: string, value: string) => + apiRequest('post', `/api/v1/accounts/${id}/note`, { + comment: value, + }); diff --git a/app/javascript/mastodon/api/interactions.ts b/app/javascript/mastodon/api/interactions.ts new file mode 100644 index 0000000000..4c466a1b46 --- /dev/null +++ b/app/javascript/mastodon/api/interactions.ts @@ -0,0 +1,10 @@ +import { apiRequest } from 'mastodon/api'; +import type { Status, StatusVisibility } from 'mastodon/models/status'; + +export const apiReblog = (statusId: string, visibility: StatusVisibility) => + apiRequest<{ reblog: Status }>('post', `v1/statuses/${statusId}/reblog`, { + visibility, + }); + +export const apiUnreblog = (statusId: string) => + apiRequest('post', `v1/statuses/${statusId}/unreblog`); diff --git a/app/javascript/mastodon/containers/status_container.jsx b/app/javascript/mastodon/containers/status_container.jsx index c6842e8df8..0174e5a02c 100644 --- a/app/javascript/mastodon/containers/status_container.jsx +++ b/app/javascript/mastodon/containers/status_container.jsx @@ -96,9 +96,9 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ onModalReblog (status, privacy) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); } }, diff --git a/app/javascript/mastodon/features/account/containers/account_note_container.js b/app/javascript/mastodon/features/account/containers/account_note_container.js index 20304a4524..9fbe0671c0 100644 --- a/app/javascript/mastodon/features/account/containers/account_note_container.js +++ b/app/javascript/mastodon/features/account/containers/account_note_container.js @@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({ const mapDispatchToProps = (dispatch, { account }) => ({ onSave (value) { - dispatch(submitAccountNote({ id: account.get('id'), value})); + dispatch(submitAccountNote(account.get('id'), value)); }, }); diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js index de450cd1ab..d829cb833e 100644 --- a/app/javascript/mastodon/features/notifications/containers/notification_container.js +++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js @@ -39,12 +39,12 @@ const mapDispatchToProps = dispatch => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx b/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx index d6b1b5fa81..1c142f3c10 100644 --- a/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx +++ b/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx @@ -123,7 +123,7 @@ class Footer extends ImmutablePureComponent { _performReblog = (status, privacy) => { const { dispatch } = this.props; - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }; handleReblogClick = e => { @@ -132,7 +132,7 @@ class Footer extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else if ((e && e.shiftKey) || !boostModal) { this._performReblog(status); } else { diff --git a/app/javascript/mastodon/features/status/containers/detailed_status_container.js b/app/javascript/mastodon/features/status/containers/detailed_status_container.js index 1c650f544f..91bc700e98 100644 --- a/app/javascript/mastodon/features/status/containers/detailed_status_container.js +++ b/app/javascript/mastodon/features/status/containers/detailed_status_container.js @@ -74,12 +74,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/mastodon/features/status/index.jsx b/app/javascript/mastodon/features/status/index.jsx index 3a9bf524f8..48f045a4af 100644 --- a/app/javascript/mastodon/features/status/index.jsx +++ b/app/javascript/mastodon/features/status/index.jsx @@ -299,7 +299,7 @@ class Status extends ImmutablePureComponent { }; handleModalReblog = (status, privacy) => { - this.props.dispatch(reblog(status, privacy)); + this.props.dispatch(reblog(status.id, privacy)); }; handleReblogClick = (status, e) => { @@ -308,7 +308,7 @@ class Status extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { if ((e && e.shiftKey) || !boostModal) { this.handleModalReblog(status); diff --git a/app/javascript/mastodon/reducers/statuses.js b/app/javascript/mastodon/reducers/statuses.js index 683fe848f7..1da1c9cf2f 100644 --- a/app/javascript/mastodon/reducers/statuses.js +++ b/app/javascript/mastodon/reducers/statuses.js @@ -3,10 +3,6 @@ import { Map as ImmutableMap, fromJS } from 'immutable'; import { STATUS_IMPORT, STATUSES_IMPORT } from '../actions/importer'; import { normalizeStatusTranslation } from '../actions/importer/normalizer'; import { - REBLOG_REQUEST, - REBLOG_FAIL, - UNREBLOG_REQUEST, - UNREBLOG_FAIL, FAVOURITE_REQUEST, FAVOURITE_FAIL, UNFAVOURITE_REQUEST, @@ -16,6 +12,10 @@ import { UNBOOKMARK_REQUEST, UNBOOKMARK_FAIL, } from '../actions/interactions'; +import { + reblog, + unreblog, +} from '../actions/interactions_typed'; import { STATUS_MUTE_SUCCESS, STATUS_UNMUTE_SUCCESS, @@ -65,6 +65,7 @@ const statusTranslateUndo = (state, id) => { const initialState = ImmutableMap(); +/** @type {import('@reduxjs/toolkit').Reducer} */ export default function statuses(state = initialState, action) { switch(action.type) { case STATUS_FETCH_REQUEST: @@ -91,14 +92,6 @@ export default function statuses(state = initialState, action) { return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'bookmarked'], false); case UNBOOKMARK_FAIL: return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'bookmarked'], true); - case REBLOG_REQUEST: - return state.setIn([action.status.get('id'), 'reblogged'], true); - case REBLOG_FAIL: - return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], false); - case UNREBLOG_REQUEST: - return state.setIn([action.status.get('id'), 'reblogged'], false); - case UNREBLOG_FAIL: - return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], true); case STATUS_MUTE_SUCCESS: return state.setIn([action.id, 'muted'], true); case STATUS_UNMUTE_SUCCESS: @@ -128,6 +121,15 @@ export default function statuses(state = initialState, action) { case STATUS_TRANSLATE_UNDO: return statusTranslateUndo(state, action.id); default: - return state; + if(reblog.pending.match(action)) + return state.setIn([action.meta.params.statusId, 'reblogged'], true); + else if(reblog.rejected.match(action)) + return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], false); + else if(unreblog.pending.match(action)) + return state.setIn([action.meta.params.statusId, 'reblogged'], false); + else if(unreblog.rejected.match(action)) + return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], true); + else + return state; } } diff --git a/app/javascript/mastodon/store/typed_functions.ts b/app/javascript/mastodon/store/typed_functions.ts index b66d7545c5..4b07a55610 100644 --- a/app/javascript/mastodon/store/typed_functions.ts +++ b/app/javascript/mastodon/store/typed_functions.ts @@ -2,6 +2,8 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { useDispatch, useSelector } from 'react-redux'; +import type { BaseThunkAPI } from '@reduxjs/toolkit/dist/createAsyncThunk'; + import type { AppDispatch, RootState } from './store'; export const useAppDispatch = useDispatch.withTypes(); @@ -13,8 +15,192 @@ export interface AsyncThunkRejectValue { error?: unknown; } +interface AppMeta { + skipLoading?: boolean; +} + export const createAppAsyncThunk = createAsyncThunk.withTypes<{ state: RootState; dispatch: AppDispatch; rejectValue: AsyncThunkRejectValue; }>(); + +type AppThunkApi = Pick< + BaseThunkAPI< + RootState, + unknown, + AppDispatch, + AsyncThunkRejectValue, + AppMeta, + AppMeta + >, + 'getState' | 'dispatch' +>; + +interface AppThunkOptions { + skipLoading?: boolean; +} + +const createBaseAsyncThunk = createAsyncThunk.withTypes<{ + state: RootState; + dispatch: AppDispatch; + rejectValue: AsyncThunkRejectValue; + fulfilledMeta: AppMeta; + rejectedMeta: AppMeta; +}>(); + +export function createThunk( + name: string, + creator: (arg: Arg, api: AppThunkApi) => Returned | Promise, + options: AppThunkOptions = {}, +) { + return createBaseAsyncThunk( + name, + async ( + arg: Arg, + { getState, dispatch, fulfillWithValue, rejectWithValue }, + ) => { + try { + const result = await creator(arg, { dispatch, getState }); + + return fulfillWithValue(result, { + skipLoading: options.skipLoading, + }); + } catch (error) { + return rejectWithValue({ error }, { skipLoading: true }); + } + }, + { + getPendingMeta() { + if (options.skipLoading) return { skipLoading: true }; + return {}; + }, + }, + ); +} + +const discardLoadDataInPayload = Symbol('discardLoadDataInPayload'); +type DiscardLoadData = typeof discardLoadDataInPayload; + +type OnData = ( + data: LoadDataResult, + api: AppThunkApi & { + discardLoadData: DiscardLoadData; + }, +) => ReturnedData | DiscardLoadData | Promise; + +// Overload when there is no `onData` method, the payload is the `onData` result +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when the `onData` method returns discardLoadDataInPayload, then the payload is empty +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: + | AppThunkOptions + | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when the `onData` method returns nothing, then the mayload is the `onData` result +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when there is an `onData` method returning something +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], + Returned, +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +/** + * This function creates a Redux Thunk that handles loading data asynchronously (usually from the API), dispatching `pending`, `fullfilled` and `rejected` actions. + * + * You can run a callback on the `onData` results to either dispatch side effects or modify the payload. + * + * It is a wrapper around RTK's [`createAsyncThunk`](https://redux-toolkit.js.org/api/createAsyncThunk) + * @param name Prefix for the actions types + * @param loadData Function that loads the data. It's arguments will become the thunk's arguments + * @param onDataOrThunkOptions + * Callback called on the results from `loadData`. + * + * First argument will be the return from `loadData`. + * + * Second argument is an object with: `dispatch`, `getState` and `discardLoadData`. + * It can return: + * - `undefined` (or no explicit return), meaning that the `onData` results will be the payload + * - `discardLoadData` to discard the `onData` results and return an empty payload + * - anything else, which will be the payload + * + * You can also omit this parameter and pass `thunkOptions` directly + * @param maybeThunkOptions + * Additional Mastodon specific options for the thunk. Currently supports: + * - `skipLoading` to avoid showing the loading bar when the request is in progress + * @returns The created thunk + */ +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], + Returned, +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + maybeThunkOptions?: AppThunkOptions, +) { + let onData: OnData | undefined; + let thunkOptions: AppThunkOptions | undefined; + + if (typeof onDataOrThunkOptions === 'function') onData = onDataOrThunkOptions; + else if (typeof onDataOrThunkOptions === 'object') + thunkOptions = onDataOrThunkOptions; + + if (maybeThunkOptions) { + thunkOptions = maybeThunkOptions; + } + + return createThunk( + name, + async (arg, { getState, dispatch }) => { + const data = await loadData(...arg); + + if (!onData) return data as Returned; + + const result = await onData(data, { + dispatch, + getState, + discardLoadData: discardLoadDataInPayload, + }); + + // if there is no return in `onData`, we return the `onData` result + if (typeof result === 'undefined') return data as Returned; + // the user explicitely asked to discard the payload + else if (result === discardLoadDataInPayload) + return undefined as Returned; + else return result; + }, + thunkOptions, + ); +} From 133d98fb25e623745326945b3800173c27519d57 Mon Sep 17 00:00:00 2001 From: Claire Date: Thu, 23 May 2024 19:28:18 +0200 Subject: [PATCH 5/9] Normalize language code of incoming posts (#30403) --- app/lib/activitypub/parser/status_parser.rb | 11 +++- .../activitypub/parser/status_parser_spec.rb | 50 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 spec/lib/activitypub/parser/status_parser_spec.rb diff --git a/app/lib/activitypub/parser/status_parser.rb b/app/lib/activitypub/parser/status_parser.rb index cfc2b8788b..2940aea44b 100644 --- a/app/lib/activitypub/parser/status_parser.rb +++ b/app/lib/activitypub/parser/status_parser.rb @@ -3,6 +3,8 @@ class ActivityPub::Parser::StatusParser include JsonLdHelper + NORMALIZED_LOCALE_NAMES = LanguagesHelper::SUPPORTED_LOCALES.keys.index_by(&:downcase).freeze + # @param [Hash] json # @param [Hash] options # @option options [String] :followers_collection @@ -87,6 +89,13 @@ class ActivityPub::Parser::StatusParser end def language + lang = raw_language_code + lang.presence && NORMALIZED_LOCALE_NAMES.fetch(lang.downcase.to_sym, lang) + end + + private + + def raw_language_code if content_language_map? @object['contentMap'].keys.first elsif name_language_map? @@ -96,8 +105,6 @@ class ActivityPub::Parser::StatusParser end end - private - def audience_to as_array(@object['to'] || @json['to']).map { |x| value_or_id(x) } end diff --git a/spec/lib/activitypub/parser/status_parser_spec.rb b/spec/lib/activitypub/parser/status_parser_spec.rb new file mode 100644 index 0000000000..5d9f008db1 --- /dev/null +++ b/spec/lib/activitypub/parser/status_parser_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe ActivityPub::Parser::StatusParser do + subject { described_class.new(json) } + + let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', domain: 'example.com', uri: 'https://example.com/actor') } + let(:follower) { Fabricate(:account, username: 'bob') } + + let(:json) do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: [ActivityPub::TagManager.instance.uri_for(sender), '#foo'].join, + type: 'Create', + actor: ActivityPub::TagManager.instance.uri_for(sender), + object: object_json, + }.with_indifferent_access + end + + let(:object_json) do + { + id: [ActivityPub::TagManager.instance.uri_for(sender), 'post1'].join('/'), + type: 'Note', + to: [ + 'https://www.w3.org/ns/activitystreams#Public', + ActivityPub::TagManager.instance.uri_for(follower), + ], + content: '@bob lorem ipsum', + contentMap: { + EN: '@bob lorem ipsum', + }, + published: 1.hour.ago.utc.iso8601, + updated: 1.hour.ago.utc.iso8601, + tag: { + type: 'Mention', + href: ActivityPub::TagManager.instance.uri_for(follower), + }, + } + end + + it 'correctly parses status' do + expect(subject).to have_attributes( + text: '@bob lorem ipsum', + uri: [ActivityPub::TagManager.instance.uri_for(sender), 'post1'].join('/'), + reply: false, + language: :en + ) + end +end From c465ef75602d1b9c92d640de9971a2798355585f Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 09:30:48 +0200 Subject: [PATCH 6/9] [Glitch] Fix some API calls that should not use an API token Port 15d307075479cf93ea199be0f25820003ddbe27c to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/api.ts | 4 ++-- app/javascript/flavours/glitch/components/admin/Counter.jsx | 2 +- app/javascript/flavours/glitch/components/admin/Dimension.jsx | 2 +- .../flavours/glitch/components/admin/ImpactReport.jsx | 2 +- .../flavours/glitch/components/admin/ReportReasonSelector.jsx | 4 ++-- app/javascript/flavours/glitch/components/admin/Retention.jsx | 2 +- app/javascript/flavours/glitch/components/admin/Trends.jsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/javascript/flavours/glitch/api.ts b/app/javascript/flavours/glitch/api.ts index ccff68c373..2ccf178f00 100644 --- a/app/javascript/flavours/glitch/api.ts +++ b/app/javascript/flavours/glitch/api.ts @@ -40,11 +40,11 @@ const authorizationTokenFromInitialState = (): RawAxiosRequestHeaders => { }; // eslint-disable-next-line import/no-default-export -export default function api() { +export default function api(withAuthorization = true) { return axios.create({ headers: { ...csrfHeader, - ...authorizationTokenFromInitialState(), + ...(withAuthorization ? authorizationTokenFromInitialState() : {}), }, transformResponse: [ diff --git a/app/javascript/flavours/glitch/components/admin/Counter.jsx b/app/javascript/flavours/glitch/components/admin/Counter.jsx index 9bb792fc9d..ce62c93570 100644 --- a/app/javascript/flavours/glitch/components/admin/Counter.jsx +++ b/app/javascript/flavours/glitch/components/admin/Counter.jsx @@ -48,7 +48,7 @@ export default class Counter extends PureComponent { componentDidMount () { const { measure, start_at, end_at, params } = this.props; - api().post('/api/v1/admin/measures', { keys: [measure], start_at, end_at, [measure]: params }).then(res => { + api(false).post('/api/v1/admin/measures', { keys: [measure], start_at, end_at, [measure]: params }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/flavours/glitch/components/admin/Dimension.jsx b/app/javascript/flavours/glitch/components/admin/Dimension.jsx index 793fe2dd76..de24a4bf3c 100644 --- a/app/javascript/flavours/glitch/components/admin/Dimension.jsx +++ b/app/javascript/flavours/glitch/components/admin/Dimension.jsx @@ -26,7 +26,7 @@ export default class Dimension extends PureComponent { componentDidMount () { const { start_at, end_at, dimension, limit, params } = this.props; - api().post('/api/v1/admin/dimensions', { keys: [dimension], start_at, end_at, limit, [dimension]: params }).then(res => { + api(false).post('/api/v1/admin/dimensions', { keys: [dimension], start_at, end_at, limit, [dimension]: params }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/flavours/glitch/components/admin/ImpactReport.jsx b/app/javascript/flavours/glitch/components/admin/ImpactReport.jsx index 9ec1460fcf..06d1a6a343 100644 --- a/app/javascript/flavours/glitch/components/admin/ImpactReport.jsx +++ b/app/javascript/flavours/glitch/components/admin/ImpactReport.jsx @@ -27,7 +27,7 @@ export default class ImpactReport extends PureComponent { include_subdomains: true, }; - api().post('/api/v1/admin/measures', { + api(false).post('/api/v1/admin/measures', { keys: ['instance_accounts', 'instance_follows', 'instance_followers'], start_at: null, end_at: null, diff --git a/app/javascript/flavours/glitch/components/admin/ReportReasonSelector.jsx b/app/javascript/flavours/glitch/components/admin/ReportReasonSelector.jsx index 9ff1d30899..323e0b0d39 100644 --- a/app/javascript/flavours/glitch/components/admin/ReportReasonSelector.jsx +++ b/app/javascript/flavours/glitch/components/admin/ReportReasonSelector.jsx @@ -105,7 +105,7 @@ class ReportReasonSelector extends PureComponent { }; componentDidMount() { - api().get('/api/v1/instance').then(res => { + api(false).get('/api/v1/instance').then(res => { this.setState({ rules: res.data.rules, }); @@ -122,7 +122,7 @@ class ReportReasonSelector extends PureComponent { return; } - api().put(`/api/v1/admin/reports/${id}`, { + api(false).put(`/api/v1/admin/reports/${id}`, { category, rule_ids: category === 'violation' ? rule_ids : [], }).catch(err => { diff --git a/app/javascript/flavours/glitch/components/admin/Retention.jsx b/app/javascript/flavours/glitch/components/admin/Retention.jsx index e9f0ea2e0f..e2a19d5844 100644 --- a/app/javascript/flavours/glitch/components/admin/Retention.jsx +++ b/app/javascript/flavours/glitch/components/admin/Retention.jsx @@ -34,7 +34,7 @@ export default class Retention extends PureComponent { componentDidMount () { const { start_at, end_at, frequency } = this.props; - api().post('/api/v1/admin/retention', { start_at, end_at, frequency }).then(res => { + api(false).post('/api/v1/admin/retention', { start_at, end_at, frequency }).then(res => { this.setState({ loading: false, data: res.data, diff --git a/app/javascript/flavours/glitch/components/admin/Trends.jsx b/app/javascript/flavours/glitch/components/admin/Trends.jsx index d7755fcdbb..b64f3f90ab 100644 --- a/app/javascript/flavours/glitch/components/admin/Trends.jsx +++ b/app/javascript/flavours/glitch/components/admin/Trends.jsx @@ -22,7 +22,7 @@ export default class Trends extends PureComponent { componentDidMount () { const { limit } = this.props; - api().get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { + api(false).get('/api/v1/admin/trends/tags', { params: { limit } }).then(res => { this.setState({ loading: false, data: res.data, From b6fd14f0e2842eca269ef8962e3c5bd560a76357 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 20:22:42 +0200 Subject: [PATCH 7/9] Fix `createDataLoadingThunk` and related actions (#30408) --- .../mastodon/actions/account_notes.ts | 3 ++- .../mastodon/actions/interactions_typed.ts | 11 ++++++--- app/javascript/mastodon/api.ts | 6 ++--- app/javascript/mastodon/api/accounts.ts | 2 +- .../mastodon/containers/status_container.jsx | 4 ++-- .../containers/account_note_container.js | 2 +- .../containers/notification_container.js | 4 ++-- .../picture_in_picture/components/footer.jsx | 4 ++-- .../containers/detailed_status_container.js | 4 ++-- .../mastodon/features/status/index.jsx | 4 ++-- app/javascript/mastodon/reducers/statuses.js | 8 +++---- .../mastodon/store/typed_functions.ts | 24 +++++++++---------- 12 files changed, 41 insertions(+), 35 deletions(-) diff --git a/app/javascript/mastodon/actions/account_notes.ts b/app/javascript/mastodon/actions/account_notes.ts index bf4f93dca9..c2ebaf54a4 100644 --- a/app/javascript/mastodon/actions/account_notes.ts +++ b/app/javascript/mastodon/actions/account_notes.ts @@ -3,7 +3,8 @@ import { createDataLoadingThunk } from 'mastodon/store/typed_functions'; export const submitAccountNote = createDataLoadingThunk( 'account_note/submit', - (accountId: string, note: string) => apiSubmitAccountNote(accountId, note), + ({ accountId, note }: { accountId: string; note: string }) => + apiSubmitAccountNote(accountId, note), (relationship) => ({ relationship }), { skipLoading: true }, ); diff --git a/app/javascript/mastodon/actions/interactions_typed.ts b/app/javascript/mastodon/actions/interactions_typed.ts index 5180806087..f58faffa86 100644 --- a/app/javascript/mastodon/actions/interactions_typed.ts +++ b/app/javascript/mastodon/actions/interactions_typed.ts @@ -6,8 +6,13 @@ import { importFetchedStatus } from './importer'; export const reblog = createDataLoadingThunk( 'status/reblog', - (statusId: string, visibility: StatusVisibility) => - apiReblog(statusId, visibility), + ({ + statusId, + visibility, + }: { + statusId: string; + visibility: StatusVisibility; + }) => apiReblog(statusId, visibility), (data, { dispatch, discardLoadData }) => { // The reblog API method returns a new status wrapped around the original. In this case we are only // interested in how the original is modified, hence passing it skipping the wrapper @@ -20,7 +25,7 @@ export const reblog = createDataLoadingThunk( export const unreblog = createDataLoadingThunk( 'status/unreblog', - (statusId: string) => apiUnreblog(statusId), + ({ statusId }: { statusId: string }) => apiUnreblog(statusId), (data, { dispatch, discardLoadData }) => { dispatch(importFetchedStatus(data)); diff --git a/app/javascript/mastodon/api.ts b/app/javascript/mastodon/api.ts index 4e5ccef08c..e133125a29 100644 --- a/app/javascript/mastodon/api.ts +++ b/app/javascript/mastodon/api.ts @@ -62,12 +62,12 @@ export default function api(withAuthorization = true) { export async function apiRequest( method: Method, url: string, - params?: unknown, + params?: Record, ) { const { data } = await api().request({ method, - url, - params, + url: '/api/' + url, + data: params, }); return data; diff --git a/app/javascript/mastodon/api/accounts.ts b/app/javascript/mastodon/api/accounts.ts index 51b1f4f8de..3d89e44b26 100644 --- a/app/javascript/mastodon/api/accounts.ts +++ b/app/javascript/mastodon/api/accounts.ts @@ -2,6 +2,6 @@ import { apiRequest } from 'mastodon/api'; import type { ApiRelationshipJSON } from 'mastodon/api_types/relationships'; export const apiSubmitAccountNote = (id: string, value: string) => - apiRequest('post', `/api/v1/accounts/${id}/note`, { + apiRequest('post', `v1/accounts/${id}/note`, { comment: value, }); diff --git a/app/javascript/mastodon/containers/status_container.jsx b/app/javascript/mastodon/containers/status_container.jsx index 0174e5a02c..4a9b525777 100644 --- a/app/javascript/mastodon/containers/status_container.jsx +++ b/app/javascript/mastodon/containers/status_container.jsx @@ -96,9 +96,9 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ onModalReblog (status, privacy) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); } }, diff --git a/app/javascript/mastodon/features/account/containers/account_note_container.js b/app/javascript/mastodon/features/account/containers/account_note_container.js index 9fbe0671c0..1530242d69 100644 --- a/app/javascript/mastodon/features/account/containers/account_note_container.js +++ b/app/javascript/mastodon/features/account/containers/account_note_container.js @@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({ const mapDispatchToProps = (dispatch, { account }) => ({ onSave (value) { - dispatch(submitAccountNote(account.get('id'), value)); + dispatch(submitAccountNote({ accountId: account.get('id'), note: value })); }, }); diff --git a/app/javascript/mastodon/features/notifications/containers/notification_container.js b/app/javascript/mastodon/features/notifications/containers/notification_container.js index d829cb833e..650acf4ccd 100644 --- a/app/javascript/mastodon/features/notifications/containers/notification_container.js +++ b/app/javascript/mastodon/features/notifications/containers/notification_container.js @@ -39,12 +39,12 @@ const mapDispatchToProps = dispatch => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx b/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx index 1c142f3c10..ba0642da28 100644 --- a/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx +++ b/app/javascript/mastodon/features/picture_in_picture/components/footer.jsx @@ -123,7 +123,7 @@ class Footer extends ImmutablePureComponent { _performReblog = (status, privacy) => { const { dispatch } = this.props; - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }; handleReblogClick = e => { @@ -132,7 +132,7 @@ class Footer extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else if ((e && e.shiftKey) || !boostModal) { this._performReblog(status); } else { diff --git a/app/javascript/mastodon/features/status/containers/detailed_status_container.js b/app/javascript/mastodon/features/status/containers/detailed_status_container.js index 91bc700e98..c3d4fec4db 100644 --- a/app/javascript/mastodon/features/status/containers/detailed_status_container.js +++ b/app/javascript/mastodon/features/status/containers/detailed_status_container.js @@ -74,12 +74,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/mastodon/features/status/index.jsx b/app/javascript/mastodon/features/status/index.jsx index 48f045a4af..7f37cb50d2 100644 --- a/app/javascript/mastodon/features/status/index.jsx +++ b/app/javascript/mastodon/features/status/index.jsx @@ -299,7 +299,7 @@ class Status extends ImmutablePureComponent { }; handleModalReblog = (status, privacy) => { - this.props.dispatch(reblog(status.id, privacy)); + this.props.dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }; handleReblogClick = (status, e) => { @@ -308,7 +308,7 @@ class Status extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { if ((e && e.shiftKey) || !boostModal) { this.handleModalReblog(status); diff --git a/app/javascript/mastodon/reducers/statuses.js b/app/javascript/mastodon/reducers/statuses.js index 1da1c9cf2f..ca766f73a3 100644 --- a/app/javascript/mastodon/reducers/statuses.js +++ b/app/javascript/mastodon/reducers/statuses.js @@ -122,13 +122,13 @@ export default function statuses(state = initialState, action) { return statusTranslateUndo(state, action.id); default: if(reblog.pending.match(action)) - return state.setIn([action.meta.params.statusId, 'reblogged'], true); + return state.setIn([action.meta.arg.statusId, 'reblogged'], true); else if(reblog.rejected.match(action)) - return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], false); + return state.get(action.meta.arg.statusId) === undefined ? state : state.setIn([action.meta.arg.statusId, 'reblogged'], false); else if(unreblog.pending.match(action)) - return state.setIn([action.meta.params.statusId, 'reblogged'], false); + return state.setIn([action.meta.arg.statusId, 'reblogged'], false); else if(unreblog.rejected.match(action)) - return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], true); + return state.get(action.meta.arg.statusId) === undefined ? state : state.setIn([action.meta.arg.statusId, 'reblogged'], true); else return state; } diff --git a/app/javascript/mastodon/store/typed_functions.ts b/app/javascript/mastodon/store/typed_functions.ts index 4b07a55610..0392f373c0 100644 --- a/app/javascript/mastodon/store/typed_functions.ts +++ b/app/javascript/mastodon/store/typed_functions.ts @@ -92,20 +92,20 @@ type OnData = ( // Overload when there is no `onData` method, the payload is the `onData` result export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, thunkOptions?: AppThunkOptions, ): ReturnType>; // Overload when the `onData` method returns discardLoadDataInPayload, then the payload is empty export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: | AppThunkOptions | OnData, @@ -115,10 +115,10 @@ export function createDataLoadingThunk< // Overload when the `onData` method returns nothing, then the mayload is the `onData` result export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, thunkOptions?: AppThunkOptions, ): ReturnType>; @@ -126,11 +126,11 @@ export function createDataLoadingThunk< // Overload when there is an `onData` method returning something export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, Returned, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, thunkOptions?: AppThunkOptions, ): ReturnType>; @@ -142,7 +142,7 @@ export function createDataLoadingThunk< * * It is a wrapper around RTK's [`createAsyncThunk`](https://redux-toolkit.js.org/api/createAsyncThunk) * @param name Prefix for the actions types - * @param loadData Function that loads the data. It's arguments will become the thunk's arguments + * @param loadData Function that loads the data. It's (object) argument will become the thunk's argument * @param onDataOrThunkOptions * Callback called on the results from `loadData`. * @@ -162,11 +162,11 @@ export function createDataLoadingThunk< */ export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, Returned, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, maybeThunkOptions?: AppThunkOptions, ) { @@ -184,7 +184,7 @@ export function createDataLoadingThunk< return createThunk( name, async (arg, { getState, dispatch }) => { - const data = await loadData(...arg); + const data = await loadData(arg); if (!onData) return data as Returned; From 8d6058b40a8953e16338b57f5ba0e17fc07a1bd2 Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 11:50:13 +0200 Subject: [PATCH 8/9] [Glitch] Proposal: a modern & typed way of writing Redux actions doing API requests Port 10ec421dd4e0da987e69a3dd7f4f696f9c5878e0 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/actions/account_notes.ts | 21 +- .../flavours/glitch/actions/interactions.js | 86 +------- .../glitch/actions/interactions_typed.ts | 30 +++ app/javascript/flavours/glitch/api.ts | 16 +- .../flavours/glitch/api/accounts.ts | 7 + .../flavours/glitch/api/interactions.ts | 10 + .../glitch/containers/status_container.js | 4 +- .../containers/account_note_container.js | 2 +- .../containers/notification_container.js | 4 +- .../picture_in_picture/components/footer.jsx | 4 +- .../containers/detailed_status_container.js | 4 +- .../flavours/glitch/features/status/index.jsx | 4 +- .../flavours/glitch/reducers/statuses.js | 28 +-- .../flavours/glitch/store/typed_functions.ts | 186 ++++++++++++++++++ 14 files changed, 281 insertions(+), 125 deletions(-) create mode 100644 app/javascript/flavours/glitch/actions/interactions_typed.ts create mode 100644 app/javascript/flavours/glitch/api/accounts.ts create mode 100644 app/javascript/flavours/glitch/api/interactions.ts diff --git a/app/javascript/flavours/glitch/actions/account_notes.ts b/app/javascript/flavours/glitch/actions/account_notes.ts index b3e79a92c6..9b05ae06c2 100644 --- a/app/javascript/flavours/glitch/actions/account_notes.ts +++ b/app/javascript/flavours/glitch/actions/account_notes.ts @@ -1,18 +1,9 @@ -import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships'; -import { createAppAsyncThunk } from 'flavours/glitch/store/typed_functions'; +import { apiSubmitAccountNote } from 'flavours/glitch/api/accounts'; +import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; -import api from '../api'; - -export const submitAccountNote = createAppAsyncThunk( +export const submitAccountNote = createDataLoadingThunk( 'account_note/submit', - async (args: { id: string; value: string }) => { - const response = await api().post( - `/api/v1/accounts/${args.id}/note`, - { - comment: args.value, - }, - ); - - return { relationship: response.data }; - }, + (accountId: string, note: string) => apiSubmitAccountNote(accountId, note), + (relationship) => ({ relationship }), + { skipLoading: true }, ); diff --git a/app/javascript/flavours/glitch/actions/interactions.js b/app/javascript/flavours/glitch/actions/interactions.js index fe7c911b61..57f2459c01 100644 --- a/app/javascript/flavours/glitch/actions/interactions.js +++ b/app/javascript/flavours/glitch/actions/interactions.js @@ -3,10 +3,6 @@ import api, { getLinks } from '../api'; import { fetchRelationships } from './accounts'; import { importFetchedAccounts, importFetchedStatus } from './importer'; -export const REBLOG_REQUEST = 'REBLOG_REQUEST'; -export const REBLOG_SUCCESS = 'REBLOG_SUCCESS'; -export const REBLOG_FAIL = 'REBLOG_FAIL'; - export const REBLOGS_EXPAND_REQUEST = 'REBLOGS_EXPAND_REQUEST'; export const REBLOGS_EXPAND_SUCCESS = 'REBLOGS_EXPAND_SUCCESS'; export const REBLOGS_EXPAND_FAIL = 'REBLOGS_EXPAND_FAIL'; @@ -15,10 +11,6 @@ export const FAVOURITE_REQUEST = 'FAVOURITE_REQUEST'; export const FAVOURITE_SUCCESS = 'FAVOURITE_SUCCESS'; export const FAVOURITE_FAIL = 'FAVOURITE_FAIL'; -export const UNREBLOG_REQUEST = 'UNREBLOG_REQUEST'; -export const UNREBLOG_SUCCESS = 'UNREBLOG_SUCCESS'; -export const UNREBLOG_FAIL = 'UNREBLOG_FAIL'; - export const UNFAVOURITE_REQUEST = 'UNFAVOURITE_REQUEST'; export const UNFAVOURITE_SUCCESS = 'UNFAVOURITE_SUCCESS'; export const UNFAVOURITE_FAIL = 'UNFAVOURITE_FAIL'; @@ -51,83 +43,7 @@ export const UNBOOKMARK_REQUEST = 'UNBOOKMARKED_REQUEST'; export const UNBOOKMARK_SUCCESS = 'UNBOOKMARKED_SUCCESS'; export const UNBOOKMARK_FAIL = 'UNBOOKMARKED_FAIL'; -export function reblog(status, visibility) { - return function (dispatch) { - dispatch(reblogRequest(status)); - - api().post(`/api/v1/statuses/${status.get('id')}/reblog`, { visibility }).then(function (response) { - // The reblog API method returns a new status wrapped around the original. In this case we are only - // interested in how the original is modified, hence passing it skipping the wrapper - dispatch(importFetchedStatus(response.data.reblog)); - dispatch(reblogSuccess(status)); - }).catch(function (error) { - dispatch(reblogFail(status, error)); - }); - }; -} - -export function unreblog(status) { - return (dispatch) => { - dispatch(unreblogRequest(status)); - - api().post(`/api/v1/statuses/${status.get('id')}/unreblog`).then(response => { - dispatch(importFetchedStatus(response.data)); - dispatch(unreblogSuccess(status)); - }).catch(error => { - dispatch(unreblogFail(status, error)); - }); - }; -} - -export function reblogRequest(status) { - return { - type: REBLOG_REQUEST, - status: status, - skipLoading: true, - }; -} - -export function reblogSuccess(status) { - return { - type: REBLOG_SUCCESS, - status: status, - skipLoading: true, - }; -} - -export function reblogFail(status, error) { - return { - type: REBLOG_FAIL, - status: status, - error: error, - skipLoading: true, - }; -} - -export function unreblogRequest(status) { - return { - type: UNREBLOG_REQUEST, - status: status, - skipLoading: true, - }; -} - -export function unreblogSuccess(status) { - return { - type: UNREBLOG_SUCCESS, - status: status, - skipLoading: true, - }; -} - -export function unreblogFail(status, error) { - return { - type: UNREBLOG_FAIL, - status: status, - error: error, - skipLoading: true, - }; -} +export * from "./interactions_typed"; export function favourite(status) { return function (dispatch) { diff --git a/app/javascript/flavours/glitch/actions/interactions_typed.ts b/app/javascript/flavours/glitch/actions/interactions_typed.ts new file mode 100644 index 0000000000..30ae270ea1 --- /dev/null +++ b/app/javascript/flavours/glitch/actions/interactions_typed.ts @@ -0,0 +1,30 @@ +import { apiReblog, apiUnreblog } from 'flavours/glitch/api/interactions'; +import type { StatusVisibility } from 'flavours/glitch/models/status'; +import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; + +import { importFetchedStatus } from './importer'; + +export const reblog = createDataLoadingThunk( + 'status/reblog', + (statusId: string, visibility: StatusVisibility) => + apiReblog(statusId, visibility), + (data, { dispatch, discardLoadData }) => { + // The reblog API method returns a new status wrapped around the original. In this case we are only + // interested in how the original is modified, hence passing it skipping the wrapper + dispatch(importFetchedStatus(data.reblog)); + + // The payload is not used in any actions + return discardLoadData; + }, +); + +export const unreblog = createDataLoadingThunk( + 'status/unreblog', + (statusId: string) => apiUnreblog(statusId), + (data, { dispatch, discardLoadData }) => { + dispatch(importFetchedStatus(data)); + + // The payload is not used in any actions + return discardLoadData; + }, +); diff --git a/app/javascript/flavours/glitch/api.ts b/app/javascript/flavours/glitch/api.ts index 2ccf178f00..4e5ccef08c 100644 --- a/app/javascript/flavours/glitch/api.ts +++ b/app/javascript/flavours/glitch/api.ts @@ -1,4 +1,4 @@ -import type { AxiosResponse, RawAxiosRequestHeaders } from 'axios'; +import type { AxiosResponse, Method, RawAxiosRequestHeaders } from 'axios'; import axios from 'axios'; import LinkHeader from 'http-link-header'; @@ -58,3 +58,17 @@ export default function api(withAuthorization = true) { ], }); } + +export async function apiRequest( + method: Method, + url: string, + params?: unknown, +) { + const { data } = await api().request({ + method, + url, + params, + }); + + return data; +} diff --git a/app/javascript/flavours/glitch/api/accounts.ts b/app/javascript/flavours/glitch/api/accounts.ts new file mode 100644 index 0000000000..19abc849b7 --- /dev/null +++ b/app/javascript/flavours/glitch/api/accounts.ts @@ -0,0 +1,7 @@ +import { apiRequest } from 'flavours/glitch/api'; +import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships'; + +export const apiSubmitAccountNote = (id: string, value: string) => + apiRequest('post', `/api/v1/accounts/${id}/note`, { + comment: value, + }); diff --git a/app/javascript/flavours/glitch/api/interactions.ts b/app/javascript/flavours/glitch/api/interactions.ts new file mode 100644 index 0000000000..eaa83b2136 --- /dev/null +++ b/app/javascript/flavours/glitch/api/interactions.ts @@ -0,0 +1,10 @@ +import { apiRequest } from 'flavours/glitch/api'; +import type { Status, StatusVisibility } from 'flavours/glitch/models/status'; + +export const apiReblog = (statusId: string, visibility: StatusVisibility) => + apiRequest<{ reblog: Status }>('post', `v1/statuses/${statusId}/reblog`, { + visibility, + }); + +export const apiUnreblog = (statusId: string) => + apiRequest('post', `v1/statuses/${statusId}/unreblog`); diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index d304af5ec7..6ae800c037 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -115,9 +115,9 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ onModalReblog (status, privacy) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); } }, diff --git a/app/javascript/flavours/glitch/features/account/containers/account_note_container.js b/app/javascript/flavours/glitch/features/account/containers/account_note_container.js index d98a3996d0..2fd7d56735 100644 --- a/app/javascript/flavours/glitch/features/account/containers/account_note_container.js +++ b/app/javascript/flavours/glitch/features/account/containers/account_note_container.js @@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({ const mapDispatchToProps = (dispatch, { account }) => ({ onSave (value) { - dispatch(submitAccountNote({ id: account.get('id'), value})); + dispatch(submitAccountNote(account.get('id'), value)); }, }); diff --git a/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js b/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js index de5cb2b11e..570f468157 100644 --- a/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js +++ b/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js @@ -36,12 +36,12 @@ const mapDispatchToProps = dispatch => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx index 0b6b91fe91..bbcb6d46ba 100644 --- a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx +++ b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx @@ -125,7 +125,7 @@ class Footer extends ImmutablePureComponent { _performReblog = (status, privacy) => { const { dispatch } = this.props; - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }; handleReblogClick = e => { @@ -134,7 +134,7 @@ class Footer extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else if ((e && e.shiftKey) || !boostModal) { this._performReblog(status); } else { diff --git a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js index 7e8fe49b23..8fe0fc42e2 100644 --- a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js +++ b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js @@ -71,12 +71,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 2656f8afdd..943b48020a 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -346,9 +346,9 @@ class Status extends ImmutablePureComponent { const { dispatch } = this.props; if (status.get('reblogged')) { - dispatch(unreblog(status)); + dispatch(unreblog(status.id)); } else { - dispatch(reblog(status, privacy)); + dispatch(reblog(status.id, privacy)); } }; diff --git a/app/javascript/flavours/glitch/reducers/statuses.js b/app/javascript/flavours/glitch/reducers/statuses.js index 683fe848f7..1da1c9cf2f 100644 --- a/app/javascript/flavours/glitch/reducers/statuses.js +++ b/app/javascript/flavours/glitch/reducers/statuses.js @@ -3,10 +3,6 @@ import { Map as ImmutableMap, fromJS } from 'immutable'; import { STATUS_IMPORT, STATUSES_IMPORT } from '../actions/importer'; import { normalizeStatusTranslation } from '../actions/importer/normalizer'; import { - REBLOG_REQUEST, - REBLOG_FAIL, - UNREBLOG_REQUEST, - UNREBLOG_FAIL, FAVOURITE_REQUEST, FAVOURITE_FAIL, UNFAVOURITE_REQUEST, @@ -16,6 +12,10 @@ import { UNBOOKMARK_REQUEST, UNBOOKMARK_FAIL, } from '../actions/interactions'; +import { + reblog, + unreblog, +} from '../actions/interactions_typed'; import { STATUS_MUTE_SUCCESS, STATUS_UNMUTE_SUCCESS, @@ -65,6 +65,7 @@ const statusTranslateUndo = (state, id) => { const initialState = ImmutableMap(); +/** @type {import('@reduxjs/toolkit').Reducer} */ export default function statuses(state = initialState, action) { switch(action.type) { case STATUS_FETCH_REQUEST: @@ -91,14 +92,6 @@ export default function statuses(state = initialState, action) { return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'bookmarked'], false); case UNBOOKMARK_FAIL: return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'bookmarked'], true); - case REBLOG_REQUEST: - return state.setIn([action.status.get('id'), 'reblogged'], true); - case REBLOG_FAIL: - return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], false); - case UNREBLOG_REQUEST: - return state.setIn([action.status.get('id'), 'reblogged'], false); - case UNREBLOG_FAIL: - return state.get(action.status.get('id')) === undefined ? state : state.setIn([action.status.get('id'), 'reblogged'], true); case STATUS_MUTE_SUCCESS: return state.setIn([action.id, 'muted'], true); case STATUS_UNMUTE_SUCCESS: @@ -128,6 +121,15 @@ export default function statuses(state = initialState, action) { case STATUS_TRANSLATE_UNDO: return statusTranslateUndo(state, action.id); default: - return state; + if(reblog.pending.match(action)) + return state.setIn([action.meta.params.statusId, 'reblogged'], true); + else if(reblog.rejected.match(action)) + return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], false); + else if(unreblog.pending.match(action)) + return state.setIn([action.meta.params.statusId, 'reblogged'], false); + else if(unreblog.rejected.match(action)) + return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], true); + else + return state; } } diff --git a/app/javascript/flavours/glitch/store/typed_functions.ts b/app/javascript/flavours/glitch/store/typed_functions.ts index b66d7545c5..4b07a55610 100644 --- a/app/javascript/flavours/glitch/store/typed_functions.ts +++ b/app/javascript/flavours/glitch/store/typed_functions.ts @@ -2,6 +2,8 @@ import { createAsyncThunk } from '@reduxjs/toolkit'; // eslint-disable-next-line @typescript-eslint/no-restricted-imports import { useDispatch, useSelector } from 'react-redux'; +import type { BaseThunkAPI } from '@reduxjs/toolkit/dist/createAsyncThunk'; + import type { AppDispatch, RootState } from './store'; export const useAppDispatch = useDispatch.withTypes(); @@ -13,8 +15,192 @@ export interface AsyncThunkRejectValue { error?: unknown; } +interface AppMeta { + skipLoading?: boolean; +} + export const createAppAsyncThunk = createAsyncThunk.withTypes<{ state: RootState; dispatch: AppDispatch; rejectValue: AsyncThunkRejectValue; }>(); + +type AppThunkApi = Pick< + BaseThunkAPI< + RootState, + unknown, + AppDispatch, + AsyncThunkRejectValue, + AppMeta, + AppMeta + >, + 'getState' | 'dispatch' +>; + +interface AppThunkOptions { + skipLoading?: boolean; +} + +const createBaseAsyncThunk = createAsyncThunk.withTypes<{ + state: RootState; + dispatch: AppDispatch; + rejectValue: AsyncThunkRejectValue; + fulfilledMeta: AppMeta; + rejectedMeta: AppMeta; +}>(); + +export function createThunk( + name: string, + creator: (arg: Arg, api: AppThunkApi) => Returned | Promise, + options: AppThunkOptions = {}, +) { + return createBaseAsyncThunk( + name, + async ( + arg: Arg, + { getState, dispatch, fulfillWithValue, rejectWithValue }, + ) => { + try { + const result = await creator(arg, { dispatch, getState }); + + return fulfillWithValue(result, { + skipLoading: options.skipLoading, + }); + } catch (error) { + return rejectWithValue({ error }, { skipLoading: true }); + } + }, + { + getPendingMeta() { + if (options.skipLoading) return { skipLoading: true }; + return {}; + }, + }, + ); +} + +const discardLoadDataInPayload = Symbol('discardLoadDataInPayload'); +type DiscardLoadData = typeof discardLoadDataInPayload; + +type OnData = ( + data: LoadDataResult, + api: AppThunkApi & { + discardLoadData: DiscardLoadData; + }, +) => ReturnedData | DiscardLoadData | Promise; + +// Overload when there is no `onData` method, the payload is the `onData` result +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when the `onData` method returns discardLoadDataInPayload, then the payload is empty +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: + | AppThunkOptions + | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when the `onData` method returns nothing, then the mayload is the `onData` result +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +// Overload when there is an `onData` method returning something +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], + Returned, +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + thunkOptions?: AppThunkOptions, +): ReturnType>; + +/** + * This function creates a Redux Thunk that handles loading data asynchronously (usually from the API), dispatching `pending`, `fullfilled` and `rejected` actions. + * + * You can run a callback on the `onData` results to either dispatch side effects or modify the payload. + * + * It is a wrapper around RTK's [`createAsyncThunk`](https://redux-toolkit.js.org/api/createAsyncThunk) + * @param name Prefix for the actions types + * @param loadData Function that loads the data. It's arguments will become the thunk's arguments + * @param onDataOrThunkOptions + * Callback called on the results from `loadData`. + * + * First argument will be the return from `loadData`. + * + * Second argument is an object with: `dispatch`, `getState` and `discardLoadData`. + * It can return: + * - `undefined` (or no explicit return), meaning that the `onData` results will be the payload + * - `discardLoadData` to discard the `onData` results and return an empty payload + * - anything else, which will be the payload + * + * You can also omit this parameter and pass `thunkOptions` directly + * @param maybeThunkOptions + * Additional Mastodon specific options for the thunk. Currently supports: + * - `skipLoading` to avoid showing the loading bar when the request is in progress + * @returns The created thunk + */ +export function createDataLoadingThunk< + LoadDataResult, + Args extends readonly unknown[], + Returned, +>( + name: string, + loadData: (...args: Args) => Promise, + onDataOrThunkOptions?: AppThunkOptions | OnData, + maybeThunkOptions?: AppThunkOptions, +) { + let onData: OnData | undefined; + let thunkOptions: AppThunkOptions | undefined; + + if (typeof onDataOrThunkOptions === 'function') onData = onDataOrThunkOptions; + else if (typeof onDataOrThunkOptions === 'object') + thunkOptions = onDataOrThunkOptions; + + if (maybeThunkOptions) { + thunkOptions = maybeThunkOptions; + } + + return createThunk( + name, + async (arg, { getState, dispatch }) => { + const data = await loadData(...arg); + + if (!onData) return data as Returned; + + const result = await onData(data, { + dispatch, + getState, + discardLoadData: discardLoadDataInPayload, + }); + + // if there is no return in `onData`, we return the `onData` result + if (typeof result === 'undefined') return data as Returned; + // the user explicitely asked to discard the payload + else if (result === discardLoadDataInPayload) + return undefined as Returned; + else return result; + }, + thunkOptions, + ); +} From e32bfad88a76a1acd42e56c0ad2f83cdfe535aff Mon Sep 17 00:00:00 2001 From: Renaud Chaput Date: Thu, 23 May 2024 20:22:42 +0200 Subject: [PATCH 9/9] [Glitch] Fix `createDataLoadingThunk` and related actions Port b6fd14f0e2842eca269ef8962e3c5bd560a76357 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/actions/account_notes.ts | 3 ++- .../glitch/actions/interactions_typed.ts | 11 ++++++--- app/javascript/flavours/glitch/api.ts | 6 ++--- .../flavours/glitch/api/accounts.ts | 2 +- .../glitch/containers/status_container.js | 4 ++-- .../containers/account_note_container.js | 2 +- .../containers/notification_container.js | 4 ++-- .../picture_in_picture/components/footer.jsx | 4 ++-- .../containers/detailed_status_container.js | 4 ++-- .../flavours/glitch/features/status/index.jsx | 4 ++-- .../flavours/glitch/reducers/statuses.js | 8 +++---- .../flavours/glitch/store/typed_functions.ts | 24 +++++++++---------- 12 files changed, 41 insertions(+), 35 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/account_notes.ts b/app/javascript/flavours/glitch/actions/account_notes.ts index 9b05ae06c2..a71b342b06 100644 --- a/app/javascript/flavours/glitch/actions/account_notes.ts +++ b/app/javascript/flavours/glitch/actions/account_notes.ts @@ -3,7 +3,8 @@ import { createDataLoadingThunk } from 'flavours/glitch/store/typed_functions'; export const submitAccountNote = createDataLoadingThunk( 'account_note/submit', - (accountId: string, note: string) => apiSubmitAccountNote(accountId, note), + ({ accountId, note }: { accountId: string; note: string }) => + apiSubmitAccountNote(accountId, note), (relationship) => ({ relationship }), { skipLoading: true }, ); diff --git a/app/javascript/flavours/glitch/actions/interactions_typed.ts b/app/javascript/flavours/glitch/actions/interactions_typed.ts index 30ae270ea1..075fc242e4 100644 --- a/app/javascript/flavours/glitch/actions/interactions_typed.ts +++ b/app/javascript/flavours/glitch/actions/interactions_typed.ts @@ -6,8 +6,13 @@ import { importFetchedStatus } from './importer'; export const reblog = createDataLoadingThunk( 'status/reblog', - (statusId: string, visibility: StatusVisibility) => - apiReblog(statusId, visibility), + ({ + statusId, + visibility, + }: { + statusId: string; + visibility: StatusVisibility; + }) => apiReblog(statusId, visibility), (data, { dispatch, discardLoadData }) => { // The reblog API method returns a new status wrapped around the original. In this case we are only // interested in how the original is modified, hence passing it skipping the wrapper @@ -20,7 +25,7 @@ export const reblog = createDataLoadingThunk( export const unreblog = createDataLoadingThunk( 'status/unreblog', - (statusId: string) => apiUnreblog(statusId), + ({ statusId }: { statusId: string }) => apiUnreblog(statusId), (data, { dispatch, discardLoadData }) => { dispatch(importFetchedStatus(data)); diff --git a/app/javascript/flavours/glitch/api.ts b/app/javascript/flavours/glitch/api.ts index 4e5ccef08c..e133125a29 100644 --- a/app/javascript/flavours/glitch/api.ts +++ b/app/javascript/flavours/glitch/api.ts @@ -62,12 +62,12 @@ export default function api(withAuthorization = true) { export async function apiRequest( method: Method, url: string, - params?: unknown, + params?: Record, ) { const { data } = await api().request({ method, - url, - params, + url: '/api/' + url, + data: params, }); return data; diff --git a/app/javascript/flavours/glitch/api/accounts.ts b/app/javascript/flavours/glitch/api/accounts.ts index 19abc849b7..346b3bc38c 100644 --- a/app/javascript/flavours/glitch/api/accounts.ts +++ b/app/javascript/flavours/glitch/api/accounts.ts @@ -2,6 +2,6 @@ import { apiRequest } from 'flavours/glitch/api'; import type { ApiRelationshipJSON } from 'flavours/glitch/api_types/relationships'; export const apiSubmitAccountNote = (id: string, value: string) => - apiRequest('post', `/api/v1/accounts/${id}/note`, { + apiRequest('post', `v1/accounts/${id}/note`, { comment: value, }); diff --git a/app/javascript/flavours/glitch/containers/status_container.js b/app/javascript/flavours/glitch/containers/status_container.js index 6ae800c037..1430a0c845 100644 --- a/app/javascript/flavours/glitch/containers/status_container.js +++ b/app/javascript/flavours/glitch/containers/status_container.js @@ -115,9 +115,9 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ onModalReblog (status, privacy) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); } }, diff --git a/app/javascript/flavours/glitch/features/account/containers/account_note_container.js b/app/javascript/flavours/glitch/features/account/containers/account_note_container.js index 2fd7d56735..135e772f3e 100644 --- a/app/javascript/flavours/glitch/features/account/containers/account_note_container.js +++ b/app/javascript/flavours/glitch/features/account/containers/account_note_container.js @@ -11,7 +11,7 @@ const mapStateToProps = (state, { account }) => ({ const mapDispatchToProps = (dispatch, { account }) => ({ onSave (value) { - dispatch(submitAccountNote(account.get('id'), value)); + dispatch(submitAccountNote({ accountId: account.get('id'), note: value })); }, }); diff --git a/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js b/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js index 570f468157..338d27d8d6 100644 --- a/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js +++ b/app/javascript/flavours/glitch/features/notifications/containers/notification_container.js @@ -36,12 +36,12 @@ const mapDispatchToProps = dispatch => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx index bbcb6d46ba..13ad86f801 100644 --- a/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx +++ b/app/javascript/flavours/glitch/features/picture_in_picture/components/footer.jsx @@ -125,7 +125,7 @@ class Footer extends ImmutablePureComponent { _performReblog = (status, privacy) => { const { dispatch } = this.props; - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }; handleReblogClick = e => { @@ -134,7 +134,7 @@ class Footer extends ImmutablePureComponent { if (signedIn) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else if ((e && e.shiftKey) || !boostModal) { this._performReblog(status); } else { diff --git a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js index 8fe0fc42e2..7cb9735cfe 100644 --- a/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js +++ b/app/javascript/flavours/glitch/features/status/containers/detailed_status_container.js @@ -71,12 +71,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({ }, onModalReblog (status, privacy) { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); }, onReblog (status, e) { if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { if (e.shiftKey || !boostModal) { this.onModalReblog(status); diff --git a/app/javascript/flavours/glitch/features/status/index.jsx b/app/javascript/flavours/glitch/features/status/index.jsx index 943b48020a..00639a667e 100644 --- a/app/javascript/flavours/glitch/features/status/index.jsx +++ b/app/javascript/flavours/glitch/features/status/index.jsx @@ -346,9 +346,9 @@ class Status extends ImmutablePureComponent { const { dispatch } = this.props; if (status.get('reblogged')) { - dispatch(unreblog(status.id)); + dispatch(unreblog({ statusId: status.get('id') })); } else { - dispatch(reblog(status.id, privacy)); + dispatch(reblog({ statusId: status.get('id'), visibility: privacy })); } }; diff --git a/app/javascript/flavours/glitch/reducers/statuses.js b/app/javascript/flavours/glitch/reducers/statuses.js index 1da1c9cf2f..ca766f73a3 100644 --- a/app/javascript/flavours/glitch/reducers/statuses.js +++ b/app/javascript/flavours/glitch/reducers/statuses.js @@ -122,13 +122,13 @@ export default function statuses(state = initialState, action) { return statusTranslateUndo(state, action.id); default: if(reblog.pending.match(action)) - return state.setIn([action.meta.params.statusId, 'reblogged'], true); + return state.setIn([action.meta.arg.statusId, 'reblogged'], true); else if(reblog.rejected.match(action)) - return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], false); + return state.get(action.meta.arg.statusId) === undefined ? state : state.setIn([action.meta.arg.statusId, 'reblogged'], false); else if(unreblog.pending.match(action)) - return state.setIn([action.meta.params.statusId, 'reblogged'], false); + return state.setIn([action.meta.arg.statusId, 'reblogged'], false); else if(unreblog.rejected.match(action)) - return state.get(action.meta.params.statusId) === undefined ? state : state.setIn([action.meta.params.statusId, 'reblogged'], true); + return state.get(action.meta.arg.statusId) === undefined ? state : state.setIn([action.meta.arg.statusId, 'reblogged'], true); else return state; } diff --git a/app/javascript/flavours/glitch/store/typed_functions.ts b/app/javascript/flavours/glitch/store/typed_functions.ts index 4b07a55610..0392f373c0 100644 --- a/app/javascript/flavours/glitch/store/typed_functions.ts +++ b/app/javascript/flavours/glitch/store/typed_functions.ts @@ -92,20 +92,20 @@ type OnData = ( // Overload when there is no `onData` method, the payload is the `onData` result export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, thunkOptions?: AppThunkOptions, ): ReturnType>; // Overload when the `onData` method returns discardLoadDataInPayload, then the payload is empty export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: | AppThunkOptions | OnData, @@ -115,10 +115,10 @@ export function createDataLoadingThunk< // Overload when the `onData` method returns nothing, then the mayload is the `onData` result export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, thunkOptions?: AppThunkOptions, ): ReturnType>; @@ -126,11 +126,11 @@ export function createDataLoadingThunk< // Overload when there is an `onData` method returning something export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, Returned, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, thunkOptions?: AppThunkOptions, ): ReturnType>; @@ -142,7 +142,7 @@ export function createDataLoadingThunk< * * It is a wrapper around RTK's [`createAsyncThunk`](https://redux-toolkit.js.org/api/createAsyncThunk) * @param name Prefix for the actions types - * @param loadData Function that loads the data. It's arguments will become the thunk's arguments + * @param loadData Function that loads the data. It's (object) argument will become the thunk's argument * @param onDataOrThunkOptions * Callback called on the results from `loadData`. * @@ -162,11 +162,11 @@ export function createDataLoadingThunk< */ export function createDataLoadingThunk< LoadDataResult, - Args extends readonly unknown[], + Args extends Record, Returned, >( name: string, - loadData: (...args: Args) => Promise, + loadData: (args: Args) => Promise, onDataOrThunkOptions?: AppThunkOptions | OnData, maybeThunkOptions?: AppThunkOptions, ) { @@ -184,7 +184,7 @@ export function createDataLoadingThunk< return createThunk( name, async (arg, { getState, dispatch }) => { - const data = await loadData(...arg); + const data = await loadData(arg); if (!onData) return data as Returned;