mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #9020 from overleaf/bg-decaff-guard
decaff cleanup of __guard__ calls GitOrigin-RevId: 0d61e4d44a2fda19285674040ba92e500deae78d
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS101: Remove unnecessary use of Array.from
|
||||
* DS103: Rewrite code to no longer use __guard__
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
@@ -93,12 +92,7 @@ module.exports = UpdateCompressor = {
|
||||
},
|
||||
|
||||
compressRawUpdates(lastPreviousUpdate, rawUpdates) {
|
||||
if (
|
||||
__guard__(
|
||||
lastPreviousUpdate != null ? lastPreviousUpdate.op : undefined,
|
||||
x => x.length
|
||||
) > 1
|
||||
) {
|
||||
if (lastPreviousUpdate?.op?.length > 1) {
|
||||
// if the last previous update was an array op, don't compress onto it.
|
||||
// The avoids cases where array length changes but version number doesn't
|
||||
return [lastPreviousUpdate].concat(
|
||||
@@ -331,9 +325,3 @@ module.exports = UpdateCompressor = {
|
||||
return ops
|
||||
},
|
||||
}
|
||||
|
||||
function __guard__(value, transform) {
|
||||
return typeof value !== 'undefined' && value !== null
|
||||
? transform(value)
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* DS103: Rewrite code to no longer use __guard__
|
||||
* DS207: Consider shorter variations of null checks
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
@@ -37,12 +36,7 @@ module.exports = UpdateTrimmer = {
|
||||
return callback(error)
|
||||
}
|
||||
logger.debug({ project_id, details }, 'got details')
|
||||
if (
|
||||
__guard__(
|
||||
details != null ? details.features : undefined,
|
||||
x => x.versioning
|
||||
)
|
||||
) {
|
||||
if (details?.features?.versioning) {
|
||||
return MongoManager.setProjectMetaData(
|
||||
project_id,
|
||||
{ preserveHistory: true },
|
||||
@@ -71,9 +65,3 @@ module.exports = UpdateTrimmer = {
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
function __guard__(value, transform) {
|
||||
return typeof value !== 'undefined' && value !== null
|
||||
? transform(value)
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -99,12 +99,7 @@ module.exports = UpdatesManager = {
|
||||
}
|
||||
|
||||
if (rawUpdates[0] != null && rawUpdates[0].v !== lastVersion + 1) {
|
||||
const ts = __guard__(
|
||||
lastCompressedUpdate != null
|
||||
? lastCompressedUpdate.meta
|
||||
: undefined,
|
||||
x1 => x1.end_ts
|
||||
)
|
||||
const ts = lastCompressedUpdate?.meta?.end_ts
|
||||
const last_timestamp = ts != null ? new Date(ts) : 'unknown time'
|
||||
error = new Error(
|
||||
`Tried to apply raw op at version ${rawUpdates[0].v} to last compressed update with version ${lastVersion} from ${last_timestamp}`
|
||||
|
||||
Reference in New Issue
Block a user