Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: bump versions #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions lib/app/sync/conflictSolvers.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import { Aggregate, AnyIdentity } from '@akdasa-studios/framework'
import { ConflictSolver } from '@akdasa-studios/framework-sync'
import { AnyIdentity } from '@akdasa-studios/framework'
import { SyncAggregate, SyncConflictSolver } from '@akdasa-studios/framework-sync'
import { Decks, InboxCard, ReviewCard, VerseStatus } from '@lib/models'

// Stryker disable all

export class InboxCardConflictSolver implements ConflictSolver<InboxCard> {
solve(object1: InboxCard, object2: InboxCard): Aggregate<AnyIdentity> {
export class InboxCardConflictSolver implements SyncConflictSolver<InboxCard> {
solve(object1: InboxCard, object2: InboxCard): SyncAggregate<AnyIdentity> {
return object1.memorizedAt ? object1 : object2
}
}

export class ReviewCardConflictSolver implements ConflictSolver<ReviewCard> {
solve(object1: ReviewCard, object2: ReviewCard): Aggregate<AnyIdentity> {
export class ReviewCardConflictSolver implements SyncConflictSolver<ReviewCard> {
solve(object1: ReviewCard, object2: ReviewCard): SyncAggregate<AnyIdentity> {
return object1.lapses > object2.lapses ? object1 : object2
}
}

export class VerseStatusConflictSolver implements ConflictSolver<VerseStatus> {
solve(object1: VerseStatus, object2: VerseStatus): Aggregate<AnyIdentity> {
export class VerseStatusConflictSolver implements SyncConflictSolver<VerseStatus> {
solve(object1: VerseStatus, object2: VerseStatus): SyncAggregate<AnyIdentity> {
if (object1.inDeck !== object2.inDeck) {
const object1Progress = Object.keys(Decks).indexOf(object1.inDeck)
const object2Progress = Object.keys(Decks).indexOf(object2.inDeck)
Expand Down
9 changes: 7 additions & 2 deletions lib/models/cards/Card.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { UuidIdentity, Aggregate } from '@akdasa-studios/framework'
import { HasVersion } from '@akdasa-studios/framework-sync'
import { Syncable } from '@akdasa-studios/framework-sync'
import { VerseId } from '@lib/models/verse'


export class CardId extends UuidIdentity<'CardId'> {}

export abstract class Card extends Aggregate<CardId> implements HasVersion {
export abstract class Card extends Aggregate<CardId> implements Syncable {
constructor(
id: CardId,
public readonly verseId: VerseId
Expand All @@ -17,4 +17,9 @@ export abstract class Card extends Aggregate<CardId> implements HasVersion {
* Version
*/
version: string

/**
* Synced at
*/
syncedAt: number
}
5 changes: 3 additions & 2 deletions lib/models/verse/VerseStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HasVersion } from '@akdasa-studios/framework-sync'
import { Syncable } from '@akdasa-studios/framework-sync'
import { Aggregate, UuidIdentity } from '@akdasa-studios/framework'
import { VerseId } from './Verse'

Expand All @@ -18,10 +18,11 @@ export enum Decks {
/**
* Verse status
*/
export class VerseStatus extends Aggregate<VerseStatusId> implements HasVersion {
export class VerseStatus extends Aggregate<VerseStatusId> implements Syncable {
private readonly _verseId: VerseId
private _deck: Decks = Decks.None
public version: string
public syncedAt: number

constructor(
verseId: VerseId,
Expand Down
Loading