Skip to content

Commit

Permalink
Having a rethink, going to branch and try something else.
Browse files Browse the repository at this point in the history
  • Loading branch information
davemackintosh committed Aug 2, 2024
1 parent 6ee8110 commit 57da05c
Show file tree
Hide file tree
Showing 7 changed files with 468 additions and 450 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
"format": "prettier --write ."
},
"devDependencies": {
"@eslint/js": "^9.6.0",
"@eslint/js": "^9.8.0",
"@sveltejs/adapter-auto": "^3.2.2",
"@sveltejs/kit": "^2.5.18",
"@sveltejs/kit": "^2.5.19",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@types/eslint": "^8.56.10",
"eslint": "^9.6.0",
"@types/eslint": "^9.6.0",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-svelte": "^2.41.0",
"globals": "^15.7.0",
"prettier": "^3.3.2",
"prettier-plugin-svelte": "^3.2.5",
"eslint-plugin-svelte": "^2.43.0",
"globals": "^15.9.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"svelte": "^4.2.18",
"svelte-check": "^3.8.4",
"svelte-check": "^3.8.5",
"tslib": "^2.6.3",
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0",
"vite": "^5.3.2"
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.0",
"vite": "^5.3.5"
},
"type": "module",
"packageManager": "yarn@4.3.0",
"dependencies": {
"rxdb": "^15.25.0",
"rxdb": "^15.30.0",
"rxjs": "^7.8.1",
"svelte-awesome-color-picker": "^3.1.0",
"svelte-awesome-color-picker": "^3.1.2",
"ts-pattern": "^5.2.0"
}
}
36 changes: 15 additions & 21 deletions src/lib/cqrs/views/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
SetLayerNameEvent,
type ProjectEvents,
} from "$lib/types/commands-events"
import type { ColorPalettes } from "$lib/rxdb/collections/color-palette"
import type { ColorPalette } from "$lib/rxdb/collections/color-palette"
import type { StaticMethods } from "$lib/rxdb/collection-interfaces"

interface ILayer {
Expand All @@ -34,7 +34,7 @@ class Layer {
}
}

static fromDatabase(instance: ILayer): Layer {
static decode(instance: ILayer): Layer {
return new Layer(instance.id, instance.name)
}

Expand All @@ -48,33 +48,27 @@ interface IProjectView {
name?: string | null
layers: ILayer[]
members: string[]
colorPalettes: ColorPalettes
colorPalettes: ColorPalette[]
}

class ProjectView
implements IProjectView, View {
id: string
name: string
id!: string
name!: string
layers: Layer[] = []
members: string[] = []
colorPalettes: ColorPalettes = []
colorPalettes: ColorPalette[] = []

constructor(name: string, id: string, layers: Layer[] = [], members: string[] = [], colorPalettes: ColorPalettes) {
this.id = id
this.name = name
this.layers = layers
this.members = members
this.colorPalettes = colorPalettes
}
static decode(persistable: RxDocument<IProjectView>): ProjectView {
const view = new ProjectView()

view.id = persistable.get("id")
view.name = persistable.get("name")
view.layers = persistable.get("layers").map((layer: ILayer) => Layer.decode(layer))
view.members = persistable.get("members")
view.colorPalettes = persistable.get("colorPalettes")

static fromDatabase(persistable: RxDocument<IProjectView>): ProjectView {
return new ProjectView(
persistable.get("name"),
persistable.get("id"),
persistable.get("layers").map((layer: ILayer) => Layer.fromDatabase(layer)),
persistable.get("members"),
persistable.get("colorPalettes"),
)
return view
}

encode(instance: ProjectView): IProjectView {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/rxdb/collections/projects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// You're right in landing here, this logically is where you would find the table desccription for the project table, however there is no "project table" and only a "view" built from the event stream.

// You're right in landing here, this logically is where you would find the table description for the project table, however there is no "project table" and only a "view" built from the event stream.

// You'll find the table description in {projectRoot}/cqrs/views/project-view.ts or you can "go to definition" below

Expand Down
4 changes: 4 additions & 0 deletions src/lib/rxdb/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import { CollectionNames, type DatabaseType } from "./types"
import { browser } from "$app/environment"
import { ProjectView } from "$lib/cqrs/views/project"

// I went down this path and regret having done so because while
// rxdb is a great piece of software, I don't like it. I should
// have and probably will use Dexie directly as the API is nicer

/**
* Create a new database instance and initialize the collections.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="app">
<aside>
<p>
{$userAddress}
<input readonly value={$userAddress} />
<small>
Save this somewhere safe, this is your unique Novum address. Lose this and you
lose all your work and invites.
Expand Down
Loading

0 comments on commit 57da05c

Please sign in to comment.