mirror of
https://github.com/mue/mue.git
synced 2026-07-11 18:31:47 +02:00
fix: update french translation, fix language bug and use abort controller on more tabs
Co-authored-by: Alex Sparkes <turbomarshmello@gmail.com>
This commit is contained in:
@@ -36,6 +36,7 @@ export default class Marketplace extends React.PureComponent {
|
||||
install: <button className='addToMue' onClick={() => this.manage('install')}>{window.language.modals.main.marketplace.product.buttons.addtomue}</button>
|
||||
};
|
||||
this.language = window.language.modals.main.marketplace;
|
||||
this.controller = new AbortController();
|
||||
}
|
||||
|
||||
async toggle(type, data) {
|
||||
@@ -43,9 +44,15 @@ export default class Marketplace extends React.PureComponent {
|
||||
let info;
|
||||
// get item info
|
||||
try {
|
||||
info = await (await fetch(`${window.constants.MARKETPLACE_URL}/item/${this.props.type}/${data}`)).json();
|
||||
info = await (await fetch(`${window.constants.MARKETPLACE_URL}/item/${this.props.type}/${data}`, { signal: this.controller.signal })).json();
|
||||
} catch (e) {
|
||||
return toast(window.language.toasts.error);
|
||||
if (this.controller.signal.aborted === false) {
|
||||
return toast(window.language.toasts.error);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if already installed
|
||||
@@ -85,8 +92,12 @@ export default class Marketplace extends React.PureComponent {
|
||||
}
|
||||
|
||||
async getItems() {
|
||||
const { data } = await (await fetch(window.constants.MARKETPLACE_URL + '/all')).json();
|
||||
const featured = await (await fetch(window.constants.MARKETPLACE_URL + '/featured')).json();
|
||||
const { data } = await (await fetch(window.constants.MARKETPLACE_URL + '/all', { signal: this.controller.signal })).json();
|
||||
const featured = await (await fetch(window.constants.MARKETPLACE_URL + '/featured', { signal: this.controller.signal })).json();
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
items: data[this.props.type],
|
||||
@@ -116,6 +127,11 @@ export default class Marketplace extends React.PureComponent {
|
||||
this.getItems();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
// stop making requests
|
||||
this.controller.abort();
|
||||
}
|
||||
|
||||
render() {
|
||||
const errorMessage = (msg) => {
|
||||
return (
|
||||
|
||||
@@ -41,6 +41,10 @@ export default class About extends React.PureComponent {
|
||||
});
|
||||
}
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newVersion = versionData[0].tag_name;
|
||||
|
||||
let updateMsg = this.language.version.no_update;
|
||||
@@ -48,9 +52,6 @@ export default class About extends React.PureComponent {
|
||||
updateMsg = `${this.language.version.update_available}: ${newVersion}`;
|
||||
}
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
contributors: contributors.filter((contributor) => !contributor.login.includes('bot')),
|
||||
|
||||
@@ -9,10 +9,15 @@ export default class Changelog extends React.PureComponent {
|
||||
title: null
|
||||
};
|
||||
this.language = window.language.modals.update;
|
||||
this.controller = new AbortController();
|
||||
}
|
||||
|
||||
async getUpdate() {
|
||||
const data = await (await fetch(window.constants.BLOG_POST + '/index.json')).json();
|
||||
const data = await (await fetch(window.constants.BLOG_POST + '/index.json', { signal: this.controller.signal })).json();
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
title: data.title,
|
||||
@@ -21,15 +26,20 @@ export default class Changelog extends React.PureComponent {
|
||||
author: 'By ' + data.authors.join(', '),
|
||||
html: data.html
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
componentDidMount() {
|
||||
if (localStorage.getItem('offlineMode') === 'true') {
|
||||
return;
|
||||
}
|
||||
|
||||
this.getUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
// stop making requests
|
||||
this.controller.abort();
|
||||
}
|
||||
|
||||
render() {
|
||||
const errorMessage = (msg) => {
|
||||
|
||||
@@ -13,10 +13,15 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
value: 'loading'
|
||||
}]
|
||||
};
|
||||
this.controller = new AbortController();
|
||||
}
|
||||
|
||||
async getQuoteLanguages() {
|
||||
const data = await (await fetch(window.constants.API_URL + '/quotes/languages')).json();
|
||||
const data = await (await fetch(window.constants.API_URL + '/quotes/languages', { signal: this.controller.signal })).json();
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
let array = [];
|
||||
data.forEach(item => {
|
||||
@@ -35,6 +40,11 @@ export default class BackgroundSettings extends React.PureComponent {
|
||||
this.getQuoteLanguages();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
// stop making requests
|
||||
this.controller.abort();
|
||||
}
|
||||
|
||||
render() {
|
||||
const language = window.language.modals.main.settings.sections.language;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user