From 6dc0c2cd58fcd20c4676b37a80bcf98ea3c79650 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 23 Mar 2024 01:32:55 -0600 Subject: [PATCH 01/38] add a camera-switch button --- src/components/GiftedDialog.vue | 2 +- src/components/GiftedPhotoDialog.vue | 37 ++++++++++++++++++++++------ src/views/HelpView.vue | 4 +-- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index cfb7f50a4..386f7621d 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -53,7 +53,7 @@ }" class="text-blue-500" > - More Options + Photo, ... diff --git a/src/components/GiftedPhotoDialog.vue b/src/components/GiftedPhotoDialog.vue index 43d4cd470..93dcb8967 100644 --- a/src/components/GiftedPhotoDialog.vue +++ b/src/components/GiftedPhotoDialog.vue @@ -48,7 +48,12 @@ Camera "resolution" doesn't change how it shows on screen but rather stretches the result, eg the following which just stretches it vertically: :resolution="{ width: 375, height: 812 }" --> - +
@@ -59,6 +64,14 @@
+
+ +
@@ -80,12 +93,11 @@ import { accessToken } from "@/libs/crypto"; export default class GiftedPhotoDialog extends Vue { $notify!: (notification: NotificationIface, timeout?: number) => void; + activeDeviceNumber = 0; activeDid = ""; blob: Blob | null = null; + numDevices = 0; setImage: (arg: string) => void = () => {}; - imageHeight?: number = window.innerHeight / 2; - imageWidth?: number = window.innerWidth / 2; - imageWarning = "."; uploading = false; visible = false; @@ -129,6 +141,20 @@ export default class GiftedPhotoDialog extends Vue { this.blob = null; } + async cameraStarted() { + const cameraComponent = this.$refs.camera as InstanceType; + if (cameraComponent) { + this.numDevices = (await cameraComponent.devices(["videoinput"])).length; + } + } + + async switchCamera() { + const cameraComponent = this.$refs.camera as InstanceType; + this.activeDeviceNumber = (this.activeDeviceNumber + 1) % this.numDevices; + const devices = await cameraComponent?.devices(["videoinput"]); + cameraComponent?.changeCamera(devices[this.activeDeviceNumber].deviceId); + } + async takeImage(/* payload: MouseEvent */) { const cameraComponent = this.$refs.camera as InstanceType; @@ -200,7 +226,6 @@ export default class GiftedPhotoDialog extends Vue { async cameraClicked() { - console.log("camera_button clicked"); const video = document.querySelector("#video"); const stream = await navigator.mediaDevices.getUserMedia({ video: true, @@ -211,7 +236,6 @@ export default class GiftedPhotoDialog extends Vue { } } photoSnapped() { - console.log("snap_photo clicked"); const video = document.querySelector("#video"); const canvas = document.querySelector("#canvas"); if ( @@ -232,7 +256,6 @@ export default class GiftedPhotoDialog extends Vue { // data url of the image const image_data_url = canvas?.toDataURL("image/jpeg"); - console.log(image_data_url); } } ****/ diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index 8e47b7c87..0db68e224 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -198,9 +198,7 @@
  • Chrome: - clear here + Clear at chrome://settings/content/all and also clear under dev tools Application
  • -- 2.30.2 From 2b8f9579f1f4c39c508510de285de1990041e0fb Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 23 Mar 2024 02:31:44 -0600 Subject: [PATCH 02/38] fix so that project agent & location removals get saved --- src/views/NewEditProjectView.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index cceaaafb2..cab2b8756 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -265,6 +265,8 @@ export default class NewEditProjectView extends Vue { vcClaim.agent = { identifier: this.agentDid, }; + } else { + delete vcClaim.agent; } if (this.includeLocation) { vcClaim.location = { @@ -274,6 +276,8 @@ export default class NewEditProjectView extends Vue { longitude: this.longitude, }, }; + } else { + delete vcClaim.location; } // Make a payload for the claim const vcPayload = { -- 2.30.2 From 28754bdfb1e11aa221dd49a5dce4219b69cf6a9d Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 23 Mar 2024 02:41:25 -0600 Subject: [PATCH 03/38] bump version to 0.3.5 --- CHANGELOG.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cccdeea34..73252b8ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Nothing -## [0.3.4] - 2024.03.21 +## [0.3.5] - 2024.03.23 ### Added - Photo on gift records ### Fixed diff --git a/package-lock.json b/package-lock.json index 1d576d60c..cdebbe06f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "TimeSafari", - "version": "0.3.4", + "version": "0.3.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "TimeSafari", - "version": "0.3.4", + "version": "0.3.5", "dependencies": { "@dicebear/collection": "^5.3.5", "@dicebear/core": "^5.3.5", diff --git a/package.json b/package.json index 2dff0e243..97cf9196a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "TimeSafari", - "version": "0.3.4", + "version": "0.3.5", "private": true, "scripts": { "serve": "vue-cli-service serve", -- 2.30.2 From 40d12b1f9c42e29f1a0b8362aeee812350b4c636 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 23 Mar 2024 16:31:23 -0600 Subject: [PATCH 04/38] add button on photo to switch to mirror mode --- src/components/GiftedPhotoDialog.vue | 43 ++++++++++++++++++++++++---- src/main.ts | 2 ++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/GiftedPhotoDialog.vue b/src/components/GiftedPhotoDialog.vue index 93dcb8967..35f121da1 100644 --- a/src/components/GiftedPhotoDialog.vue +++ b/src/components/GiftedPhotoDialog.vue @@ -43,7 +43,7 @@ -
    +
    +
    +
    +
    diff --git a/src/components/GiftedDialog.vue b/src/components/GiftedDialog.vue index 1a8d8be3c..57cf34917 100644 --- a/src/components/GiftedDialog.vue +++ b/src/components/GiftedDialog.vue @@ -59,6 +59,11 @@

    Sign & Send to publish to the world +

    - +
    @@ -230,7 +230,7 @@ @click="onClickLoadClaim(offer.jwtId as string)" class="cursor-pointer" > - +
    - + diff --git a/src/views/ProjectsView.vue b/src/views/ProjectsView.vue index 48c7a718f..ad0e930b9 100644 --- a/src/views/ProjectsView.vue +++ b/src/views/ProjectsView.vue @@ -167,7 +167,7 @@ diff --git a/src/views/QuickActionBvcEndView.vue b/src/views/QuickActionBvcEndView.vue index ba0dc770b..930509f53 100644 --- a/src/views/QuickActionBvcEndView.vue +++ b/src/views/QuickActionBvcEndView.vue @@ -60,7 +60,7 @@ }} -- 2.30.2 From 0e2c5af16ead6625b27069a2aa25d3077625794a Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 24 Mar 2024 17:01:53 -0600 Subject: [PATCH 08/38] add onboarding help instructions as separate page --- README.md | 2 +- src/libs/util.ts | 5 --- src/router/index.ts | 20 ++++++--- src/views/ContactsView.vue | 51 +++++++++-------------- src/views/HelpOnboardingView.vue | 69 ++++++++++++++++++++++++++++++++ src/views/HelpView.vue | 17 +------- 6 files changed, 106 insertions(+), 58 deletions(-) create mode 100644 src/views/HelpOnboardingView.vue diff --git a/README.md b/README.md index abb43f1a9..dd2e6a0ed 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ To add an icon, add to main.ts and reference with `fa` element and `icon` attrib * Clear cache for site. (In Chrome, go to `chrome://settings/cookies` and "all site data and permissions"; in Firefox, go to `about:preferences` and search for "cache" then "Manage Data", and also manually remove the IndexedDB data if the DBs still show.) * Clear notification permission. (In Chrome, go to `chrome://settings/content/notifications`; in Firefox, go to `about:preferences` and search for "notifications".) -* Unregister service worker. (In Chrome, go to `chrome://serviceworker-internals/`; in Firefox, go to `about:serviceworkers`.) +* Unregister service worker. (In Chrome, go to `chrome://serviceworker-internals`; in Firefox, go to `about:serviceworkers`.) * Clear Cache Storage manually, possibly deleting the DB. (In Chrome, in dev tools under Application; in Firefox, in dev tools under Storage.) (If you find more, add them to the HelpNotificationsView.vue file.) diff --git a/src/libs/util.ts b/src/libs/util.ts index 6c4a5c01c..1a613df8c 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -15,11 +15,6 @@ import * as serverUtil from "@/libs/endorserServer"; // eslint-disable-next-line @typescript-eslint/no-var-requires const Buffer = require("buffer/").Buffer; -// If you edit this, check that the numbers still line up on the side in the alert (on mobile, too), -// and make sure they can take all actions while the notification shows. -export const ONBOARD_MESSAGE = - "1) Read through all their yellow prompts. 2) Add them to your Contacts by scanning with the QR icon that is by the input box. 3) Click the person icon to register them. 4) Show them your QR so they'll scan you. 5) Have them enable notifications."; - export const PRIVACY_MESSAGE = "The data you send be visible to the world -- except: your IDs and the IDs of anyone you tag will stay private, only visible to those you allow."; diff --git a/src/router/index.ts b/src/router/index.ts index 4f3e9fe43..0496a37db 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -98,12 +98,6 @@ const routes: Array = [ component: () => import(/* webpackChunkName: "help" */ "../views/HelpView.vue"), }, - { - path: "/", - name: "home", - component: () => - import(/* webpackChunkName: "home" */ "../views/HomeView.vue"), - }, { path: "/help-notifications", name: "help-notifications", @@ -112,6 +106,20 @@ const routes: Array = [ /* webpackChunkName: "help-notifications" */ "../views/HelpNotificationsView.vue" ), }, + { + path: "/help-onboarding", + name: "help-onboarding", + component: () => + import( + /* webpackChunkName: "help-onboarding" */ "../views/HelpOnboardingView.vue" + ), + }, + { + path: "/", + name: "home", + component: () => + import(/* webpackChunkName: "home" */ "../views/HomeView.vue"), + }, { path: "/identity-switcher", name: "identity-switcher", diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index b866e5e24..8384163dc 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -10,7 +10,8 @@ Onboarding Guide @@ -510,18 +511,6 @@ export default class ContactsView extends Vue { } } - showHintsForOnboarding() { - this.$notify( - { - group: "alert", - type: "info", - title: "Onboard Someone", - text: libsUtil.ONBOARD_MESSAGE, - }, - -1, - ); - } - async onClickNewContact(): Promise { if (!this.contactInput) { this.$notify( @@ -531,7 +520,7 @@ export default class ContactsView extends Vue { title: "No Contact", text: "There was no contact info to add.", }, - -1, + 3000, ); return; } @@ -559,7 +548,7 @@ export default class ContactsView extends Vue { title: "Contacts Added", text: "Each contact was added. Nothing was sent to the server.", }, - -1, // keeping it up so that the "visibility" message is seen + 3000, // keeping it up so that the "visibility" message is seen ); } catch (e) { this.$notify( @@ -664,7 +653,7 @@ export default class ContactsView extends Vue { title: "No Contact Info", text: "The contact info could not be parsed.", }, - -1, + 3000, ); return; } else { @@ -686,7 +675,7 @@ export default class ContactsView extends Vue { title: "Incomplete Contact", text: "Cannot add a contact without a DID.", }, - -1, + 5000, ); return; } @@ -698,7 +687,7 @@ export default class ContactsView extends Vue { title: "Invalid DID", text: "The DID is not valid. It must begin with 'did:'", }, - -1, + 5000, ); return; } @@ -737,7 +726,7 @@ export default class ContactsView extends Vue { title: "Contact Added", text: addedMessage, }, - -1, // keeping it up so that the "visibility" message is seen + 3000, ); }) .catch((err) => { @@ -853,7 +842,7 @@ export default class ContactsView extends Vue { title: "Registration Still Unknown", text: message, }, - -1, + 5000, ); } else if (resp.data?.success?.handleId) { contact.registered = true; @@ -892,7 +881,7 @@ export default class ContactsView extends Vue { title: "Registration Error", text: userMessage, }, - -1, + 5000, ); } } @@ -933,7 +922,7 @@ export default class ContactsView extends Vue { (visibility ? "" : "not ") + "see your activity.", }, - -1, + 3000, ); } contact.seesMe = visibility; @@ -953,7 +942,7 @@ export default class ContactsView extends Vue { title: "Error Setting Visibility", text: message, }, - -1, + 5000, ); } } catch (err) { @@ -965,7 +954,7 @@ export default class ContactsView extends Vue { title: "Error Setting Visibility", text: "Check connectivity and try again.", }, - -1, + 5000, ); } } @@ -997,7 +986,7 @@ export default class ContactsView extends Vue { (visibility ? "" : "not ") + "see your activity.", }, - -1, + 3000, ); } else { console.error("Got bad server response checking visibility:", resp); @@ -1009,7 +998,7 @@ export default class ContactsView extends Vue { title: "Error Checking Visibility", text: message, }, - -1, + 5000, ); } } catch (err) { @@ -1021,7 +1010,7 @@ export default class ContactsView extends Vue { title: "Error Checking Visibility", text: "Check connectivity and try again.", }, - -1, + 3000, ); } } @@ -1069,7 +1058,7 @@ export default class ContactsView extends Vue { title: "Input Error", text: "This is not a valid number of hours: " + this.hourInput, }, - -1, + 3000, ); } else if (parseFloat(this.hourInput) == 0 && !this.hourDescriptionInput) { this.$notify( @@ -1079,7 +1068,7 @@ export default class ContactsView extends Vue { title: "Input Error", text: "Giving no hours or description does nothing.", }, - -1, + 3000, ); } else if (!identity) { this.$notify( @@ -1089,7 +1078,7 @@ export default class ContactsView extends Vue { title: "Status Error", text: "No identifier is available.", }, - -1, + 3000, ); } else { // ask to confirm amount @@ -1218,7 +1207,7 @@ export default class ContactsView extends Vue { title: "Error Sending Give", text: userMessage, }, - -1, + 5000, ); } } diff --git a/src/views/HelpOnboardingView.vue b/src/views/HelpOnboardingView.vue new file mode 100644 index 000000000..e6c6b116d --- /dev/null +++ b/src/views/HelpOnboardingView.vue @@ -0,0 +1,69 @@ + + + diff --git a/src/views/HelpView.vue b/src/views/HelpView.vue index 79571b6f7..30cb013dc 100644 --- a/src/views/HelpView.vue +++ b/src/views/HelpView.vue @@ -83,9 +83,9 @@

    How do I add someone else?

    - + To start scanning, go here.

    @@ -376,7 +376,6 @@ import { Component, Vue } from "vue-facing-decorator"; import * as Package from "../../package.json"; import QuickNav from "@/components/QuickNav.vue"; import { NotificationIface } from "@/constants/app"; -import { ONBOARD_MESSAGE } from "@/libs/util"; @Component({ components: { QuickNav } }) export default class Help extends Vue { @@ -384,17 +383,5 @@ export default class Help extends Vue { package = Package; commitHash = process.env.VUE_APP_GIT_HASH; - - showOnboardInfo() { - this.$notify( - { - group: "alert", - type: "info", - title: "Onboard Someone", - text: ONBOARD_MESSAGE, - }, - -1, - ); - } } -- 2.30.2 From 35455e66480c204e57591cda37839614ba6cc1e7 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sun, 24 Mar 2024 18:27:06 -0600 Subject: [PATCH 09/38] fix check for more camera-device options --- src/components/GiftedPhotoDialog.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/GiftedPhotoDialog.vue b/src/components/GiftedPhotoDialog.vue index 35f121da1..8fb17bf1d 100644 --- a/src/components/GiftedPhotoDialog.vue +++ b/src/components/GiftedPhotoDialog.vue @@ -74,7 +74,7 @@
    -
    +
    - +
    + + +
    diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index b1dd6e6fc..1c2ccc503 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -503,7 +503,7 @@ +
    + + +
    diff --git a/src/views/ContactScanView.vue b/src/views/ContactScanView.vue index 9ca3b0bf1..7a8a87d9a 100644 --- a/src/views/ContactScanView.vue +++ b/src/views/ContactScanView.vue @@ -65,17 +65,19 @@ />
    - - +
    + + +
    diff --git a/src/views/GiftedDetails.vue b/src/views/GiftedDetails.vue index d2cb8f162..5b911aefe 100644 --- a/src/views/GiftedDetails.vue +++ b/src/views/GiftedDetails.vue @@ -98,18 +98,20 @@ @click="explainData()" />

    - - +
    + + +
    diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 153de0604..29a89a391 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -160,7 +160,7 @@ diff --git a/src/views/ImportAccountView.vue b/src/views/ImportAccountView.vue index e3ffdf2da..e185c97a8 100644 --- a/src/views/ImportAccountView.vue +++ b/src/views/ImportAccountView.vue @@ -56,19 +56,21 @@
    - - +
    + + +
    diff --git a/src/views/ImportDerivedAccountView.vue b/src/views/ImportDerivedAccountView.vue index 1505620e3..09dbb51c2 100644 --- a/src/views/ImportDerivedAccountView.vue +++ b/src/views/ImportDerivedAccountView.vue @@ -49,19 +49,21 @@
- - +
+ + +
diff --git a/src/views/NewEditAccountView.vue b/src/views/NewEditAccountView.vue index a3f1435ea..cae8c7d68 100644 --- a/src/views/NewEditAccountView.vue +++ b/src/views/NewEditAccountView.vue @@ -22,21 +22,23 @@ />
- - - +
+ + + +
diff --git a/src/views/NewEditProjectView.vue b/src/views/NewEditProjectView.vue index b971c0aad..b2392b222 100644 --- a/src/views/NewEditProjectView.vue +++ b/src/views/NewEditProjectView.vue @@ -105,28 +105,30 @@
- + - + Cancel + +
diff --git a/src/views/StartView.vue b/src/views/StartView.vue index e73256ff1..04558e378 100644 --- a/src/views/StartView.vue +++ b/src/views/StartView.vue @@ -23,36 +23,40 @@
-

- Do you want a new identifier of your own? -

-

- If you haven't used this before, click "Yes" to generate a new - identifier. -

-

- Only click "No" if you have a seed of 12 or 24 words generated - elsewhere. -

- - Yes, generate one - - - No, I have a seed - - - Derive new address from existing seed - +
+

+ Do you want a new identifier of your own? +

+

+ If you haven't used this before, click "Yes" to generate a new + identifier. +

+

+ Only click "No" if you have a seed of 12 or 24 words generated + elsewhere. +

+ + Yes, generate one + + +
-- 2.30.2 From 55da3d0b1cdf7ce5c487a35e8eb39130a6b504e9 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Tue, 26 Mar 2024 21:38:21 +0800 Subject: [PATCH 17/38] Map fix #2 --- src/views/SearchAreaView.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/views/SearchAreaView.vue b/src/views/SearchAreaView.vue index 4b3a7501e..e4d4444de 100644 --- a/src/views/SearchAreaView.vue +++ b/src/views/SearchAreaView.vue @@ -64,10 +64,11 @@ -
+
-- 2.30.2 From 4635c1ac481da1d98c016a4a573bf147fa0d2b87 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Wed, 27 Mar 2024 19:57:31 +0800 Subject: [PATCH 18/38] Feed filters dialog --- src/components/FeedFilters.vue | 190 +++++++++++++++++++++++++++++++++ src/views/HomeView.vue | 17 ++- 2 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 src/components/FeedFilters.vue diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue new file mode 100644 index 000000000..c711eb5d6 --- /dev/null +++ b/src/components/FeedFilters.vue @@ -0,0 +1,190 @@ + + + + + diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 4edf0b99a..e6172ce40 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -172,10 +172,19 @@ showGivenToUser="true" /> +
-

Latest Activity

+
+

Latest Activity

+ +
  • -- 2.30.2 From 7f66addfe313869d7b9019c1e7bbcfb4bd8ae8bc Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 29 Mar 2024 15:53:46 +0800 Subject: [PATCH 19/38] Filter options reduced for release --- src/components/FeedFilters.vue | 48 ---------------------------------- 1 file changed, 48 deletions(-) diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue index c711eb5d6..1f0541099 100644 --- a/src/components/FeedFilters.vue +++ b/src/components/FeedFilters.vue @@ -38,54 +38,6 @@
-
- -
From my projects
- -
- - - -
- -
-
-
- -
- -
Matched to my topics of interest
- -
- - - -
- -
-
-
- -
- -
Offers
- -
- - - -
- -
-
-
-
Nearby
-- 2.30.2 From cfd53bc186a98e47f8e394635dbcfc4cbb5dc50e Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 29 Mar 2024 15:55:16 +0800 Subject: [PATCH 20/38] Removed one more --- src/components/FeedFilters.vue | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue index 1f0541099..0b3cae5cd 100644 --- a/src/components/FeedFilters.vue +++ b/src/components/FeedFilters.vue @@ -6,22 +6,6 @@

Show only activities that are…

-
- -
From me
- -
- - - -
- -
-
-
-
From my contacts
-- 2.30.2 From 0b4f2484f75acd90a8c116522fd02e2cafbcf50a Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Fri, 29 Mar 2024 21:41:14 +0800 Subject: [PATCH 21/38] Additions to Account View --- src/views/AccountViewView.vue | 38 ++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index b1dd6e6fc..5f6c78e25 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -112,6 +112,8 @@
+ +
Settings
- + Troubleshoot your notification setup. + + + Set Search Area… + + + +
+ Topics of Interest +
+ +
+ Separate topics with a comma. +
-
Usage Limits
+
Usage Limits
Checking… @@ -200,7 +224,7 @@
-
Data Export
+
Data Export
Download Settings & Contacts @@ -221,7 +245,7 @@ If no download happened yet, click again here to download now. @@ -952,13 +976,13 @@ export default class AccountViewView extends Vue { public computedStartDownloadLinkClassNames() { return { - invisible: this.downloadUrl, + hidden: this.downloadUrl, }; } public computedDownloadLinkClassNames() { return { - invisible: !this.downloadUrl, + hidden: !this.downloadUrl, }; } -- 2.30.2 From 7692cc2b35238340f4f96a89831e18b2c54d047e Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Mon, 1 Apr 2024 19:04:54 -0600 Subject: [PATCH 22/38] add logic to send a time for notifications --- src/App.vue | 106 ++++++++++++++++++++++++++++++++++++++++------- src/libs/util.ts | 6 ++- src/main.ts | 4 ++ 3 files changed, 100 insertions(+), 16 deletions(-) diff --git a/src/App.vue b/src/App.vue index 63c3ebab7..d4f9aa0b6 100644 --- a/src/App.vue +++ b/src/App.vue @@ -191,7 +191,7 @@ >

- Would you like to turn on notifications for this app? + Would you like to be notified of new activity once a day?

Waiting for system initialization, which may take up to 10 @@ -199,22 +199,42 @@

- +
+ + Yes, tell me at: + + + AM + PM + + + +
@@ -297,8 +317,11 @@ diff --git a/src/views/SearchAreaView.vue b/src/views/SearchAreaView.vue index 4b3a7501e..e9c30e85e 100644 --- a/src/views/SearchAreaView.vue +++ b/src/views/SearchAreaView.vue @@ -208,9 +208,9 @@ export default class DiscoverView extends Vue { group: "alert", type: "success", title: "Saved", - text: "That has been saved in your preferences.", + text: "That has been saved in your preferences. You can now filter by it on your home screen feed.", }, - -1, + 7000, ); this.$router.back(); } catch (err) { @@ -246,6 +246,7 @@ export default class DiscoverView extends Vue { await db.open(); db.settings.update(MASTER_SETTINGS_KEY, { searchBoxes: [], + filterFeedNearby: false, }); this.searchBox = null; this.localCenterLat = 0; -- 2.30.2 From 640d2736468fe2d514fbfb3989af02b9a40bea72 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Sat, 6 Apr 2024 14:01:18 -0600 Subject: [PATCH 29/38] filter by selections (now all working), add cache for plans --- babel.config.js | 1 + package-lock.json | 149 ++++++++++++++++++++++++++-- package.json | 1 + project.task.yaml | 5 +- src/components/FeedFilters.vue | 50 +++++----- src/db/tables/settings.ts | 8 +- src/libs/endorserServer.ts | 94 +++++++++++++++--- src/libs/util.ts | 14 +-- src/views/ContactAmountsView.vue | 10 +- src/views/ContactsView.vue | 4 +- src/views/HomeView.vue | 113 ++++++++++++++++----- src/views/ProjectViewView.vue | 30 +++--- src/views/ProjectsView.vue | 4 +- src/views/QuickActionBvcEndView.vue | 6 +- src/views/SearchAreaView.vue | 2 +- 15 files changed, 384 insertions(+), 107 deletions(-) diff --git a/babel.config.js b/babel.config.js index 162a3ea97..cfbc57158 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,3 +1,4 @@ module.exports = { + plugins: ["@babel/plugin-transform-private-methods"], presets: ["@vue/cli-plugin-babel/preset"], }; diff --git a/package-lock.json b/package-lock.json index 1cbcd8ad3..4c5c5683f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,6 +42,7 @@ "js-generate-password": "^0.1.9", "js-yaml": "^4.1.0", "localstorage-slim": "^2.5.0", + "lru-cache": "^10.2.0", "luxon": "^3.4.4", "merkletreejs": "^0.3.11", "moment": "^2.29.4", @@ -3052,6 +3053,18 @@ "integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==", "optional": true }, + "node_modules/@digitalcredentials/jsonld/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@digitalcredentials/keypair": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@digitalcredentials/keypair/-/keypair-1.0.5.tgz", @@ -3149,6 +3162,18 @@ "integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==", "optional": true }, + "node_modules/@digitalcredentials/vc-status-list/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", @@ -4317,6 +4342,19 @@ "node": ">=4" } }, + "node_modules/@expo/cli/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@expo/cli/node_modules/mimic-fn": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", @@ -4714,6 +4752,19 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/@expo/config/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@expo/config/node_modules/resolve-from": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", @@ -8912,6 +8963,18 @@ "node": ">=12" } }, + "node_modules/@transmute/jsonld/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@transmute/ld-key-pair": { "version": "0.7.0-unstable.81", "resolved": "https://registry.npmjs.org/@transmute/ld-key-pair/-/ld-key-pair-0.7.0-unstable.81.tgz", @@ -9674,6 +9737,18 @@ "integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==", "optional": true }, + "node_modules/@veramo-community/lds-ecdsa-secp256k1-recovery2020/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@veramo/core": { "version": "5.5.3", "resolved": "https://registry.npmjs.org/@veramo/core/-/core-5.5.3.tgz", @@ -10378,6 +10453,18 @@ "node": ">=8" } }, + "node_modules/@vue/cli-shared-utils/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@vue/cli-shared-utils/node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -12425,6 +12512,19 @@ "node": ">= 10" } }, + "node_modules/cacache/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/cacache/node_modules/mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", @@ -17014,6 +17114,19 @@ "node": ">=10" } }, + "node_modules/hosted-git-info/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "peer": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/hpack.js": { "version": "2.1.6", "resolved": "https://registry.npmjs.org/hpack.js/-/hpack.js-2.1.6.tgz", @@ -19269,6 +19382,18 @@ "integrity": "sha512-0CNTVCLZggSh7bc5VkX5WWPWO+cyZbNd07IHIsSXLia/eAq+r836hgk+8BKoEh7949Mda87VUOitx5OddVj64A==", "optional": true }, + "node_modules/jsonld/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "optional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/jsonpointer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-5.0.1.tgz", @@ -20246,15 +20371,11 @@ } }, "node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "devOptional": true, - "dependencies": { - "yallist": "^4.0.0" - }, + "version": "10.2.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.2.0.tgz", + "integrity": "sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==", "engines": { - "node": ">=10" + "node": "14 || >=16.14" } }, "node_modules/luxon": { @@ -25124,6 +25245,18 @@ "node": ">=10" } }, + "node_modules/semver/node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "devOptional": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/send": { "version": "0.18.0", "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", diff --git a/package.json b/package.json index 5425d2423..2487cff75 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "js-generate-password": "^0.1.9", "js-yaml": "^4.1.0", "localstorage-slim": "^2.5.0", + "lru-cache": "^10.2.0", "luxon": "^3.4.4", "merkletreejs": "^0.3.11", "moment": "^2.29.4", diff --git a/project.task.yaml b/project.task.yaml index d111576c6..c8db872c0 100644 --- a/project.task.yaml +++ b/project.task.yaml @@ -1,10 +1,13 @@ tasks : +- fix the notification link to the app - 24 contextual tutorials https://docs.google.com/document/d/11C_K3RM0rgo0onih20KFhcIzukZyq_CRWqaWX5om_kM/edit#heading=h.iwiwcydou5hw - 24 Move to Vite +- feeds - add "remote" filter, if they choose 'visible' then warn that they won't see any others, cache list & don't reload front page on change + - .1 add KindSpring link to ideas - .1 on feed, don't show "to someone anonymous" if it's to a project - .1 on ideas, put an "x" to close it assignee-group:ui @@ -122,7 +125,7 @@ tasks : - 08 convert to cleaner implementation (maybe Drie -- https://github.com/janvorisek/drie) - .5 show seed phrase in a QR code for transfer to another device -- .5 on DiscoverView, switch to a filter UI (eg. just from friend +- .5 on DiscoverView, switch to a filter UI (eg. just from friend) - .5 don't show "Offer" on project screen if they aren't registered - 01 especially for iOS, check for new version & update, eg. https://stackoverflow.com/questions/52221805/any-way-yet-to-auto-update-or-just-clear-the-cache-on-a-pwa-on-ios diff --git a/src/components/FeedFilters.vue b/src/components/FeedFilters.vue index 669e9531e..a8b029af3 100644 --- a/src/components/FeedFilters.vue +++ b/src/components/FeedFilters.vue @@ -3,21 +3,21 @@

Feed Filters

-

Show only activities that are…

+

Show only activities that…

-
From my contacts
+
Include Someone Visible to Me
@@ -30,6 +30,8 @@
+ or +
-
Nearby
+
Are Nearby
@@ -109,20 +111,20 @@ import { db } from "@/db/index"; }, }) export default class FeedFilters extends Vue { - callOnCloseIfChanged = () => {}; + onCloseIfChanged = () => {}; hasSearchBox = false; - isInMyContacts = false; + hasVisibleDid = false; isNearby = false; settingChanged = false; visible = false; - async open(callOnCloseIfChanged: () => void) { - this.callOnCloseIfChanged = callOnCloseIfChanged; + async open(onCloseIfChanged: () => void) { + this.onCloseIfChanged = onCloseIfChanged; await db.open(); const settings = await db.settings.get(MASTER_SETTINGS_KEY); - this.isInMyContacts = !!settings?.filterFeedContacts; - this.isNearby = !!settings?.filterFeedNearby; + this.hasVisibleDid = !!settings?.filterFeedByVisible; + this.isNearby = !!settings?.filterFeedByNearby; if (settings?.searchBoxes && settings.searchBoxes.length > 0) { this.hasSearchBox = true; } @@ -131,11 +133,11 @@ export default class FeedFilters extends Vue { this.visible = true; } - toggleContacts() { + toggleHasVisibleDid() { this.settingChanged = true; - this.isInMyContacts = !this.isInMyContacts; + this.hasVisibleDid = !this.hasVisibleDid; db.settings.update(MASTER_SETTINGS_KEY, { - filterFeedContacts: this.isInMyContacts, + filterFeedByVisible: this.hasVisibleDid, }); } @@ -143,41 +145,41 @@ export default class FeedFilters extends Vue { this.settingChanged = true; this.isNearby = !this.isNearby; db.settings.update(MASTER_SETTINGS_KEY, { - filterFeedNearby: this.isNearby, + filterFeedByNearby: this.isNearby, }); } async clearAll() { - if (this.isInMyContacts || this.isNearby) { + if (this.hasVisibleDid || this.isNearby) { this.settingChanged = true; } db.settings.update(MASTER_SETTINGS_KEY, { - filterFeedNearby: false, - filterFeedContacts: false, + filterFeedByNearby: false, + filterFeedByVisible: false, }); - this.isInMyContacts = false; + this.hasVisibleDid = false; this.isNearby = false; } async setAll() { - if (!this.isInMyContacts || !this.isNearby) { + if (!this.hasVisibleDid || !this.isNearby) { this.settingChanged = true; } db.settings.update(MASTER_SETTINGS_KEY, { - filterFeedNearby: true, - filterFeedContacts: true, + filterFeedByNearby: true, + filterFeedByVisible: true, }); - this.isInMyContacts = true; + this.hasVisibleDid = true; this.isNearby = true; } close() { if (this.settingChanged) { - this.callOnCloseIfChanged(); + this.onCloseIfChanged(); } this.visible = false; } diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts index 479ee637c..dbc4cf0c9 100644 --- a/src/db/tables/settings.ts +++ b/src/db/tables/settings.ts @@ -17,8 +17,8 @@ export type Settings = { activeDid?: string; // Active Decentralized ID apiServer?: string; // API server URL - filterFeedNearby?: string; // filter by nearby - filterFeedContacts?: string; // filter by user contacts + filterFeedByNearby?: boolean; // filter by nearby + filterFeedByVisible?: boolean; // filter by visible users ie. anyone not hidden firstName?: string; // User's first name isRegistered?: boolean; @@ -42,6 +42,10 @@ export type Settings = { webPushServer?: string; // Web Push server URL }; +export function isAnyFeedFilterOn(settings: Settings): boolean { + return !!(settings.filterFeedByNearby || settings.filterFeedByVisible); +} + /** * Schema for the Settings table in the database. */ diff --git a/src/libs/endorserServer.ts b/src/libs/endorserServer.ts index 5972708ca..b1676e9fb 100644 --- a/src/libs/endorserServer.ts +++ b/src/libs/endorserServer.ts @@ -1,9 +1,11 @@ +import { Axios, AxiosResponse, RawAxiosRequestHeaders } from "axios"; +import * as didJwt from "did-jwt"; +import { LRUCache } from "lru-cache"; import * as R from "ramda"; import { IIdentifier } from "@veramo/core"; -import { accessToken, SimpleSigner } from "@/libs/crypto"; -import * as didJwt from "did-jwt"; -import { Axios, AxiosResponse } from "axios"; + import { Contact } from "@/db/tables/contacts"; +import { accessToken, SimpleSigner } from "@/libs/crypto"; export const SCHEMA_ORG_CONTEXT = "https://schema.org"; // the object in RegisterAction claims @@ -49,7 +51,7 @@ export interface GenericVerifiableCredential { [key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any } -export interface GenericServerRecord extends GenericVerifiableCredential { +export interface GenericCredWrapper extends GenericVerifiableCredential { handleId?: string; id: string; issuedAt: string; @@ -58,7 +60,7 @@ export interface GenericServerRecord extends GenericVerifiableCredential { claim: Record; claimType?: string; } -export const BLANK_GENERIC_SERVER_RECORD: GenericServerRecord = { +export const BLANK_GENERIC_SERVER_RECORD: GenericCredWrapper = { "@context": SCHEMA_ORG_CONTEXT, "@type": "", claim: {}, @@ -68,7 +70,7 @@ export const BLANK_GENERIC_SERVER_RECORD: GenericServerRecord = { }; // a summary record; the VC is found the fullClaim field -export interface GiveServerRecord { +export interface GiveSummaryRecord { agentDid: string; amount: number; amountConfirmed: number; @@ -83,7 +85,7 @@ export interface GiveServerRecord { } // a summary record; the VC is found the fullClaim field -export interface OfferServerRecord { +export interface OfferSummaryRecord { amount: number; amountGiven: number; amountGivenConfirmed: number; @@ -101,7 +103,7 @@ export interface OfferServerRecord { } // a summary record; the VC is not currently part of this record -export interface PlanServerRecord { +export interface PlanSummaryRecord { agentDid?: string; // optional, if the issuer wants someone else to manage as well description: string; endTime?: string; @@ -256,6 +258,10 @@ export type CreateAndSubmitClaimResult = SuccessResult | ErrorResult; // See https://github.com/trentlarson/endorser-ch/blob/0cb626f803028e7d9c67f095858a9fc8542e3dbd/server/api/services/util.js#L6 const HIDDEN_DID = "did:none:HIDDEN"; +const planCache: LRUCache = new LRUCache({ + max: 500, +}); + export function isDid(did: string) { return did.startsWith("did:"); } @@ -269,7 +275,7 @@ export function isEmptyOrHiddenDid(did?: string) { } /** - * @return true for any nested string where func(input) === true + * @return true for any string within this primitive/object/array where func(input) === true * * Similar logic is found in endorser-mobile. */ @@ -304,6 +310,12 @@ export function containsHiddenDid(obj: any) { return testRecursivelyOnStrings(isHiddenDid, obj); } +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const containsNonHiddenDid = (obj: any) => { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + return testRecursivelyOnStrings((s: any) => isDid(s) && !isHiddenDid(s), obj); +}; + export function stripEndorserPrefix(claimId: string) { if (claimId && claimId.startsWith(ENDORSER_CH_HANDLE_PREFIX)) { return claimId.substring(ENDORSER_CH_HANDLE_PREFIX.length); @@ -423,6 +435,62 @@ export function didInfo( return didInfoForContact(did, activeDid, contact, allMyDids).displayName; } +async function getHeaders(identity: IIdentifier) { + const headers: RawAxiosRequestHeaders = { + "Content-Type": "application/json", + }; + if (identity) { + const token = await accessToken(identity); + headers["Authorization"] = "Bearer " + token; + } + return headers; +} + +export async function getPlanFromCache( + handleId: string, + identity: IIdentifier, + axios: Axios, + apiServer: string, +) { + let cred = planCache.get(handleId); + if (!cred) { + const url = + apiServer + + "/api/v2/report/plans?handleId=" + + encodeURIComponent(handleId); + const headers = await getHeaders(identity); + try { + const resp = await axios.get(url, { headers }); + if (resp.status === 200 && resp.data?.data?.length > 0) { + cred = resp.data.data[0]; + planCache.set(handleId, cred); + } else { + console.log( + "Failed to load plan with handle", + handleId, + " Got data:", + resp.data, + ); + } + } catch (error) { + console.log( + "Failed to load plan with handle", + handleId, + " Got error:", + error, + ); + } + } + return cred; +} + +export async function setPlanInCache( + handleId: string, + planSummary: PlanSummaryRecord, +) { + planCache.set(handleId, planSummary); +} + /** * For result, see https://api.endorser.ch/api-docs/#/claims/post_api_v2_claim * @@ -475,7 +543,7 @@ export async function createAndSubmitGive( vcClaim.image = imageUrl; } return createAndSubmitClaim( - vcClaim as GenericServerRecord, + vcClaim as GenericCredWrapper, identity, apiServer, axios, @@ -524,7 +592,7 @@ export async function createAndSubmitOffer( }; } return createAndSubmitClaim( - vcClaim as GenericServerRecord, + vcClaim as GenericCredWrapper, identity, apiServer, axios, @@ -695,7 +763,7 @@ const claimSummary = (claim: Record) => { similar code is also contained in endorser-mobile **/ export const claimSpecialDescription = ( - record: GenericServerRecord, + record: GenericCredWrapper, activeDid: string, identifiers: Array, contacts: Array, @@ -789,7 +857,7 @@ export const claimSpecialDescription = ( "...]" ); } else { - return issuer + " declared " + claimSummary(claim as GenericServerRecord); + return issuer + " declared " + claimSummary(claim as GenericCredWrapper); } }; diff --git a/src/libs/util.ts b/src/libs/util.ts index 1a613df8c..f85f550f8 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -9,7 +9,7 @@ import { accountsDB, db } from "@/db/index"; import { Account } from "@/db/tables/accounts"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { deriveAddress, generateSeed, newIdentifier } from "@/libs/crypto"; -import { GenericServerRecord, containsHiddenDid } from "@/libs/endorserServer"; +import { GenericCredWrapper, containsHiddenDid } from "@/libs/endorserServer"; import * as serverUtil from "@/libs/endorserServer"; // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -69,7 +69,7 @@ export const isGlobalUri = (uri: string) => { return uri && uri.match(new RegExp(/^[A-Za-z][A-Za-z0-9+.-]+:/)); }; -export const giveIsConfirmable = (veriClaim: GenericServerRecord) => { +export const giveIsConfirmable = (veriClaim: GenericCredWrapper) => { return veriClaim.claimType === "GiveAction"; }; @@ -85,7 +85,7 @@ export const doCopyTwoSecRedo = (text: string, fn: () => void) => { * @param veriClaim is expected to have fields: claim, claimType, and issuer */ export const isGiveRecordTheUserCanConfirm = ( - veriClaim: GenericServerRecord, + veriClaim: GenericCredWrapper, activeDid: string, confirmerIdList: string[] = [], ) => { @@ -101,9 +101,9 @@ export const isGiveRecordTheUserCanConfirm = ( * @returns the DID of the person who offered, or undefined if hidden * @param veriClaim is expected to have fields: claim and issuer */ -export const offerGiverDid: ( - arg0: GenericServerRecord, -) => string | undefined = (veriClaim) => { +export const offerGiverDid: (arg0: GenericCredWrapper) => string | undefined = ( + veriClaim, +) => { let giver; if ( veriClaim.claim.offeredBy?.identifier && @@ -120,7 +120,7 @@ export const offerGiverDid: ( * @returns true if the user can fulfill the offer * @param veriClaim is expected to have fields: claim, claimType, and issuer */ -export const canFulfillOffer = (veriClaim: GenericServerRecord) => { +export const canFulfillOffer = (veriClaim: GenericCredWrapper) => { return !!(veriClaim.claimType === "Offer" && offerGiverDid(veriClaim)); }; diff --git a/src/views/ContactAmountsView.vue b/src/views/ContactAmountsView.vue index a6fc0ff98..1d3654ab7 100644 --- a/src/views/ContactAmountsView.vue +++ b/src/views/ContactAmountsView.vue @@ -119,7 +119,7 @@ import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { accessToken, SimpleSigner } from "@/libs/crypto"; import { AgreeVerifiableCredential, - GiveServerRecord, + GiveSummaryRecord, GiveVerifiableCredential, SCHEMA_ORG_CONTEXT, } from "@/libs/endorserServer"; @@ -131,7 +131,7 @@ export default class ContactAmountssView extends Vue { activeDid = ""; apiServer = ""; contact: Contact | null = null; - giveRecords: Array = []; + giveRecords: Array = []; numAccounts = 0; async beforeCreate() { @@ -197,7 +197,7 @@ export default class ContactAmountssView extends Vue { async loadGives(activeDid: string, contact: Contact) { try { const identity = await this.getIdentity(this.activeDid); - let result: Array = []; + let result: Array = []; const url = this.apiServer + "/api/v2/report/gives?agentDid=" + @@ -252,7 +252,7 @@ export default class ContactAmountssView extends Vue { ); } - const sortedResult: Array = R.sort( + const sortedResult: Array = R.sort( (a, b) => new Date(b.issuedAt).getTime() - new Date(a.issuedAt).getTime(), result, @@ -271,7 +271,7 @@ export default class ContactAmountssView extends Vue { } } - async confirm(record: GiveServerRecord) { + async confirm(record: GiveSummaryRecord) { // Make claim // I use clone here because otherwise it gets a Proxy object. // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/views/ContactsView.vue b/src/views/ContactsView.vue index 8384163dc..2bf4a9a8c 100644 --- a/src/views/ContactsView.vue +++ b/src/views/ContactsView.vue @@ -303,7 +303,7 @@ import { import { CONTACT_CSV_HEADER, CONTACT_URL_PREFIX, - GiveServerRecord, + GiveSummaryRecord, GiveVerifiableCredential, isDid, RegisterVerifiableCredential, @@ -410,7 +410,7 @@ export default class ContactsView extends Vue { } const handleResponse = ( - resp: { status: number; data: { data: GiveServerRecord[] } }, + resp: { status: number; data: { data: GiveSummaryRecord[] } }, descriptions: Record, confirmed: Record, unconfirmed: Record, diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 419415173..57dca406e 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -247,11 +247,17 @@ Loading…

+
+

+ No claims match your filters. +

+