Reducers: Preserve translation if an existing status already has it
This commit is contained in:
parent
4fae24cf20
commit
dc0b68f995
1 changed files with 11 additions and 0 deletions
|
@ -129,6 +129,16 @@ const isQuote = (status: StatusRecord) => {
|
||||||
return Boolean(status.pleroma.get('quote_url'));
|
return Boolean(status.pleroma.get('quote_url'));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Preserve translation if an existing status already has it
|
||||||
|
const fixTranslation = (status: StatusRecord, oldStatus?: StatusRecord): StatusRecord => {
|
||||||
|
if (oldStatus?.translation && !status.translation) {
|
||||||
|
return status
|
||||||
|
.set('translation', oldStatus.translation);
|
||||||
|
} else {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Preserve quote if an existing status already has it
|
// Preserve quote if an existing status already has it
|
||||||
const fixQuote = (status: StatusRecord, oldStatus?: StatusRecord): StatusRecord => {
|
const fixQuote = (status: StatusRecord, oldStatus?: StatusRecord): StatusRecord => {
|
||||||
if (oldStatus && !status.quote && isQuote(status)) {
|
if (oldStatus && !status.quote && isQuote(status)) {
|
||||||
|
@ -144,6 +154,7 @@ const fixStatus = (state: State, status: APIEntity, expandSpoilers: boolean): Re
|
||||||
const oldStatus = state.get(status.id);
|
const oldStatus = state.get(status.id);
|
||||||
|
|
||||||
return normalizeStatus(status).withMutations(status => {
|
return normalizeStatus(status).withMutations(status => {
|
||||||
|
fixTranslation(status, oldStatus);
|
||||||
fixQuote(status, oldStatus);
|
fixQuote(status, oldStatus);
|
||||||
calculateStatus(status, oldStatus, expandSpoilers);
|
calculateStatus(status, oldStatus, expandSpoilers);
|
||||||
minifyStatus(status);
|
minifyStatus(status);
|
||||||
|
|
Loading…
Reference in a new issue