Skip to content

Commit

Permalink
fixup! fix(capabilities): make a deep comparison
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Feb 11, 2025
1 parent 5245c45 commit 5dce66c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/services/CapabilitiesManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { cloneDeep, isEqual } from 'lodash'

import { getCapabilities as _getCapabilities } from '@nextcloud/capabilities'

import { getRemoteCapabilities } from './federationService.ts'
Expand Down Expand Up @@ -189,7 +187,7 @@ function checkRemoteCapabilitiesHasChanged(newObject: Capabilities['spreed'], ol
* @param object remote capabilities object
*/
function getStrippedCapabilities(object: Capabilities['spreed']): { config: Partial<Config>, features: string[] } {
const config = cloneDeep(object.config)
const config = structuredClone(object.config)

for (const key1 of Object.keys(object['config-local']) as Array<keyof Config>) {
const keys2 = object['config-local'][key1]
Expand All @@ -206,7 +204,7 @@ function checkRemoteCapabilitiesHasChanged(newObject: Capabilities['spreed'], ol
return { config, features }
}

return !isEqual(getStrippedCapabilities(newObject), getStrippedCapabilities(oldObject))
return JSON.stringify(getStrippedCapabilities(newObject)) !== JSON.stringify(getStrippedCapabilities(oldObject))
}

/**
Expand Down
2 changes: 2 additions & 0 deletions src/test-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ global.ResizeObserver = jest.fn(() => ({
disconnect: jest.fn(),
}))

global.structuredClone = jest.fn((val) => JSON.parse(JSON.stringify(val)))

// Work around missing "URL.createObjectURL" (which is used in the code but not
// relevant for the tests) in jsdom: https://github.com/jsdom/jsdom/issues/1721
window.URL.createObjectURL = jest.fn()
Expand Down

0 comments on commit 5dce66c

Please sign in to comment.