Skip to content

Refactor: Extract SyncResolverApi interface and SyncDeviceManager class #3942

@guiyanakuang

Description

@guiyanakuang

Background

SyncResolver mixes two concerns:

  1. Complex connection resolution logic (telnet, heartbeat, token verification)
  2. Simple device management delegates (DAO calls, API notifications)

It also has no interface, making it harder to mock and violating dependency inversion.

Changes

Extract SyncResolverApi interface

  • New interface with a single emitEvent(event: SyncEvent) method
  • SyncResolver implements the interface
  • GeneralSyncManager and Koin bindings depend on the interface

Extract SyncDeviceManager class

Move 7 device management methods into a focused class with only 3 dependencies:

  • updateAllowSend, updateAllowReceive, updateNoteName
  • showToken, notifyExit, markExit, removeDevice

Split tests

  • Move 11 device management tests from SyncResolverTest to SyncDeviceManagerTest
  • SyncDeviceManagerTest mocks only 3 deps instead of 10+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions