Fix integration (#1275)
* Fix integration - Don't use sourceCode as "temporary" value as it's being used as legit value(consider that we delete it after it's non longer needed). - Wrap the metadata into a `try {}` as some styles doesn't have any metadata. * Typos adios magios and bonjour gutentag
This commit is contained in:
parent
44b08dc089
commit
58fc531515
|
@ -378,12 +378,18 @@ const styleMan = (() => {
|
||||||
for (const {style: someStyle} of dataMap.values()) {
|
for (const {style: someStyle} of dataMap.values()) {
|
||||||
if (someStyle._id === style._id) {
|
if (someStyle._id === style._id) {
|
||||||
someStyle._isUswLinked = true;
|
someStyle._isUswLinked = true;
|
||||||
someStyle.sourceCode = style.sourceCode;
|
someStyle.originalValue = style.sourceCode;
|
||||||
const {metadata} = await API.worker.parseUsercssMeta(style.sourceCode);
|
let metadata = {};
|
||||||
|
try {
|
||||||
|
const {metadata: tmpMetadata} = await API.worker.parseUsercssMeta(style.sourceCode);
|
||||||
|
metadata = tmpMetadata;
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
someStyle.metadata = metadata;
|
someStyle.metadata = metadata;
|
||||||
} else {
|
} else {
|
||||||
delete someStyle._isUswLinked;
|
delete someStyle._isUswLinked;
|
||||||
delete someStyle.sourceCode;
|
delete someStyle.originalValue;
|
||||||
delete someStyle.metadata;
|
delete someStyle.metadata;
|
||||||
}
|
}
|
||||||
handleSave(await saveStyle(someStyle), null, null, false);
|
handleSave(await saveStyle(someStyle), null, null, false);
|
||||||
|
@ -393,7 +399,7 @@ const styleMan = (() => {
|
||||||
};
|
};
|
||||||
|
|
||||||
delete style._isUswLinked;
|
delete style._isUswLinked;
|
||||||
delete style.sourceCode;
|
delete style.originalValue;
|
||||||
delete style.metadata;
|
delete style.metadata;
|
||||||
for (const [k, v] of Object.entries(await retrieveStyleInformation(style._usw.token))) {
|
for (const [k, v] of Object.entries(await retrieveStyleInformation(style._usw.token))) {
|
||||||
style._usw[k] = v;
|
style._usw[k] = v;
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
if (location.pathname === '/api/oauth/style/new') {
|
if (location.pathname === '/api/oauth/style/new') {
|
||||||
API.styles.find({_isUswLinked: true}).then(style => {
|
API.styles.find({_isUswLinked: true}).then(style => {
|
||||||
|
style.sourceCode = style.originalValue;
|
||||||
sendPostMessage({type: 'usw-fill-new-style', data: style});
|
sendPostMessage({type: 'usw-fill-new-style', data: style});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user