diff --git a/project.yaml b/project.yaml index bf0267c..a0f3f13 100644 --- a/project.yaml +++ b/project.yaml @@ -11,7 +11,8 @@ - replace user-affecting console.logs with error messages (eg. catches) -- contacts +- contacts v1: + - parse input correctly (with CSV lib and not commas) - commit screen diff --git a/src/db/index.ts b/src/db/index.ts index be9d9f4..67b3061 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -1,6 +1,12 @@ -import BaseDexie from "dexie"; +import BaseDexie, { Table } from "dexie"; import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon"; -import { accountsSchema, AccountsTable } from "./tables/accounts"; +import { accountsSchema, Account } from "./tables/accounts"; +import { contactsSchema, Contact } from "./tables/contacts"; + +type AllTables = { + accounts: Table; + contacts: Table; +}; /** * In order to make the next line be acceptable, the program needs to have its linter suppress a rule: @@ -10,10 +16,9 @@ import { accountsSchema, AccountsTable } from "./tables/accounts"; * * https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any */ -type DexieTables = AccountsTable; +type DexieTables = AllTables; export type Dexie = BaseDexie & T; export const db = new BaseDexie("kickStarter") as Dexie; -const schema = Object.assign({}, accountsSchema); /** * Needed to enable a special webpack setting to allow *await* below: @@ -27,6 +32,7 @@ const secret = if (localStorage.getItem("secret") == null) { localStorage.setItem("secret", secret); } -console.log(secret); +console.log("DB encryption secretKey:", secret); encrypted(db, { secretKey: secret }); -db.version(1).stores(schema); +db.version(1).stores(accountsSchema); +db.version(2).stores(contactsSchema); diff --git a/src/db/tables/accounts.ts b/src/db/tables/accounts.ts index 8ed1bd2..b78982f 100644 --- a/src/db/tables/accounts.ts +++ b/src/db/tables/accounts.ts @@ -1,5 +1,3 @@ -import { Table } from "dexie"; - export type Account = { id?: number; publicKey: string; @@ -8,10 +6,6 @@ export type Account = { dateCreated: number; }; -export type AccountsTable = { - accounts: Table; -}; - // mark encrypted field by starting with a $ character export const accountsSchema = { accounts: "++id, publicKey, $mnemonic, $identity, dateCreated", diff --git a/src/db/tables/contacts.ts b/src/db/tables/contacts.ts new file mode 100644 index 0000000..a197902 --- /dev/null +++ b/src/db/tables/contacts.ts @@ -0,0 +1,12 @@ +export interface Contact { + did: string; + name?: string; + publicKeyBase64?: string; + seesMe?: boolean; + registered?: boolean; +} + +// mark encrypted field by starting with a $ character +export const contactsSchema = { + contacts: "++did, name, publicKeyBase64, seesMe, registered", +}; diff --git a/src/main.ts b/src/main.ts index 234967b..8fc26a4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -20,6 +20,7 @@ import { faShareNodes, faQrcode, faUser, + faUsers, faPen, faPlus, faTrashCan, @@ -41,6 +42,7 @@ library.add( faShareNodes, faQrcode, faUser, + faUsers, faPen, faPlus, faTrashCan, diff --git a/src/router/index.ts b/src/router/index.ts index 38611c9..3147ab4 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -43,6 +43,12 @@ const routes: Array = [ /* webpackChunkName: "confirm-contact" */ "../views/ConfirmContactView.vue" ), }, + { + path: "/contacts", + name: "contacts", + component: () => + import(/* webpackChunkName: "contacts" */ "../views/ContactsView.vue"), + }, { path: "/scan-contact", name: "scan-contact", diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index 0bc56fa..d67e3a2 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -29,10 +29,10 @@
  • - +
  • diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue new file mode 100644 index 0000000..34fcb2b --- /dev/null +++ b/src/views/ContactsView.vue @@ -0,0 +1,442 @@ + + + diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index c351481..7eadab7 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -26,8 +26,10 @@
  • -
  • diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index 54c020f..bb153aa 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -107,6 +107,7 @@ export default class NewEditProjectView extends Vue { isHiddenSave = false; isHiddenSpinner = true; + // 'created' hook runs when the Vue instance is first created async created() { if (this.projectId === "") { console.log("This is a new project"); diff --git a/src/views/ProjectViewView.vue b/src/views/ProjectViewView.vue index f0a2b4e..e8577ff 100644 --- a/src/views/ProjectViewView.vue +++ b/src/views/ProjectViewView.vue @@ -222,6 +222,7 @@ export default class ProjectViewView extends Vue { } } + // 'created' hook runs when the Vue instance is first created async created() { await db.open(); const num_accounts = await db.accounts.count(); diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 06b8fdc..46660cd 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -26,8 +26,10 @@
  • -
  • @@ -151,6 +153,7 @@ export default class ProjectsView extends Vue { } } + // 'created' hook runs when the Vue instance is first created async created() { await db.open(); const num_accounts = await db.accounts.count();