-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into super-to-pdf
- Loading branch information
Showing
24 changed files
with
166 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.1.396](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/clipper | ||
|
||
## [1.1.395](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21) | ||
|
||
**Note:** Version bump only for package @standardnotes/clipper | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [3.108.334](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/desktop | ||
|
||
## [3.108.333](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21) | ||
|
||
**Note:** Version bump only for package @standardnotes/desktop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [3.58.55](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/mobile | ||
|
||
## [3.58.54](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21) | ||
|
||
**Note:** Version bump only for package @standardnotes/mobile | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.4.690](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/releases | ||
|
||
## [1.4.689](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21) | ||
|
||
**Note:** Version bump only for package @standardnotes/releases | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.68.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/services | ||
|
||
# [1.68.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-20) | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/services/src/Domain/Sync/SyncBackoffService.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { AnyItemInterface } from '@standardnotes/models' | ||
import { SyncBackoffService } from './SyncBackoffService' | ||
|
||
describe('SyncBackoffService', () => { | ||
const createService = () => new SyncBackoffService() | ||
|
||
it('should not be in backoff if no backoff was set', () => { | ||
const service = createService() | ||
|
||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(false) | ||
}) | ||
|
||
it('should be in backoff if backoff was set', () => { | ||
const service = createService() | ||
|
||
service.backoffItem({ uuid: '123' } as jest.Mocked<AnyItemInterface>) | ||
|
||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(true) | ||
}) | ||
|
||
it('should not be in backoff if backoff expired', () => { | ||
const service = createService() | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_000_000) | ||
|
||
service.backoffItem({ uuid: '123' } as jest.Mocked<AnyItemInterface>) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(2_000_000) | ||
|
||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(false) | ||
}) | ||
|
||
it('should double backoff penalty on each backoff', () => { | ||
const service = createService() | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_000_000) | ||
|
||
service.backoffItem({ uuid: '123' } as jest.Mocked<AnyItemInterface>) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_000_000) | ||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(true) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_000_000) | ||
service.backoffItem({ uuid: '123' } as jest.Mocked<AnyItemInterface>) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_001_000) | ||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(true) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_000_000) | ||
service.backoffItem({ uuid: '123' } as jest.Mocked<AnyItemInterface>) | ||
|
||
jest.spyOn(Date, 'now').mockReturnValueOnce(1_003_000) | ||
expect(service.isItemInBackoff({ uuid: '123' } as jest.Mocked<AnyItemInterface>)).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { AnyItemInterface } from '@standardnotes/models' | ||
import { SyncBackoffServiceInterface } from './SyncBackoffServiceInterface' | ||
|
||
export class SyncBackoffService implements SyncBackoffServiceInterface { | ||
private backoffPenalties: Map<string, number> | ||
private backoffStartTimestamps: Map<string, number> | ||
|
||
constructor() { | ||
this.backoffPenalties = new Map<string, number>() | ||
this.backoffStartTimestamps = new Map<string, number>() | ||
} | ||
|
||
isItemInBackoff(item: AnyItemInterface): boolean { | ||
const backoffStartingTimestamp = this.backoffStartTimestamps.get(item.uuid) | ||
if (!backoffStartingTimestamp) { | ||
return false | ||
} | ||
|
||
const backoffPenalty = this.backoffPenalties.get(item.uuid) | ||
if (!backoffPenalty) { | ||
return false | ||
} | ||
|
||
const backoffEndTimestamp = backoffStartingTimestamp + backoffPenalty | ||
|
||
return backoffEndTimestamp > Date.now() | ||
} | ||
|
||
backoffItem(item: AnyItemInterface): void { | ||
const backoffPenalty = this.backoffPenalties.get(item.uuid) || 0 | ||
|
||
const newBackoffPenalty = backoffPenalty === 0 ? 1_000 : backoffPenalty * 2 | ||
|
||
this.backoffPenalties.set(item.uuid, newBackoffPenalty) | ||
this.backoffStartTimestamps.set(item.uuid, Date.now()) | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/services/src/Domain/Sync/SyncBackoffServiceInterface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { AnyItemInterface } from '@standardnotes/models' | ||
|
||
export interface SyncBackoffServiceInterface { | ||
isItemInBackoff(item: AnyItemInterface): boolean | ||
backoffItem(item: AnyItemInterface): void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [2.205.1](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/snjs | ||
|
||
# [2.205.0](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-20) | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [1.35.21](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/ui-services | ||
|
||
## [1.35.20](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-20) | ||
|
||
**Note:** Version bump only for package @standardnotes/ui-services | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,10 @@ | |
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
|
||
## [3.185.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23) | ||
|
||
**Note:** Version bump only for package @standardnotes/web | ||
|
||
## [3.185.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21) | ||
|
||
**Note:** Version bump only for package @standardnotes/web | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
{ | ||
"versions": [ | ||
{ | ||
"version": "3.185.4", | ||
"title": "[3.185.4](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-23)", | ||
"date": null, | ||
"body": "**Note:** Version bump only for package @standardnotes/web", | ||
"parsed": { | ||
"_": [ | ||
"Note: Version bump only for package @standardnotes/web" | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "3.185.3", | ||
"title": "[3.185.3](https://github.com/standardnotes/app/compare/@standardnotes/[email protected]...@standardnotes/[email protected]) (2024-01-21)", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters