diff --git a/package.json b/package.json index 5ef417d..11b7f81 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kickstart-for-time-pwa", - "version": "0.1.2", + "version": "0.1.3", "private": true, "scripts": { "serve": "vue-cli-service serve", diff --git a/project.task.yaml b/project.task.yaml index b489cd3..c370194 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -6,14 +6,10 @@ tasks: - 40 notifications : - push, where we trigger a ServiceWorker(?) in the app to reach out and check for new data assignee:matthew -- 01 bug - we get a 404 when reloading the page anyplace except "/", and it's hard to get back -- .1 test - make sure that a registration failure (including network failure) doesn't give a success message (which may have happened during board meeting) - -- .1 don't allow to even see the claim actions if they're not registered - - 01 Replace Gifted/Give in ContactsView with GiftedDialog assignee:matthew - 01 fix the Discovery map display to not show on top of bottom icons (and any other UI tweaks on the map flow) assignee-group:ui +- .1 add instructions for map location selection - 01 Show pop-up or some message confirming that settings & contacts download has been initiated/finished assignee:matthew assignee-group:ui @@ -27,7 +23,7 @@ tasks: - 24 Move to Vite assignee:matthew -- .2 fit more icons on home screen, with a "more" button to contacts page if there is more than 2 rows +- .2 fit as many icons as possible on home & project view screens but only going halfway down the page - .1 Remove notification alert visuals on home page - .5 Add infinite scroll to gifts on the home page - .5 bug - search for "Safari" does not find the project, but if already on the "Anywhere" tab it shows all @@ -57,7 +53,8 @@ tasks: - 01 Would it look better to shrink the buttons on many pages so they don't expand to the width of the screen? assignee-group:ui - .5 Display a more appealing confirmation on the map when erasing the marker assignee-group:ui - .5 make a VC details page -- .1 Add units or different icon to the coins (to distinguish $, BTC, etc) +- .1 Add units or different icon to the coins (to distinguish $, BTC, hours, etc) +- .1 remove firstName (& lastName) from localStorage - contacts v+ : - 01 Import all the non-sensitive data (ie. contacts & settings). diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index d06d334..f803046 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -2,7 +2,7 @@

- {{ message }} {{ giver?.name || "somebody not specified" }} + {{ message }} {{ giver?.name || "somebody not named" }}

diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index 8298dfe..fb926c9 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -12,7 +12,8 @@ export type Settings = { activeDid?: string; apiServer?: string; firstName?: string; - lastName?: string; + isRegistered?: boolean; + lastName?: string; // deprecated, pre v 0.1.3 lastViewedClaimId?: string; searchBoxes?: Array<{ name: string; diff --git a/src/router/index.ts b/src/router/index.ts index fa0e035..c06a5dc 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -33,7 +33,6 @@ const routes: Array = [ name: "home", component: () => import(/* webpackChunkName: "home" */ "../views/HomeView.vue"), - beforeEnter: enterOrStart, }, { path: "/account", @@ -79,7 +78,6 @@ const routes: Array = [ name: "contacts", component: () => import(/* webpackChunkName: "contacts" */ "../views/ContactsView.vue"), - beforeEnter: enterOrStart, }, { path: "/scan-contact", diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index aafb7cb..f222fc3 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -52,7 +52,17 @@
-

{{ firstName }} {{ lastName }}

+

+ {{ givenName }} +

+ + + (set name) + +
ID
@@ -67,53 +77,11 @@ Copied!
- -
Public Key (base 64)
-
- {{ publicBase64 }} - - Copied! -
- -
Public Key (hex)
-
- {{ publicHex }} - - Copied! -
- -
Derivation Path
-
- {{ derivationPath }} - - Copied! -
Edit Identity @@ -132,8 +100,10 @@ ) " > + +
App Notifications
-
+
@@ -143,8 +113,6 @@ class="dot absolute left-1 top-1 bg-slate-400 w-6 h-6 rounded-full transition" >
- -
App Notifications
@@ -192,32 +160,13 @@ class="block w-full text-center text-md uppercase bg-slate-500 text-white px-1.5 py-2 rounded-md mb-6" @click="exportDatabase()" > - Download Settings & Contacts (excluding Identifier Data) + Download Settings & Contacts +
+ (excluding Identifier Data) - - -
- ID: did:peer:kl45kj41lk451kl3 -
- - - - -
- -
+
@@ -252,14 +201,76 @@ > Advanced +
+ +

+ Deep Identity Details +

+
+
Public Key (base 64)
+
+ {{ publicBase64 }} + + Copied! +
+ +
Public Key (hex)
+
+ {{ publicHex }} + + Copied! +
+ +
Derivation Path
+
+ {{ derivationPath }} + + Copied! +
+
+
- - - Switch Identity / No Identity - +
- Claim Server + +
+ +
+

Claim Server

- -
- -
@@ -346,7 +354,7 @@ import { useClipboard } from "@vueuse/core"; import QuickNav from "@/components/QuickNav.vue"; import { AppString } from "@/constants/app"; import { db, accountsDB } from "@/db/index"; -import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { IIdentifier } from "@veramo/core"; import { ErrorResponse, RateLimits } from "@/libs/endorserServer"; @@ -368,14 +376,6 @@ interface IAccount { derivationPath: string; } -interface SettingsType { - activeDid?: string; - apiServer?: string; - firstName?: string; - lastName?: string; - showContactGivesInline?: boolean; -} - @Component({ components: { QuickNav } }) export default class AccountViewView extends Vue { $notify!: (notification: Notification, timeout?: number) => void; @@ -386,8 +386,8 @@ export default class AccountViewView extends Vue { apiServer = ""; apiServerInput = ""; derivationPath = ""; - firstName = ""; - lastName = ""; + givenName = ""; + isRegistered = false; numAccounts = 0; publicHex = ""; publicBase64 = ""; @@ -402,8 +402,6 @@ export default class AccountViewView extends Vue { showPubCopy = false; showAdvanced = false; - alertMessage = ""; - alertTitle = ""; public async getIdentity(activeDid: string): Promise { try { @@ -428,7 +426,7 @@ export default class AccountViewView extends Vue { } // Return parsed identity or null if not found - return JSON.parse(account?.identity || "null"); + return JSON.parse((account?.identity as string) || "null"); } /** @@ -509,12 +507,14 @@ export default class AccountViewView extends Vue { * Initializes component state with values from the database or defaults. * @param {SettingsType} settings - Object containing settings from the database. */ - initializeState(settings: SettingsType | undefined) { - this.activeDid = settings?.activeDid || ""; - this.apiServer = settings?.apiServer || ""; - this.apiServerInput = settings?.apiServer || ""; - this.firstName = settings?.firstName || ""; - this.lastName = settings?.lastName || ""; + initializeState(settings: Settings | undefined) { + this.activeDid = (settings?.activeDid as string) || ""; + this.apiServer = (settings?.apiServer as string) || ""; + this.apiServerInput = (settings?.apiServer as string) || ""; + this.givenName = + (settings?.firstName || "") + + (settings?.lastName ? ` ${settings.lastName}` : ""); // pre v 0.1.3 + this.isRegistered = !!settings?.isRegistered; this.showContactGives = !!settings?.showContactGivesInline; } @@ -531,7 +531,7 @@ export default class AccountViewView extends Vue { ) { this.publicHex = identity.keys[0].publicKeyHex; this.publicBase64 = Buffer.from(this.publicHex, "hex").toString("base64"); - this.derivationPath = identity.keys[0].meta.derivationPath; + this.derivationPath = identity.keys[0].meta.derivationPath as string; db.settings.update(MASTER_SETTINGS_KEY, { activeDid: identity.did, @@ -701,6 +701,27 @@ export default class AccountViewView extends Vue { const resp = await this.fetchRateLimits(identity); if (resp.status === 200) { this.limits = resp.data; + if (!this.isRegistered) { + // the user is not known to be registered, but they are so let's record it + try { + await db.open(); + db.settings.update(MASTER_SETTINGS_KEY, { + isRegistered: true, + }); + this.isRegistered = true; + } catch (err) { + console.log("Got an error updating settings:", err); + this.$notify( + { + group: "alert", + type: "warning", + title: "Update Error", + text: "Unable to update your settings. Check claim limits again.", + }, + -1, + ); + } + } } } catch (error) { this.handleRateLimitsError(error); @@ -729,8 +750,13 @@ export default class AccountViewView extends Vue { private handleRateLimitsError(error: unknown) { if (error instanceof AxiosError) { const data = error.response?.data as ErrorResponse; - this.limitsMessage = data?.error?.message || "Bad server response."; - console.error("Bad response retrieving limits:", error); + this.limitsMessage = + (data?.error?.message as string) || "Bad server response."; + console.log( + "Got bad response retrieving limits, which usually means user isn't registered. Server says:", + this.limitsMessage, + //error, + ); } else if ( error instanceof Error && error.message === diff --git a/src/views/ContactGiftingView.vue b/src/views/ContactGiftingView.vue index cd8a9de..828a30e 100644 --- a/src/views/ContactGiftingView.vue +++ b/src/views/ContactGiftingView.vue @@ -16,10 +16,6 @@
- - - -
  • @@ -70,12 +66,7 @@
- - + @@ -83,16 +74,10 @@ import { Component, Vue } from "vue-facing-decorator"; import GiftedDialog from "@/components/GiftedDialog.vue"; import { db, accountsDB } from "@/db/index"; -import { AccountsSchema } from "@/db/tables/accounts"; -import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { Account, AccountsSchema } from "@/db/tables/accounts"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; -import { - createAndSubmitGive, - CreateAndSubmitGiveResult, - ErrorResult, - GiverInputInfo, - GiverOutputInfo, -} from "@/libs/endorserServer"; +import { GiverInputInfo } from "@/libs/endorserServer"; import { Contact } from "@/db/tables/contacts"; import QuickNav from "@/components/QuickNav.vue"; import EntityIcon from "@/components/EntityIcon.vue"; @@ -124,10 +109,10 @@ export default class ContactGiftingView extends Vue { public async getIdentity(activeDid: string) { await accountsDB.open(); - const account = await accountsDB.accounts + const account = (await accountsDB.accounts .where("did") .equals(activeDid) - .first(); + .first()) as Account; const identity = JSON.parse(account?.identity || "null"); if (!identity) { @@ -150,7 +135,7 @@ export default class ContactGiftingView extends Vue { async created() { try { await db.open(); - const settings = await db.settings.get(MASTER_SETTINGS_KEY); + const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.apiServer = settings?.apiServer || ""; this.activeDid = settings?.activeDid || ""; this.allContacts = await db.contacts.toArray(); @@ -173,123 +158,5 @@ export default class ContactGiftingView extends Vue { openDialog(giver: GiverInputInfo) { (this.$refs.customDialog as GiftedDialog).open(giver); } - - handleDialogResult(result: GiverOutputInfo) { - if (result.action === "confirm") { - return new Promise((resolve) => { - this.recordGive( - result.giver?.did, - result.description, - result.hours, - ).then(() => { - resolve(null); - }); - }); - } else { - // action was "cancel" so do nothing - } - } - - /** - * - * @param giverDid may be null - * @param description may be an empty string - * @param hours may be 0 - */ - public async recordGive( - giverDid?: string, - description?: string, - hours?: number, - ) { - if (!this.activeDid) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: "You must select an identity before you can record a give.", - }, - -1, - ); - return; - } - - if (!description && !hours) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: "You must enter a description or some number of hours.", - }, - -1, - ); - return; - } - - try { - const identity = await this.getIdentity(this.activeDid); - const result = await createAndSubmitGive( - this.axios, - this.apiServer, - identity, - giverDid, - this.activeDid, - description, - hours, - ); - - if (this.isGiveCreationError(result)) { - const errorMessage = this.getGiveCreationErrorMessage(result); - console.log("Error with give result:", result); - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: errorMessage || "There was an error recording the give.", - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "success", - title: "Success", - text: "That gift was recorded.", - }, - -1, - ); - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - console.log("Error with give caught:", error); - - const message = - error.userMessage || - error.response?.data?.error?.message || - "There was an error recording the Give."; - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: message, - }, - -1, - ); - } - } - - // Helper functions for readability - - isGiveCreationError(result: CreateAndSubmitGiveResult) { - return result.type == "error"; - } - - getGiveCreationErrorMessage(result: CreateAndSubmitGiveResult) { - return (result as ErrorResult).error?.userMessage; - } } diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index 282f472..21a924e 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -108,7 +108,9 @@ export default class ContactQRScanShow extends Vue { iat: Date.now(), iss: this.activeDid, own: { - name: (settings?.firstName || "") + " " + (settings?.lastName || ""), + name: + (settings?.firstName || "") + + (settings?.lastName ? ` ${settings.lastName}` : ""), // deprecated, pre v 0.1.3 publicEncKey, }, }; diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 7c0a81e..fc3d33f 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -256,7 +256,7 @@ import { NotificationIface } from "@/constants/app"; import { IIdentifier } from "@veramo/core"; import { accountsDB, db } from "@/db/index"; import { Contact } from "@/db/tables/contacts"; -import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import { accessToken, getContactPayloadFromJwtUrl, @@ -271,6 +271,7 @@ import { import { Component, Vue } from "vue-facing-decorator"; import QuickNav from "@/components/QuickNav.vue"; import EntityIcon from "@/components/EntityIcon.vue"; +import { Account } from "@/db/tables/accounts"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; @@ -308,7 +309,7 @@ export default class ContactsView extends Vue { async created() { await db.open(); - const settings = await db.settings.get(MASTER_SETTINGS_KEY); + const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.activeDid = settings?.activeDid || ""; this.apiServer = settings?.apiServer || ""; @@ -332,7 +333,7 @@ export default class ContactsView extends Vue { public async getIdentity(activeDid: string) { await accountsDB.open(); const accounts = await accountsDB.accounts.toArray(); - const account = R.find((acc) => acc.did === activeDid, accounts); + const account = R.find((acc) => acc.did === activeDid, accounts) as Account; const identity = JSON.parse(account?.identity || "null"); if (!identity) { @@ -394,7 +395,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: "Got an error retrieving your " + (useRecipient ? "given" : "received") + @@ -453,7 +454,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: error as string, }, -1, @@ -589,6 +590,16 @@ export default class ContactsView extends Vue { "?", ) ) { + this.$notify( + { + group: "alert", + type: "toast", + text: "", + title: "Registration submitted...", + }, + 1000, + ); + const identity = await this.getIdentity(this.activeDid); const vcClaim: RegisterVerifiableCredential = { @@ -671,7 +682,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: userMessage, }, -1, @@ -696,36 +707,30 @@ export default class ContactsView extends Vue { contact.seesMe = visibility; db.contacts.update(contact.did, { seesMe: visibility }); } else { - console.error("Bad response setting visibility: ", resp.data); - if (resp.data.error?.message) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: resp.data.error?.message, - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: "Bad server response of " + resp.status, - }, - -1, - ); - } + console.error( + "Got some bad server response when setting visibility: ", + resp, + ); + const message = + resp.data.error?.message || "Bad server response of " + resp.status; + this.$notify( + { + group: "alert", + type: "danger", + title: "Server Error", + text: message, + }, + -1, + ); } } catch (err) { + console.error("Got some server error when setting visibility:", err); this.$notify( { group: "alert", type: "danger", - title: "Error With Server", - text: err as string, + title: "Server Error", + text: "Check connectivity and try again.", }, -1, ); @@ -750,7 +755,7 @@ export default class ContactsView extends Vue { this.$notify( { group: "alert", - type: "toast", + type: "info", title: "Refreshed", text: this.nameForContact(contact, true) + @@ -758,38 +763,29 @@ export default class ContactsView extends Vue { (visibility ? "" : "not ") + "see your activity.", }, - 5000, + -1, ); } else { - if (resp.data.error?.message) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: resp.data.error?.message, - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error With Server", - text: "Bad server response of " + resp.status, - }, - -1, - ); - } + console.log("Got bad server response when checking visibility: ", resp); + const message = resp.data.error?.message || "Got bad server response."; + this.$notify( + { + group: "alert", + type: "danger", + title: "Server Error", + text: message, + }, + -1, + ); } } catch (err) { + console.log("Caught error from server request to check visibility:", err); this.$notify( { group: "alert", type: "danger", - title: "Error With Server", - text: err as string, + title: "Server Error", + text: "Check connectivity and try again.", }, -1, ); @@ -989,7 +985,7 @@ export default class ContactsView extends Vue { { group: "alert", type: "danger", - title: "Error With Server", + title: "Server Error", text: userMessage, }, -1, diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 73a62ed..5aaeac6 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -6,64 +6,82 @@ Time Safari +
-

Record a Gift

- -
    -
  • - -

    - Anonymous -

    -
  • -
  • + To record others' giving, + + create your identifier. +
+ +
+ To record others' giving, someone must register your account, so show + them + + your identity info + and then + + check your limits. - -

+ +
+ +

Record a Gift

+ +
    +
  • + +

    + Anonymous/Unnamed +

    +
  • +
  • - {{ contact.name || contact.did }} -

- - + +

+ {{ contact.name || contact.did }} +

+ + + + + + Show More Contacts… + - - - Show More Contacts… - - - -
- (No contacts to show.) + +
+ (No contacts to show.) +
- - +

Latest Activity

@@ -99,19 +117,18 @@ import { Component, Vue } from "vue-facing-decorator"; import GiftedDialog from "@/components/GiftedDialog.vue"; import { db, accountsDB } from "@/db/index"; -import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import { accessToken } from "@/libs/crypto"; import { - createAndSubmitGive, didInfo, GiverInputInfo, - GiverOutputInfo, GiveServerRecord, } from "@/libs/endorserServer"; import { Contact } from "@/db/tables/contacts"; import QuickNav from "@/components/QuickNav.vue"; import EntityIcon from "@/components/EntityIcon.vue"; import { IIdentifier } from "@veramo/core"; +import { Account } from "@/db/tables/accounts"; interface Notification { group: string; @@ -135,6 +152,7 @@ export default class HomeView extends Vue { feedPreviousOldestId?: string; feedLastViewedId?: string; isHiddenSpinner = true; + isRegistered = false; numAccounts = 0; async beforeCreate() { @@ -144,10 +162,10 @@ export default class HomeView extends Vue { public async getIdentity(activeDid: string) { await accountsDB.open(); - const account = await accountsDB.accounts + const account = (await accountsDB.accounts .where("did") .equals(activeDid) - .first(); + .first()) as Account; const identity = JSON.parse(account?.identity || "null"); if (!identity) { @@ -174,11 +192,12 @@ export default class HomeView extends Vue { this.allMyDids = allAccounts.map((acc) => acc.did); await db.open(); - const settings = await db.settings.get(MASTER_SETTINGS_KEY); + const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.apiServer = settings?.apiServer || ""; this.activeDid = settings?.activeDid || ""; this.allContacts = await db.contacts.toArray(); this.feedLastViewedId = settings?.lastViewedClaimId; + this.isRegistered = !!settings?.isRegistered; this.updateAllFeed(); // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (err: any) { @@ -204,7 +223,9 @@ export default class HomeView extends Vue { if (this.activeDid) { await accountsDB.open(); const allAccounts = await accountsDB.accounts.toArray(); - const account = allAccounts.find((acc) => acc.did === this.activeDid); + const account = allAccounts.find( + (acc) => acc.did === this.activeDid, + ) as Account; const identity = JSON.parse(account?.identity || "null"); if (!identity) { @@ -333,139 +354,5 @@ export default class HomeView extends Vue { openDialog(giver: GiverInputInfo) { (this.$refs.customDialog as GiftedDialog).open(giver); } - - handleDialogResult(result: GiverOutputInfo) { - if (result.action === "confirm") { - return new Promise((resolve) => { - this.recordGive( - result.giver?.did, - result.description, - result.hours, - ).then(() => { - resolve(null); - }); - }); - } else { - // action was "cancel" so do nothing - } - } - - /** - * - * @param giverDid may be null - * @param description may be an empty string - * @param hours may be 0 - */ - public async recordGive( - giverDid?: string, - description?: string, - hours?: number, - ) { - if (!this.activeDid) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: "You must select an identity before you can record a give.", - }, - -1, - ); - return; - } - - if (!description && !hours) { - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: "You must enter a description or some number of hours.", - }, - -1, - ); - return; - } - - try { - const identity = await this.getIdentity(this.activeDid); - const result = await createAndSubmitGive( - this.axios, - this.apiServer, - identity, - giverDid, - this.activeDid, - description, - hours, - ); - - if ( - result.type === "error" || - this.isGiveCreationError(result.response) - ) { - const errorMessage = this.getGiveCreationErrorMessage(result); - console.log("Error with give creation result:", result); - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: errorMessage || "There was an error creating the give.", - }, - -1, - ); - } else { - this.$notify( - { - group: "alert", - type: "success", - title: "Success", - text: "That gift was recorded.", - }, - -1, - ); - } - // eslint-disable-next-line @typescript-eslint/no-explicit-any - } catch (error: any) { - console.log("Error with give recordation caught:", error); - const message = - error.userMessage || - error.response?.data?.error?.message || - "There was an error recording the give."; - this.$notify( - { - group: "alert", - type: "danger", - title: "Error", - text: message, - }, - -1, - ); - } - } - - // Helper functions for readability - - /** - * @param result response "data" from the server - * @returns true if the result indicates an error - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - isGiveCreationError(result: any) { - return result.status !== 201 || result.data?.error; - } - - /** - * @param result direct response eg. ErrorResult or SuccessResult (potentially with embedded "data") - * @returns best guess at an error message - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - getGiveCreationErrorMessage(result: any) { - return ( - result.error?.userMessage || - result.error?.error || - result.response?.data?.error?.message - ); - } } diff --git a/src/views/IdentitySwitcherView.vue b/src/views/IdentitySwitcherView.vue index f0ed07b..74d17c3 100644 --- a/src/views/IdentitySwitcherView.vue +++ b/src/views/IdentitySwitcherView.vue @@ -22,7 +22,7 @@

- {{ firstName }} {{ lastName }} + {{ givenName }}

ID: {{ activeDid }} @@ -71,7 +71,7 @@ import { Component, Vue } from "vue-facing-decorator"; import { AppString } from "@/constants/app"; import { db, accountsDB } from "@/db/index"; import { AccountsSchema } from "@/db/tables/accounts"; -import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; +import { MASTER_SETTINGS_KEY, Settings } from "@/db/tables/settings"; import QuickNav from "@/components/QuickNav.vue"; interface Notification { @@ -90,8 +90,7 @@ export default class IdentitySwitcherView extends Vue { public activeDid = ""; public apiServer = ""; public apiServerInput = ""; - public firstName = ""; - public lastName = ""; + public givenName = ""; public otherIdentities: Array<{ did: string }> = []; public showContactGives = false; @@ -101,19 +100,20 @@ export default class IdentitySwitcherView extends Vue { .where("did") .equals(activeDid) .first(); - const identity = JSON.parse(account?.identity || "null"); + const identity = JSON.parse((account?.identity as string) || "null"); return identity; } async created() { try { await db.open(); - const settings = await db.settings.get(MASTER_SETTINGS_KEY); + const settings = (await db.settings.get(MASTER_SETTINGS_KEY)) as Settings; this.activeDid = settings?.activeDid || ""; this.apiServer = settings?.apiServer || ""; this.apiServerInput = settings?.apiServer || ""; - this.firstName = settings?.firstName || "No"; - this.lastName = settings?.lastName || "Name"; + this.givenName = + (settings?.firstName || "") + + (settings?.lastName ? ` ${settings.lastName}` : ""); // deprecated, pre v 0.1.3 this.showContactGives = !!settings?.showContactGivesInline; const identity = await this.getIdentity(this.activeDid); @@ -151,7 +151,7 @@ export default class IdentitySwitcherView extends Vue { did = undefined; } await db.open(); - db.settings.update(MASTER_SETTINGS_KEY, { + await db.settings.update(MASTER_SETTINGS_KEY, { activeDid: did, }); this.activeDid = did || ""; diff --git a/src/views/NewEditAccountView.vue b/src/views/NewEditAccountView.vue index 0fb5a7c..b416490 100644 --- a/src/views/NewEditAccountView.vue +++ b/src/views/NewEditAccountView.vue @@ -10,21 +10,15 @@ > - [New/Edit] Identity + Edit Identity
-
@@ -50,36 +44,30 @@