Merge branch 'master' into ios-contact-copy
This commit is contained in:
65
src/App.vue
65
src/App.vue
@@ -27,9 +27,13 @@
|
||||
v-if="notification.type === 'toast'"
|
||||
class="w-full max-w-sm mx-auto mb-3 overflow-hidden bg-slate-900/90 text-white rounded-lg shadow-md"
|
||||
>
|
||||
<div class="w-full px-4 py-3">
|
||||
<span class="font-semibold">{{ notification.title }}</span>
|
||||
<p class="text-sm">{{ notification.text }}</p>
|
||||
<div class="w-full px-4 py-3 overflow-hidden">
|
||||
<h4 class="font-semibold text-ellipsis overflow-hidden">
|
||||
{{ notification.title }}
|
||||
</h4>
|
||||
<p class="text-sm text-ellipsis overflow-hidden">
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -46,9 +50,15 @@
|
||||
></font-awesome>
|
||||
</div>
|
||||
|
||||
<div class="relative w-full pl-4 pr-8 py-2 text-slate-900">
|
||||
<span class="font-semibold">{{ notification.title }}</span>
|
||||
<p class="text-sm">{{ truncateLongWords(notification.text) }}</p>
|
||||
<div
|
||||
class="relative w-full pl-4 pr-8 py-2 text-slate-900 overflow-hidden"
|
||||
>
|
||||
<h4 class="font-semibold text-ellipsis overflow-hidden">
|
||||
{{ notification.title }}
|
||||
</h4>
|
||||
<p class="text-sm text-ellipsis overflow-hidden">
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
class="absolute top-2 right-2 px-0.5 py-0 rounded-full bg-slate-200 text-slate-600"
|
||||
@@ -72,9 +82,15 @@
|
||||
></font-awesome>
|
||||
</div>
|
||||
|
||||
<div class="relative w-full pl-4 pr-8 py-2 text-emerald-900">
|
||||
<span class="font-semibold">{{ notification.title }}</span>
|
||||
<p class="text-sm">{{ truncateLongWords(notification.text) }}</p>
|
||||
<div
|
||||
class="relative w-full pl-4 pr-8 py-2 text-emerald-900 overflow-hidden"
|
||||
>
|
||||
<h4 class="font-semibold text-ellipsis overflow-hidden">
|
||||
{{ notification.title }}
|
||||
</h4>
|
||||
<p class="text-sm text-ellipsis overflow-hidden">
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
class="absolute top-2 right-2 px-0.5 py-0 rounded-full bg-emerald-200 text-emerald-600"
|
||||
@@ -98,9 +114,15 @@
|
||||
></font-awesome>
|
||||
</div>
|
||||
|
||||
<div class="relative w-full pl-4 pr-8 py-2 text-amber-900">
|
||||
<span class="font-semibold">{{ notification.title }}</span>
|
||||
<p class="text-sm">{{ truncateLongWords(notification.text) }}</p>
|
||||
<div
|
||||
class="relative w-full pl-4 pr-8 py-2 text-amber-900 overflow-hidden"
|
||||
>
|
||||
<h4 class="font-semibold text-ellipsis overflow-hidden">
|
||||
{{ notification.title }}
|
||||
</h4>
|
||||
<p class="text-sm text-ellipsis overflow-hidden">
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
class="absolute top-2 right-2 px-0.5 py-0 rounded-full bg-amber-200 text-amber-600"
|
||||
@@ -124,9 +146,15 @@
|
||||
></font-awesome>
|
||||
</div>
|
||||
|
||||
<div class="relative w-full pl-4 pr-8 py-2 text-rose-900">
|
||||
<span class="font-semibold">{{ notification.title }}</span>
|
||||
<p class="text-sm">{{ truncateLongWords(notification.text) }}</p>
|
||||
<div
|
||||
class="relative w-full pl-4 pr-8 py-2 text-rose-900 overflow-hidden"
|
||||
>
|
||||
<h4 class="font-semibold text-ellipsis overflow-hidden">
|
||||
{{ notification.title }}
|
||||
</h4>
|
||||
<p class="text-sm text-ellipsis overflow-hidden">
|
||||
{{ notification.text }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
class="absolute top-2 right-2 px-0.5 py-0 rounded-full bg-rose-200 text-rose-600"
|
||||
@@ -349,13 +377,6 @@ export default class App extends Vue {
|
||||
|
||||
stopAsking = false;
|
||||
|
||||
truncateLongWords(sentence: string) {
|
||||
return sentence
|
||||
.split(" ")
|
||||
.map((word) => (word.length > 30 ? word.slice(0, 30) + "..." : word))
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
async turnOffNotifications(
|
||||
notification: NotificationIface,
|
||||
): Promise<boolean> {
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
{
|
||||
"warning": {
|
||||
"fillRule": "evenodd",
|
||||
"d": "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",
|
||||
"clipRule": "evenodd"
|
||||
},
|
||||
"spinner": {
|
||||
"d": "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
||||
},
|
||||
"chart": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
|
||||
},
|
||||
"plus": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M12 4v16m8-8H4"
|
||||
},
|
||||
"settings": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"
|
||||
},
|
||||
"settingsDot": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M15 12a3 3 0 11-6 0 3 3 0 016 0z"
|
||||
},
|
||||
"lock": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"
|
||||
},
|
||||
"download": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
||||
},
|
||||
"check": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
},
|
||||
"edit": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"
|
||||
},
|
||||
"trash": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"
|
||||
},
|
||||
"plusCircle": {
|
||||
"strokeLinecap": "round",
|
||||
"strokeLinejoin": "round",
|
||||
"strokeWidth": "2",
|
||||
"d": "M12 6v6m0 0v6m0-6h6m-6 0H6"
|
||||
},
|
||||
"info": {
|
||||
"fillRule": "evenodd",
|
||||
"d": "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z",
|
||||
"clipRule": "evenodd"
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,6 @@
|
||||
class="w-full h-auto max-w-lg max-h-96 object-contain mx-auto drop-shadow-md"
|
||||
:src="record.image"
|
||||
alt="Activity image"
|
||||
@load="handleImageLoad(record.image)"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
@@ -253,7 +252,7 @@ import { GiveRecordWithContactInfo } from "@/interfaces/give";
|
||||
import EntityIcon from "./EntityIcon.vue";
|
||||
import { isHiddenDid } from "../libs/endorserServer";
|
||||
import ProjectIcon from "./ProjectIcon.vue";
|
||||
import { createNotifyHelpers } from "@/utils/notify";
|
||||
import { createNotifyHelpers, NotifyFunction } from "@/utils/notify";
|
||||
import {
|
||||
NOTIFY_PERSON_HIDDEN,
|
||||
NOTIFY_UNKNOWN_PERSON,
|
||||
@@ -272,16 +271,9 @@ export default class ActivityListItem extends Vue {
|
||||
@Prop() isRegistered!: boolean;
|
||||
@Prop() activeDid!: string;
|
||||
|
||||
/**
|
||||
* Function prop for handling image caching
|
||||
* Called when an image loads successfully, allowing parent to control caching behavior
|
||||
*/
|
||||
@Prop({ type: Function, default: () => {} })
|
||||
onImageCache!: (imageUrl: string) => void | Promise<void>;
|
||||
|
||||
isHiddenDid = isHiddenDid;
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
$notify!: (notification: any, timeout?: number) => void;
|
||||
$notify!: NotifyFunction;
|
||||
|
||||
created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
@@ -295,17 +287,8 @@ export default class ActivityListItem extends Vue {
|
||||
this.notify.warning(NOTIFY_UNKNOWN_PERSON.message, TIMEOUTS.STANDARD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle image load event - call function prop for caching
|
||||
* Allows parent to control caching behavior and validation
|
||||
*/
|
||||
handleImageLoad(imageUrl: string): void {
|
||||
this.onImageCache(imageUrl);
|
||||
}
|
||||
|
||||
get fetchAmount(): string {
|
||||
const claim =
|
||||
(this.record.fullClaim as any)?.claim || this.record.fullClaim;
|
||||
const claim = this.record.fullClaim;
|
||||
|
||||
const amount = claim.object?.amountOfThisGood
|
||||
? this.displayAmount(claim.object.unitCode, claim.object.amountOfThisGood)
|
||||
@@ -315,8 +298,7 @@ export default class ActivityListItem extends Vue {
|
||||
}
|
||||
|
||||
get description(): string {
|
||||
const claim =
|
||||
(this.record.fullClaim as any)?.claim || this.record.fullClaim;
|
||||
const claim = this.record.fullClaim;
|
||||
|
||||
return `${claim?.description || ""}`;
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ export default class ContactInputForm extends Vue {
|
||||
*/
|
||||
@Emit("qr-scan")
|
||||
private handleQRScan(): void {
|
||||
console.log("[ContactInputForm] QR scan button clicked");
|
||||
// QR scan button clicked - event emitted for parent handling
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -171,6 +171,8 @@ export default class DataExportSection extends Vue {
|
||||
* @throws {Error} If export fails
|
||||
*/
|
||||
public async exportDatabase(): Promise<void> {
|
||||
// Note that similar code is in ContactsView.vue exportContactData()
|
||||
|
||||
if (this.isExporting) {
|
||||
return; // Prevent multiple simultaneous exports
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ import EntitySelectionStep from "../components/EntitySelectionStep.vue";
|
||||
import GiftDetailsStep from "../components/GiftDetailsStep.vue";
|
||||
import { PlanData } from "../interfaces/records";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "@/utils/notify";
|
||||
import {
|
||||
NOTIFY_GIFT_ERROR_NEGATIVE_AMOUNT,
|
||||
NOTIFY_GIFT_ERROR_NO_DESCRIPTION,
|
||||
@@ -98,7 +98,7 @@ import {
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class GiftedDialog extends Vue {
|
||||
$notify!: (notification: any, timeout?: number) => void;
|
||||
$notify!: NotifyFunction;
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
|
||||
/**
|
||||
@@ -622,7 +622,10 @@ export default class GiftedDialog extends Vue {
|
||||
* Handle edit entity request from GiftDetailsStep
|
||||
* @param data - Object containing entityType and currentEntity
|
||||
*/
|
||||
handleEditEntity(data: { entityType: string; currentEntity: any }) {
|
||||
handleEditEntity(data: {
|
||||
entityType: string;
|
||||
currentEntity: { did: string; name: string };
|
||||
}) {
|
||||
this.goBackToStep1(data.entityType);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<template>
|
||||
<svg
|
||||
v-if="iconData"
|
||||
:class="svgClass"
|
||||
:fill="fill"
|
||||
:stroke="stroke"
|
||||
:viewBox="viewBox"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path v-for="(path, index) in iconData.paths" :key="index" v-bind="path" />
|
||||
</svg>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { Component, Prop, Vue } from "vue-facing-decorator";
|
||||
import icons from "../assets/icons.json";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
/**
|
||||
* Icon path interface
|
||||
*/
|
||||
interface IconPath {
|
||||
d: string;
|
||||
fillRule?: string;
|
||||
clipRule?: string;
|
||||
strokeLinecap?: string;
|
||||
strokeLinejoin?: string;
|
||||
strokeWidth?: string | number;
|
||||
fill?: string;
|
||||
stroke?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon data interface
|
||||
*/
|
||||
interface IconData {
|
||||
paths: IconPath[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Icons JSON structure
|
||||
*/
|
||||
interface IconsJson {
|
||||
[key: string]: IconPath | IconData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icon Renderer Component
|
||||
*
|
||||
* This component loads SVG icon definitions from a JSON file and renders them
|
||||
* as SVG elements. It provides a clean way to use icons without cluttering
|
||||
* templates with long SVG path definitions.
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
* @version 1.0.0
|
||||
* @since 2024
|
||||
*/
|
||||
@Component({
|
||||
name: "IconRenderer",
|
||||
})
|
||||
export default class IconRenderer extends Vue {
|
||||
@Prop({ required: true }) readonly iconName!: string;
|
||||
@Prop({ default: "h-5 w-5" }) readonly svgClass!: string;
|
||||
@Prop({ default: "none" }) readonly fill!: string;
|
||||
@Prop({ default: "currentColor" }) readonly stroke!: string;
|
||||
@Prop({ default: "0 0 24 24" }) readonly viewBox!: string;
|
||||
|
||||
/**
|
||||
* Get the icon data for the specified icon name
|
||||
*
|
||||
* @returns {IconData | null} The icon data object or null if not found
|
||||
*/
|
||||
get iconData(): IconData | null {
|
||||
const icon = (icons as IconsJson)[this.iconName];
|
||||
if (!icon) {
|
||||
logger.warn(`Icon "${this.iconName}" not found in icons.json`);
|
||||
return null;
|
||||
}
|
||||
|
||||
// Convert single path to array format for consistency
|
||||
if ("d" in icon) {
|
||||
return {
|
||||
paths: [icon as IconPath],
|
||||
};
|
||||
}
|
||||
|
||||
return icon as IconData;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -282,7 +282,7 @@ import {
|
||||
NOTIFY_IMAGE_DIALOG_UNSUPPORTED_FORMAT,
|
||||
createImageDialogCameraErrorMessage,
|
||||
} from "../constants/notifications";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "../utils/notify";
|
||||
import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "../utils/notify";
|
||||
|
||||
const inputImageFileNameRef = ref<Blob>();
|
||||
|
||||
@@ -291,7 +291,7 @@ const inputImageFileNameRef = ref<Blob>();
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class ImageMethodDialog extends Vue {
|
||||
$notify!: (notification: any, timeout?: number) => void;
|
||||
$notify!: NotifyFunction;
|
||||
$router!: Router;
|
||||
notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ import { logger } from "../utils/logger";
|
||||
@Component({ emits: ["update:isOpen"] })
|
||||
export default class ImageViewer extends Vue {
|
||||
@Prop() imageUrl!: string;
|
||||
@Prop() imageData!: Blob | null;
|
||||
@Prop() isOpen!: boolean;
|
||||
|
||||
userAgent = new UAParser();
|
||||
|
||||
@@ -83,6 +83,7 @@
|
||||
<script lang="ts">
|
||||
import { Component, Vue, Prop } from "vue-facing-decorator";
|
||||
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
|
||||
import { EndorserRateLimits, ImageRateLimits } from "@/interfaces/limits";
|
||||
|
||||
@Component({
|
||||
name: "UsageLimitsSection",
|
||||
@@ -94,8 +95,8 @@ export default class UsageLimitsSection extends Vue {
|
||||
@Prop({ required: true }) loadingLimits!: boolean;
|
||||
@Prop({ required: true }) limitsMessage!: string;
|
||||
@Prop({ required: false }) activeDid?: string;
|
||||
@Prop({ required: false }) endorserLimits?: any;
|
||||
@Prop({ required: false }) imageLimits?: any;
|
||||
@Prop({ required: false }) endorserLimits?: EndorserRateLimits;
|
||||
@Prop({ required: false }) imageLimits?: ImageRateLimits;
|
||||
@Prop({ required: true }) onRecheckLimits!: () => void;
|
||||
|
||||
mounted() {
|
||||
|
||||
@@ -846,6 +846,12 @@ export const NOTIFY_CONTACTS_ADDED = {
|
||||
message: "They were added.",
|
||||
};
|
||||
|
||||
// Used in: ContactsView.vue (addContact method - export data prompt after contact addition)
|
||||
export const NOTIFY_EXPORT_DATA_PROMPT = {
|
||||
title: "Export Your Data",
|
||||
message: "Would you like to export your contact data as a backup?",
|
||||
};
|
||||
|
||||
// Used in: ContactsView.vue (showCopySelectionsInfo method - info about copying contacts)
|
||||
export const NOTIFY_CONTACT_INFO_COPY = {
|
||||
title: "Info",
|
||||
@@ -1588,7 +1594,7 @@ export function createImageDialogCameraErrorMessage(error: Error): string {
|
||||
|
||||
// Helper function for dynamic upload error messages
|
||||
// Used in: ImageMethodDialog.vue (uploadImage method - dynamic upload error message)
|
||||
export function createImageDialogUploadErrorMessage(error: any): string {
|
||||
export function createImageDialogUploadErrorMessage(error: unknown): string {
|
||||
if (axios.isAxiosError(error)) {
|
||||
const status = error.response?.status;
|
||||
const data = error.response?.data;
|
||||
|
||||
@@ -98,3 +98,81 @@ export interface VerifiableCredentialClaim {
|
||||
credentialSubject: ClaimObject;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database constraint error types for consistent error handling
|
||||
*/
|
||||
export interface DatabaseConstraintError extends Error {
|
||||
name: "ConstraintError";
|
||||
message: string;
|
||||
constraint?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database storage error types for IndexedDB/SQLite operations
|
||||
*/
|
||||
export interface DatabaseStorageError extends Error {
|
||||
name: "StorageError";
|
||||
message: string;
|
||||
code?: string;
|
||||
constraint?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy Dexie error types for migration compatibility
|
||||
*/
|
||||
export interface DexieError extends Error {
|
||||
name: string;
|
||||
message: string;
|
||||
inner?: unknown;
|
||||
stack?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for database constraint errors
|
||||
*/
|
||||
export function isDatabaseConstraintError(
|
||||
error: unknown,
|
||||
): error is DatabaseConstraintError {
|
||||
return error instanceof Error && error.name === "ConstraintError";
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for database storage errors
|
||||
*/
|
||||
export function isDatabaseStorageError(
|
||||
error: unknown,
|
||||
): error is DatabaseStorageError {
|
||||
return error instanceof Error && error.name === "StorageError";
|
||||
}
|
||||
|
||||
/**
|
||||
* Type guard for legacy Dexie errors
|
||||
*/
|
||||
export function isDexieError(error: unknown): error is DexieError {
|
||||
return (
|
||||
error instanceof Error &&
|
||||
(error.name === "DexieError" ||
|
||||
error.message.includes("Key already exists in the object store") ||
|
||||
error.message.includes("ConstraintError"))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unified error type for database operations
|
||||
*/
|
||||
export type DatabaseError =
|
||||
| DatabaseConstraintError
|
||||
| DatabaseStorageError
|
||||
| DexieError;
|
||||
|
||||
/**
|
||||
* Type guard for any database error
|
||||
*/
|
||||
export function isDatabaseError(error: unknown): error is DatabaseError {
|
||||
return (
|
||||
isDatabaseConstraintError(error) ||
|
||||
isDatabaseStorageError(error) ||
|
||||
isDexieError(error)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1348,12 +1348,12 @@ export async function createEndorserJwtVcFromClaim(
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a JWT for a RegisterAction claim.
|
||||
* Create a JWT for a RegisterAction claim, used for registrations & invites.
|
||||
*
|
||||
* @param activeDid - The DID of the user creating the invite
|
||||
* @param contact - The contact to register, with a 'did' field (all optional for invites)
|
||||
* @param identifier - The identifier for the invite, usually random
|
||||
* @param expiresIn - The number of seconds until the invite expires
|
||||
* @param contact - Optional - The contact to register, with a 'did' field (all optional for invites)
|
||||
* @param identifier - Optional - The identifier for the invite, usually random
|
||||
* @param expiresIn - Optional - The number of seconds until the invite expires
|
||||
* @returns The JWT for the RegisterAction claim
|
||||
*/
|
||||
export async function createInviteJwt(
|
||||
@@ -1367,7 +1367,7 @@ export async function createInviteJwt(
|
||||
"@type": "RegisterAction",
|
||||
agent: { identifier: activeDid },
|
||||
object: SERVICE_ID,
|
||||
identifier: identifier,
|
||||
identifier: identifier, // not sent if undefined
|
||||
};
|
||||
if (contact?.did) {
|
||||
vcClaim.participant = { identifier: contact.did };
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
faCameraRotate,
|
||||
faCaretDown,
|
||||
faChair,
|
||||
faChartLine,
|
||||
faCheck,
|
||||
faChevronDown,
|
||||
faChevronLeft,
|
||||
@@ -28,6 +29,7 @@ import {
|
||||
faCircle,
|
||||
faCircleCheck,
|
||||
faCircleInfo,
|
||||
faCirclePlus,
|
||||
faCircleQuestion,
|
||||
faCircleRight,
|
||||
faCircleUser,
|
||||
@@ -49,6 +51,7 @@ import {
|
||||
faFloppyDisk,
|
||||
faFolderOpen,
|
||||
faForward,
|
||||
faGear,
|
||||
faGift,
|
||||
faGlobe,
|
||||
faHammer,
|
||||
@@ -58,6 +61,7 @@ import {
|
||||
faHouseChimney,
|
||||
faImage,
|
||||
faImagePortrait,
|
||||
faInfo,
|
||||
faLeftRight,
|
||||
faLightbulb,
|
||||
faLink,
|
||||
@@ -72,8 +76,8 @@ import {
|
||||
faPersonCircleCheck,
|
||||
faPersonCircleQuestion,
|
||||
faPlus,
|
||||
faQuestion,
|
||||
faQrcode,
|
||||
faQuestion,
|
||||
faRightFromBracket,
|
||||
faRotate,
|
||||
faShareNodes,
|
||||
@@ -106,6 +110,7 @@ library.add(
|
||||
faCameraRotate,
|
||||
faCaretDown,
|
||||
faChair,
|
||||
faChartLine,
|
||||
faCheck,
|
||||
faChevronDown,
|
||||
faChevronLeft,
|
||||
@@ -114,6 +119,7 @@ library.add(
|
||||
faCircle,
|
||||
faCircleCheck,
|
||||
faCircleInfo,
|
||||
faCirclePlus,
|
||||
faCircleQuestion,
|
||||
faCircleRight,
|
||||
faCircleUser,
|
||||
@@ -135,6 +141,7 @@ library.add(
|
||||
faFloppyDisk,
|
||||
faFolderOpen,
|
||||
faForward,
|
||||
faGear,
|
||||
faGift,
|
||||
faGlobe,
|
||||
faHammer,
|
||||
@@ -144,6 +151,7 @@ library.add(
|
||||
faHouseChimney,
|
||||
faImage,
|
||||
faImagePortrait,
|
||||
faInfo,
|
||||
faLeftRight,
|
||||
faLightbulb,
|
||||
faLink,
|
||||
|
||||
@@ -82,6 +82,15 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: "database-migration",
|
||||
component: () => import("../views/DatabaseMigration.vue"),
|
||||
},
|
||||
{
|
||||
path: "/deep-link-error",
|
||||
name: "deep-link-error",
|
||||
component: () => import("../views/DeepLinkErrorView.vue"),
|
||||
meta: {
|
||||
title: "Invalid Deep Link",
|
||||
requiresAuth: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/did/:did?",
|
||||
name: "did",
|
||||
@@ -276,15 +285,6 @@ const routes: Array<RouteRecordRaw> = [
|
||||
name: "user-profile",
|
||||
component: () => import("../views/UserProfileView.vue"),
|
||||
},
|
||||
{
|
||||
path: "/deep-link-error",
|
||||
name: "deep-link-error",
|
||||
component: () => import("../views/DeepLinkErrorView.vue"),
|
||||
meta: {
|
||||
title: "Invalid Deep Link",
|
||||
requiresAuth: false,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const isElectron = window.location.protocol === "file:";
|
||||
|
||||
99
src/services/QRNavigationService.ts
Normal file
99
src/services/QRNavigationService.ts
Normal file
@@ -0,0 +1,99 @@
|
||||
import { PlatformServiceFactory } from "./PlatformServiceFactory";
|
||||
import { PlatformService } from "./PlatformService";
|
||||
import { logger } from "@/utils/logger";
|
||||
|
||||
/**
|
||||
* QR Navigation Service
|
||||
*
|
||||
* Handles platform-specific routing logic for QR scanning operations.
|
||||
* Removes coupling between views and routing logic by centralizing
|
||||
* navigation decisions based on platform capabilities.
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
export class QRNavigationService {
|
||||
private static instance: QRNavigationService | null = null;
|
||||
private platformService: PlatformService;
|
||||
|
||||
private constructor() {
|
||||
this.platformService = PlatformServiceFactory.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get singleton instance of QRNavigationService
|
||||
*/
|
||||
public static getInstance(): QRNavigationService {
|
||||
if (!QRNavigationService.instance) {
|
||||
QRNavigationService.instance = new QRNavigationService();
|
||||
}
|
||||
return QRNavigationService.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate QR scanner route based on platform
|
||||
*
|
||||
* @returns Object with route name and parameters for QR scanning
|
||||
*/
|
||||
public getQRScannerRoute(): {
|
||||
name: string;
|
||||
params?: Record<string, string | number>;
|
||||
} {
|
||||
const isCapacitor = this.platformService.isCapacitor();
|
||||
|
||||
logger.debug("QR Navigation - Platform detection:", {
|
||||
isCapacitor,
|
||||
platform: this.platformService.getCapabilities(),
|
||||
});
|
||||
|
||||
if (isCapacitor) {
|
||||
// Use native scanner on mobile platforms
|
||||
return { name: "contact-qr-scan-full" };
|
||||
} else {
|
||||
// Use web scanner on other platforms
|
||||
return { name: "contact-qr" };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the appropriate QR display route based on platform
|
||||
*
|
||||
* @returns Object with route name and parameters for QR display
|
||||
*/
|
||||
public getQRDisplayRoute(): {
|
||||
name: string;
|
||||
params?: Record<string, string | number>;
|
||||
} {
|
||||
const isCapacitor = this.platformService.isCapacitor();
|
||||
|
||||
logger.debug("QR Navigation - Display route detection:", {
|
||||
isCapacitor,
|
||||
platform: this.platformService.getCapabilities(),
|
||||
});
|
||||
|
||||
if (isCapacitor) {
|
||||
// Use dedicated display view on mobile
|
||||
return { name: "contact-qr-scan-show" };
|
||||
} else {
|
||||
// Use combined view on web
|
||||
return { name: "contact-qr" };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if native QR scanning is available on current platform
|
||||
*
|
||||
* @returns true if native scanning is available, false otherwise
|
||||
*/
|
||||
public isNativeScanningAvailable(): boolean {
|
||||
return this.platformService.isCapacitor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get platform capabilities for QR operations
|
||||
*
|
||||
* @returns Platform capabilities object
|
||||
*/
|
||||
public getPlatformCapabilities() {
|
||||
return this.platformService.getCapabilities();
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ export class DeepLinkHandler {
|
||||
const validRoute = routeSchema.parse(path) as DeepLinkRoute;
|
||||
routeName = ROUTE_MAP[validRoute].name;
|
||||
} catch (error) {
|
||||
console.error(`[DeepLink] Invalid route path: ${path}`);
|
||||
logger.error(`[DeepLink] Invalid route path: ${path}`);
|
||||
|
||||
// Redirect to error page with information about the invalid link
|
||||
await this.router.replace({
|
||||
|
||||
@@ -693,7 +693,8 @@ export class WebPlatformService implements PlatformService {
|
||||
const setClause = keys.map((key) => `${key} = ?`).join(", ");
|
||||
const sql = `UPDATE settings SET ${setClause} WHERE accountDid = ?`;
|
||||
const params = [...keys.map((key) => settings[key]), did];
|
||||
console.log(
|
||||
// Log update operation for debugging
|
||||
logger.debug(
|
||||
"[WebPlatformService] updateDidSpecificSettings",
|
||||
sql,
|
||||
JSON.stringify(params, null, 2),
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
import axios from "axios";
|
||||
import * as didJwt from "did-jwt";
|
||||
import { SERVICE_ID } from "../libs/endorserServer";
|
||||
import { deriveAddress, newIdentifier } from "../libs/crypto";
|
||||
import {
|
||||
DEFAULT_ROOT_DERIVATION_PATH,
|
||||
deriveAddress,
|
||||
newIdentifier,
|
||||
} from "../libs/crypto";
|
||||
import { logger } from "../utils/logger";
|
||||
import { AppString } from "../constants/app";
|
||||
import { saveNewIdentity } from "@/libs/util";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
|
||||
const TEST_USER_0_MNEMONIC =
|
||||
"rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage";
|
||||
|
||||
export async function testBecomeUser0() {
|
||||
const [addr, privateHex, publicHex, deriPath] =
|
||||
deriveAddress(TEST_USER_0_MNEMONIC);
|
||||
|
||||
const identity0 = newIdentifier(addr, publicHex, privateHex, deriPath);
|
||||
await saveNewIdentity(
|
||||
identity0,
|
||||
TEST_USER_0_MNEMONIC,
|
||||
DEFAULT_ROOT_DERIVATION_PATH,
|
||||
);
|
||||
const platformService = await PlatformServiceFactory.getInstance();
|
||||
await platformService.updateDidSpecificSettings(identity0.did, {
|
||||
isRegistered: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get User #0 to sign & submit a RegisterAction for the user's activeDid.
|
||||
@@ -15,10 +40,8 @@ import { AppString } from "../constants/app";
|
||||
* @throws Error if registration fails or database access fails
|
||||
*/
|
||||
export async function testServerRegisterUser() {
|
||||
const testUser0Mnem =
|
||||
"seminar accuse mystery assist delay law thing deal image undo guard initial shallow wrestle list fragile borrow velvet tomorrow awake explain test offer control";
|
||||
|
||||
const [addr, privateHex, publicHex, deriPath] = deriveAddress(testUser0Mnem);
|
||||
const [addr, privateHex, publicHex, deriPath] =
|
||||
deriveAddress(TEST_USER_0_MNEMONIC);
|
||||
|
||||
const identity0 = newIdentifier(addr, publicHex, privateHex, deriPath);
|
||||
|
||||
@@ -32,9 +55,9 @@ export async function testServerRegisterUser() {
|
||||
const vcClaim = {
|
||||
"@context": "https://schema.org",
|
||||
"@type": "RegisterAction",
|
||||
agent: { did: identity0.did },
|
||||
agent: { identifier: identity0.did },
|
||||
object: SERVICE_ID,
|
||||
participant: { did: settings.activeDid },
|
||||
participant: { identifier: settings.activeDid },
|
||||
};
|
||||
|
||||
// Make a payload for the claim
|
||||
@@ -71,4 +94,5 @@ export async function testServerRegisterUser() {
|
||||
|
||||
const resp = await axios.post(url, payload, { headers });
|
||||
logger.log("User registration result:", resp);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
* Enhanced logger with self-contained database logging
|
||||
*
|
||||
* Provides comprehensive logging with console and database output.
|
||||
* Supports configurable log levels via VITE_LOG_LEVEL environment variable.
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
* @version 2.0.0
|
||||
* @version 2.1.0
|
||||
* @since 2025-01-25
|
||||
*/
|
||||
|
||||
@@ -46,6 +47,42 @@ export function safeStringify(obj: unknown) {
|
||||
const isElectron = process.env.VITE_PLATFORM === "electron";
|
||||
const isProduction = process.env.NODE_ENV === "production";
|
||||
|
||||
// Log level configuration via environment variable
|
||||
const LOG_LEVELS = {
|
||||
error: 0,
|
||||
warn: 1,
|
||||
info: 2,
|
||||
debug: 3,
|
||||
} as const;
|
||||
|
||||
type LogLevel = keyof typeof LOG_LEVELS;
|
||||
|
||||
// Parse VITE_LOG_LEVEL environment variable
|
||||
const getLogLevel = (): LogLevel => {
|
||||
const envLogLevel = process.env.VITE_LOG_LEVEL?.toLowerCase();
|
||||
|
||||
if (envLogLevel && envLogLevel in LOG_LEVELS) {
|
||||
return envLogLevel as LogLevel;
|
||||
}
|
||||
|
||||
// Default log levels based on environment
|
||||
if (isProduction && !isElectron) {
|
||||
return "warn"; // Production web: warnings and errors only
|
||||
} else if (isElectron) {
|
||||
return "error"; // Electron: errors only
|
||||
} else {
|
||||
return "info"; // Development/Capacitor: info and above
|
||||
}
|
||||
};
|
||||
|
||||
const currentLogLevel = getLogLevel();
|
||||
const currentLevelValue = LOG_LEVELS[currentLogLevel];
|
||||
|
||||
// Helper function to check if a log level should be displayed
|
||||
const shouldLog = (level: LogLevel): boolean => {
|
||||
return LOG_LEVELS[level] <= currentLevelValue;
|
||||
};
|
||||
|
||||
// Track initialization state to prevent circular dependencies
|
||||
let isInitializing = true;
|
||||
|
||||
@@ -105,11 +142,11 @@ async function logToDatabase(
|
||||
}
|
||||
}
|
||||
|
||||
// Enhanced logger with self-contained database methods
|
||||
// Enhanced logger with self-contained database methods and log level control
|
||||
export const logger = {
|
||||
debug: (message: string, ...args: unknown[]) => {
|
||||
// Debug logs are very verbose - only show in development mode for web
|
||||
if (!isProduction && !isElectron) {
|
||||
// Debug logs only show if VITE_LOG_LEVEL allows it
|
||||
if (shouldLog("debug")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.debug(message, ...args);
|
||||
}
|
||||
@@ -117,11 +154,8 @@ export const logger = {
|
||||
},
|
||||
|
||||
log: (message: string, ...args: unknown[]) => {
|
||||
// Regular logs - show in development or for capacitor, but quiet for Electron
|
||||
if (
|
||||
(!isProduction && !isElectron) ||
|
||||
process.env.VITE_PLATFORM === "capacitor"
|
||||
) {
|
||||
// Regular logs - show if VITE_LOG_LEVEL allows info level
|
||||
if (shouldLog("info")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message, ...args);
|
||||
}
|
||||
@@ -132,11 +166,7 @@ export const logger = {
|
||||
},
|
||||
|
||||
info: (message: string, ...args: unknown[]) => {
|
||||
if (
|
||||
process.env.NODE_ENV !== "production" ||
|
||||
process.env.VITE_PLATFORM === "capacitor" ||
|
||||
process.env.VITE_PLATFORM === "electron"
|
||||
) {
|
||||
if (shouldLog("info")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.info(message, ...args);
|
||||
}
|
||||
@@ -147,8 +177,7 @@ export const logger = {
|
||||
},
|
||||
|
||||
warn: (message: string, ...args: unknown[]) => {
|
||||
// Always show warnings, but for Electron, suppress routine database warnings
|
||||
if (!isElectron || !message.includes("[CapacitorPlatformService]")) {
|
||||
if (shouldLog("warn")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn(message, ...args);
|
||||
}
|
||||
@@ -159,9 +188,10 @@ export const logger = {
|
||||
},
|
||||
|
||||
error: (message: string, ...args: unknown[]) => {
|
||||
// Errors will always be logged to console
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(message, ...args);
|
||||
if (shouldLog("error")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(message, ...args);
|
||||
}
|
||||
|
||||
// Database logging
|
||||
const messageString = safeStringify(message);
|
||||
@@ -175,11 +205,11 @@ export const logger = {
|
||||
},
|
||||
|
||||
toConsoleAndDb: async (message: string, isError = false): Promise<void> => {
|
||||
// Console output
|
||||
if (isError) {
|
||||
// Console output based on log level
|
||||
if (isError && shouldLog("error")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(message);
|
||||
} else {
|
||||
} else if (!isError && shouldLog("info")) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message);
|
||||
}
|
||||
@@ -194,6 +224,12 @@ export const logger = {
|
||||
error: (message: string) =>
|
||||
logToDatabase(`[${componentName}] ${message}`, "error"),
|
||||
}),
|
||||
|
||||
// Log level information methods
|
||||
getCurrentLevel: (): LogLevel => currentLogLevel,
|
||||
getCurrentLevelValue: (): number => currentLevelValue,
|
||||
isLevelEnabled: (level: LogLevel): boolean => shouldLog(level),
|
||||
getAvailableLevels: (): LogLevel[] => Object.keys(LOG_LEVELS) as LogLevel[],
|
||||
};
|
||||
|
||||
// Function to manually mark initialization as complete
|
||||
|
||||
@@ -61,7 +61,8 @@
|
||||
/>
|
||||
|
||||
<!-- Notifications -->
|
||||
<!-- Currently disabled because it doesn't work, even on Chrome. If restored, make sure it works or doesn't show on mobile/electron. -->
|
||||
<!-- Currently disabled because it doesn't work, even on Chrome.
|
||||
If restored, make sure it works or doesn't show on mobile/electron. -->
|
||||
<section
|
||||
v-if="false"
|
||||
id="sectionNotifications"
|
||||
|
||||
@@ -724,6 +724,8 @@ export default class ClaimView extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
|
||||
const settings = await this.$accountSettings();
|
||||
|
||||
this.activeDid = settings.activeDid || "";
|
||||
@@ -754,8 +756,6 @@ export default class ClaimView extends Vue {
|
||||
this.windowDeepLink = `${APP_SERVER}/deep-link/claim/${claimId}`;
|
||||
|
||||
this.canShare = !!navigator.share;
|
||||
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
}
|
||||
|
||||
// insert a space before any capital letters except the initial letter
|
||||
|
||||
@@ -143,7 +143,7 @@ import {
|
||||
QR_TIMEOUT_STANDARD,
|
||||
QR_TIMEOUT_LONG,
|
||||
} from "@/constants/notifications";
|
||||
import { createNotifyHelpers } from "../utils/notify";
|
||||
import { createNotifyHelpers, NotifyFunction } from "../utils/notify";
|
||||
|
||||
interface QRScanResult {
|
||||
rawValue?: string;
|
||||
@@ -191,7 +191,7 @@ interface IUserNameDialog {
|
||||
* @since 2024
|
||||
*/
|
||||
export default class ContactQRScanFull extends Vue {
|
||||
$notify!: (notification: any, timeout?: number) => void;
|
||||
$notify!: NotifyFunction;
|
||||
$router!: Router;
|
||||
|
||||
// Notification helper system
|
||||
|
||||
@@ -708,8 +708,16 @@ export default class ContactQRScanShow extends Vue {
|
||||
|
||||
// Add new contact
|
||||
// @ts-expect-error because we're just using the value to store to the DB
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
contact.contactMethods = JSON.stringify(
|
||||
(this as any)._parseJsonField(contact.contactMethods, []),
|
||||
(
|
||||
this as {
|
||||
_parseJsonField: (
|
||||
value: unknown,
|
||||
defaultValue: unknown[],
|
||||
) => unknown[];
|
||||
}
|
||||
)._parseJsonField(contact.contactMethods, []),
|
||||
);
|
||||
await this.$insertContact(contact);
|
||||
|
||||
|
||||
@@ -130,7 +130,6 @@ import { JWTPayload } from "did-jwt";
|
||||
import * as R from "ramda";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import { copyToClipboard } from "../services/ClipboardService";
|
||||
@@ -165,13 +164,18 @@ import { GiveSummaryRecord } from "@/interfaces/records";
|
||||
import { UserInfo } from "@/interfaces/common";
|
||||
import { VerifiableCredential } from "@/interfaces/claims-result";
|
||||
import * as libsUtil from "../libs/util";
|
||||
import { generateSaveAndActivateIdentity } from "../libs/util";
|
||||
import {
|
||||
generateSaveAndActivateIdentity,
|
||||
contactsToExportJson,
|
||||
} from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
// No longer needed - using PlatformServiceMixin methods
|
||||
// import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { isDatabaseError } from "@/interfaces/common";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { APP_SERVER } from "@/constants/app";
|
||||
import { QRNavigationService } from "@/services/QRNavigationService";
|
||||
import {
|
||||
NOTIFY_CONTACT_NO_INFO,
|
||||
NOTIFY_CONTACTS_ADD_ERROR,
|
||||
@@ -197,6 +201,7 @@ import {
|
||||
NOTIFY_REGISTRATION_ERROR_FALLBACK,
|
||||
NOTIFY_REGISTRATION_ERROR_GENERIC,
|
||||
NOTIFY_VISIBILITY_ERROR_FALLBACK,
|
||||
NOTIFY_EXPORT_DATA_PROMPT,
|
||||
getRegisterPersonSuccessMessage,
|
||||
getVisibilitySuccessMessage,
|
||||
getGivesRetrievalErrorMessage,
|
||||
@@ -376,7 +381,11 @@ export default class ContactsView extends Vue {
|
||||
"",
|
||||
async (name) => {
|
||||
await this.addContact({
|
||||
did: (registration.vc.credentialSubject.agent as any).identifier,
|
||||
did: (
|
||||
registration.vc.credentialSubject.agent as {
|
||||
identifier: string;
|
||||
}
|
||||
).identifier,
|
||||
name: name,
|
||||
registered: true,
|
||||
});
|
||||
@@ -387,7 +396,11 @@ export default class ContactsView extends Vue {
|
||||
async () => {
|
||||
// on cancel, will still add the contact
|
||||
await this.addContact({
|
||||
did: (registration.vc.credentialSubject.agent as any).identifier,
|
||||
did: (
|
||||
registration.vc.credentialSubject.agent as {
|
||||
identifier: string;
|
||||
}
|
||||
).identifier,
|
||||
name: "(person who invited you)",
|
||||
registered: true,
|
||||
});
|
||||
@@ -396,8 +409,7 @@ export default class ContactsView extends Vue {
|
||||
this.showOnboardingInfo();
|
||||
},
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
const fullError = "Error redeeming invite: " + errorStringForLog(error);
|
||||
this.$logAndConsole(fullError, true);
|
||||
let message = "Got an error sending the invite.";
|
||||
@@ -784,6 +796,9 @@ export default class ContactsView extends Vue {
|
||||
|
||||
// Show success notification
|
||||
this.notify.success(addedMessage);
|
||||
|
||||
// Show export data prompt after successful contact addition
|
||||
await this.showExportDataPrompt();
|
||||
} catch (err) {
|
||||
this.handleContactAddError(err);
|
||||
}
|
||||
@@ -881,20 +896,21 @@ export default class ContactsView extends Vue {
|
||||
/**
|
||||
* Handle errors during contact addition
|
||||
*/
|
||||
private handleContactAddError(err: any): void {
|
||||
private handleContactAddError(err: unknown): void {
|
||||
const fullError =
|
||||
"Error when adding contact to storage: " + errorStringForLog(err);
|
||||
this.$logAndConsole(fullError, true);
|
||||
|
||||
let message = NOTIFY_CONTACT_IMPORT_ERROR.message;
|
||||
if (
|
||||
(err as any).message?.indexOf("Key already exists in the object store.") >
|
||||
-1
|
||||
) {
|
||||
message = NOTIFY_CONTACT_IMPORT_CONFLICT.message;
|
||||
}
|
||||
if ((err as any).name === "ConstraintError") {
|
||||
message += " " + NOTIFY_CONTACT_IMPORT_CONSTRAINT.message;
|
||||
|
||||
// Use type-safe error checking with our new type guards
|
||||
if (isDatabaseError(err)) {
|
||||
if (err.message.includes("Key already exists in the object store")) {
|
||||
message = NOTIFY_CONTACT_IMPORT_CONFLICT.message;
|
||||
}
|
||||
if (err.name === "ConstraintError") {
|
||||
message += " " + NOTIFY_CONTACT_IMPORT_CONSTRAINT.message;
|
||||
}
|
||||
}
|
||||
|
||||
this.notify.error(message, TIMEOUTS.LONG);
|
||||
@@ -1248,19 +1264,76 @@ export default class ContactsView extends Vue {
|
||||
|
||||
/**
|
||||
* Handle QR code button click - route to appropriate scanner
|
||||
* Uses native scanner on mobile platforms, web scanner otherwise
|
||||
* Uses QRNavigationService to determine scanner type and route
|
||||
*/
|
||||
|
||||
public handleQRCodeClick() {
|
||||
this.$logAndConsole(
|
||||
"[ContactsView] handleQRCodeClick method called",
|
||||
false,
|
||||
);
|
||||
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
this.$router.push({ name: "contact-qr-scan-full" });
|
||||
} else {
|
||||
this.$router.push({ name: "contact-qr" });
|
||||
const qrNavigationService = QRNavigationService.getInstance();
|
||||
const route = qrNavigationService.getQRScannerRoute();
|
||||
|
||||
this.$router.push(route);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show export data prompt after adding a contact
|
||||
* Prompts user to export their contact data as a backup
|
||||
*/
|
||||
private async showExportDataPrompt(): Promise<void> {
|
||||
setTimeout(() => {
|
||||
this.$notify(
|
||||
{
|
||||
group: "modal",
|
||||
type: "confirm",
|
||||
title: NOTIFY_EXPORT_DATA_PROMPT.title,
|
||||
text: NOTIFY_EXPORT_DATA_PROMPT.message,
|
||||
onYes: async () => {
|
||||
await this.exportContactData();
|
||||
},
|
||||
yesText: "Export Data",
|
||||
onNo: async () => {
|
||||
// User chose not to export - no action needed
|
||||
},
|
||||
noText: "Not Now",
|
||||
},
|
||||
-1,
|
||||
);
|
||||
}, 1000); // Small delay to ensure success notification is shown first
|
||||
}
|
||||
|
||||
/**
|
||||
* Export contact data to JSON file
|
||||
* Uses platform service to handle platform-specific export logic
|
||||
*/
|
||||
private async exportContactData(): Promise<void> {
|
||||
// Note that similar code is in DataExportSection.vue exportDatabase()
|
||||
try {
|
||||
// Fetch all contacts from database
|
||||
const allContacts = await this.$contacts();
|
||||
|
||||
// Convert contacts to export format
|
||||
const exportData = contactsToExportJson(allContacts);
|
||||
const jsonStr = JSON.stringify(exportData, null, 2);
|
||||
|
||||
// Generate filename with current date
|
||||
const today = new Date();
|
||||
const dateString = today.toISOString().split("T")[0]; // YYYY-MM-DD format
|
||||
const fileName = `timesafari-backup-contacts-${dateString}.json`;
|
||||
|
||||
// Use platform service to handle export
|
||||
await this.platformService.writeAndShareFile(fileName, jsonStr);
|
||||
|
||||
this.notify.success(
|
||||
"Contact export completed successfully. Check your downloads or share dialog.",
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error("Export Error:", error);
|
||||
this.notify.error(
|
||||
`There was an error exporting the data: ${error instanceof Error ? error.message : "Unknown error"}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
<!-- Breadcrumb -->
|
||||
<div id="ViewBreadcrumb" class="mb-8">
|
||||
<h1 id="ViewHeading" class="text-lg text-center font-light relative px-7">
|
||||
<!-- Go to 'contacts' instead of just 'back' because they could get here from an edit page (and going back there is annoying). -->
|
||||
<!-- Go to 'contacts' instead of just 'back' because they could get here from an edit page
|
||||
(and going back there is annoying). -->
|
||||
<router-link
|
||||
:to="{ name: 'contacts' }"
|
||||
class="text-lg text-center px-2 py-1 absolute -left-2 -top-1"
|
||||
@@ -489,6 +490,8 @@ export default class DIDView extends Vue {
|
||||
message +=
|
||||
" Note that they can see your activity, so if you want to hide your activity from them then you should do that first.";
|
||||
}
|
||||
message +=
|
||||
" Note that this will also remove anyone with the same DID underneath.";
|
||||
this.notify.confirm(message, async () => {
|
||||
await this.deleteContact(contact);
|
||||
});
|
||||
|
||||
@@ -91,17 +91,12 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="downloadAccount"
|
||||
>
|
||||
<IconRenderer
|
||||
<font-awesome
|
||||
v-if="isLoading"
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<IconRenderer
|
||||
v-else
|
||||
icon-name="chart"
|
||||
svg-class="-ml-1 mr-3 h-5 w-5"
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
<font-awesome v-else icon="chart-line" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Show Account Seed
|
||||
</button>
|
||||
|
||||
@@ -110,17 +105,12 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="downloadSettingsContacts"
|
||||
>
|
||||
<IconRenderer
|
||||
<font-awesome
|
||||
v-if="isLoading"
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<IconRenderer
|
||||
v-else
|
||||
icon-name="chart"
|
||||
svg-class="-ml-1 mr-3 h-5 w-5"
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
<font-awesome v-else icon="chart-line" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Download Settings & Contacts
|
||||
</button>
|
||||
|
||||
@@ -143,17 +133,12 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="compareDatabases"
|
||||
>
|
||||
<IconRenderer
|
||||
<font-awesome
|
||||
v-if="isLoading"
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<IconRenderer
|
||||
v-else
|
||||
icon-name="chart"
|
||||
svg-class="-ml-1 mr-3 h-5 w-5"
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
<font-awesome v-else icon="chart-line" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Compare Databases
|
||||
</button>
|
||||
|
||||
@@ -162,17 +147,12 @@
|
||||
class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="migrateAll"
|
||||
>
|
||||
<IconRenderer
|
||||
<font-awesome
|
||||
v-if="isLoading"
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<IconRenderer
|
||||
v-else
|
||||
icon-name="check"
|
||||
svg-class="-ml-1 mr-3 h-5 w-5"
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
<font-awesome v-else icon="check" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Migrate All
|
||||
</button>
|
||||
|
||||
@@ -185,10 +165,9 @@
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="warning"
|
||||
svg-class="h-5 w-5 text-red-400"
|
||||
fill="currentColor"
|
||||
<font-awesome
|
||||
icon="triangle-exclamation"
|
||||
class="h-5 w-5 text-red-400"
|
||||
/>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
@@ -207,10 +186,9 @@
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="warning"
|
||||
svg-class="h-5 w-5 text-red-400"
|
||||
fill="currentColor"
|
||||
<font-awesome
|
||||
icon="triangle-exclamation"
|
||||
class="h-5 w-5 text-red-400"
|
||||
/>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
@@ -229,10 +207,7 @@
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-5 w-5 text-green-400"
|
||||
/>
|
||||
<font-awesome icon="check" class="h-5 w-5 text-green-400" />
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-green-800">Success</h3>
|
||||
@@ -249,7 +224,7 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="exportComparison"
|
||||
>
|
||||
<IconRenderer icon-name="download" svg-class="-ml-1 mr-3 h-5 w-5" />
|
||||
<font-awesome icon="download" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Export Comparison
|
||||
</button>
|
||||
|
||||
@@ -258,17 +233,12 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="displayDatabases"
|
||||
>
|
||||
<IconRenderer
|
||||
<font-awesome
|
||||
v-if="isLoading"
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<IconRenderer
|
||||
v-else
|
||||
icon-name="chart"
|
||||
svg-class="-ml-1 mr-3 h-5 w-5"
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
<font-awesome v-else icon="chart-line" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Show Previous Data
|
||||
</button>
|
||||
|
||||
@@ -277,7 +247,7 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-orange-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="migrateAccounts"
|
||||
>
|
||||
<IconRenderer icon-name="lock" svg-class="-ml-1 mr-3 h-5 w-5" />
|
||||
<font-awesome icon="lock" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Migrate Accounts
|
||||
</button>
|
||||
|
||||
@@ -286,7 +256,7 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="migrateSettings"
|
||||
>
|
||||
<IconRenderer icon-name="settings" svg-class="-ml-1 mr-3 h-5 w-5" />
|
||||
<font-awesome icon="gear" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Migrate Settings
|
||||
</button>
|
||||
|
||||
@@ -295,7 +265,7 @@
|
||||
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
@click="migrateContacts"
|
||||
>
|
||||
<IconRenderer icon-name="plus" svg-class="-ml-1 mr-3 h-5 w-5" />
|
||||
<font-awesome icon="plus" class="-ml-1 mr-3 h-5 w-5" />
|
||||
Migrate Contacts
|
||||
</button>
|
||||
</div>
|
||||
@@ -316,11 +286,7 @@
|
||||
>
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="info"
|
||||
svg-class="h-5 w-5 text-blue-400"
|
||||
fill="currentColor"
|
||||
/>
|
||||
<font-awesome icon="info" class="h-5 w-5 text-blue-400" />
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-blue-800">
|
||||
@@ -357,10 +323,9 @@
|
||||
<div
|
||||
class="inline-flex items-center px-4 py-2 font-semibold leading-6 text-sm shadow rounded-md text-white bg-blue-500 hover:bg-blue-400 transition ease-in-out duration-150 cursor-not-allowed"
|
||||
>
|
||||
<IconRenderer
|
||||
icon-name="spinner"
|
||||
svg-class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
fill="currentColor"
|
||||
<font-awesome
|
||||
icon="spinner"
|
||||
class="animate-spin -ml-1 mr-3 h-5 w-5 text-white"
|
||||
/>
|
||||
{{ loadingMessage }}
|
||||
</div>
|
||||
@@ -375,10 +340,7 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="lock"
|
||||
svg-class="h-6 w-6 text-orange-600"
|
||||
/>
|
||||
<font-awesome icon="lock" class="h-6 w-6 text-orange-600" />
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
@@ -398,10 +360,7 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-6 w-6 text-teal-600"
|
||||
/>
|
||||
<font-awesome icon="check" class="h-6 w-6 text-teal-600" />
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
@@ -422,10 +381,7 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="settings"
|
||||
svg-class="h-6 w-6 text-purple-600"
|
||||
/>
|
||||
<font-awesome icon="gear" class="h-6 w-6 text-purple-600" />
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
@@ -445,10 +401,7 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-6 w-6 text-indigo-600"
|
||||
/>
|
||||
<font-awesome icon="check" class="h-6 w-6 text-indigo-600" />
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
@@ -469,9 +422,9 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="chart"
|
||||
svg-class="h-6 w-6 text-blue-600"
|
||||
<font-awesome
|
||||
icon="chart-line"
|
||||
class="h-6 w-6 text-blue-600"
|
||||
/>
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
@@ -492,10 +445,7 @@
|
||||
<div class="p-5">
|
||||
<div class="flex items-center">
|
||||
<div class="flex-shrink-0">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-6 w-6 text-green-600"
|
||||
/>
|
||||
<font-awesome icon="check" class="h-6 w-6 text-green-600" />
|
||||
</div>
|
||||
<div class="ml-5 w-0 flex-1">
|
||||
<dl>
|
||||
@@ -526,9 +476,9 @@
|
||||
class="flex items-center justify-between p-3 bg-blue-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="plusCircle"
|
||||
svg-class="h-5 w-5 text-blue-600 mr-2"
|
||||
<font-awesome
|
||||
icon="circle-plus"
|
||||
class="h-5 w-5 text-blue-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-blue-900">Add</span>
|
||||
</div>
|
||||
@@ -541,9 +491,9 @@
|
||||
class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-5 w-5 text-yellow-600 mr-2"
|
||||
<font-awesome
|
||||
icon="check"
|
||||
class="h-5 w-5 text-yellow-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-yellow-900"
|
||||
>Unmodified</span
|
||||
@@ -558,9 +508,9 @@
|
||||
class="flex items-center justify-between p-3 bg-red-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="trash"
|
||||
svg-class="h-5 w-5 text-red-600 mr-2"
|
||||
<font-awesome
|
||||
icon="trash-can"
|
||||
class="h-5 w-5 text-red-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-red-900">Keep</span>
|
||||
</div>
|
||||
@@ -677,9 +627,9 @@
|
||||
class="flex items-center justify-between p-3 bg-blue-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="plusCircle"
|
||||
svg-class="h-5 w-5 text-blue-600 mr-2"
|
||||
<font-awesome
|
||||
icon="circle-plus"
|
||||
class="h-5 w-5 text-blue-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-blue-900">Add</span>
|
||||
</div>
|
||||
@@ -692,9 +642,9 @@
|
||||
class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="edit"
|
||||
svg-class="h-5 w-5 text-yellow-600 mr-2"
|
||||
<font-awesome
|
||||
icon="pen"
|
||||
class="h-5 w-5 text-yellow-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-yellow-900"
|
||||
>Modify</span
|
||||
@@ -709,9 +659,9 @@
|
||||
class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-5 w-5 text-yellow-600 mr-2"
|
||||
<font-awesome
|
||||
icon="check"
|
||||
class="h-5 w-5 text-yellow-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-yellow-900"
|
||||
>Unmodified</span
|
||||
@@ -726,9 +676,9 @@
|
||||
class="flex items-center justify-between p-3 bg-red-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="trash"
|
||||
svg-class="h-5 w-5 text-red-600 mr-2"
|
||||
<font-awesome
|
||||
icon="trash-can"
|
||||
class="h-5 w-5 text-red-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-red-900">Keep</span>
|
||||
</div>
|
||||
@@ -868,9 +818,9 @@
|
||||
class="flex items-center justify-between p-3 bg-blue-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="plusCircle"
|
||||
svg-class="h-5 w-5 text-blue-600 mr-2"
|
||||
<font-awesome
|
||||
icon="circle-plus"
|
||||
class="h-5 w-5 text-blue-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-blue-900">Add</span>
|
||||
</div>
|
||||
@@ -883,9 +833,9 @@
|
||||
class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="edit"
|
||||
svg-class="h-5 w-5 text-yellow-600 mr-2"
|
||||
<font-awesome
|
||||
icon="pen"
|
||||
class="h-5 w-5 text-yellow-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-yellow-900"
|
||||
>Modify</span
|
||||
@@ -900,9 +850,9 @@
|
||||
class="flex items-center justify-between p-3 bg-yellow-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="check"
|
||||
svg-class="h-5 w-5 text-yellow-600 mr-2"
|
||||
<font-awesome
|
||||
icon="check"
|
||||
class="h-5 w-5 text-yellow-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-yellow-900"
|
||||
>Unmodified</span
|
||||
@@ -917,9 +867,9 @@
|
||||
class="flex items-center justify-between p-3 bg-red-50 rounded-lg"
|
||||
>
|
||||
<div class="flex items-center">
|
||||
<IconRenderer
|
||||
icon-name="trash"
|
||||
svg-class="h-5 w-5 text-red-600 mr-2"
|
||||
<font-awesome
|
||||
icon="trash-can"
|
||||
class="h-5 w-5 text-red-600 mr-2"
|
||||
/>
|
||||
<span class="text-sm font-medium text-red-900">Keep</span>
|
||||
</div>
|
||||
@@ -1067,7 +1017,6 @@ import { Component, Vue } from "vue-facing-decorator";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import IconRenderer from "../components/IconRenderer.vue";
|
||||
import {
|
||||
compareDatabases,
|
||||
migrateSettings,
|
||||
@@ -1104,9 +1053,6 @@ import { logger } from "../utils/logger";
|
||||
*/
|
||||
@Component({
|
||||
name: "DatabaseMigration",
|
||||
components: {
|
||||
IconRenderer,
|
||||
},
|
||||
})
|
||||
export default class DatabaseMigration extends Vue {
|
||||
$router!: Router;
|
||||
|
||||
@@ -458,7 +458,9 @@ export default class DiscoverView extends Vue {
|
||||
if (this.isLocalActive) {
|
||||
await this.searchLocal();
|
||||
} else if (this.isMappedActive) {
|
||||
const mapRef = this.$refs.projectMap as any;
|
||||
const mapRef = this.$refs.projectMap as {
|
||||
leafletObject: L.Map;
|
||||
};
|
||||
this.requestTiles(mapRef.leafletObject); // not ideal because I found this from experimentation, not documentation
|
||||
} else {
|
||||
await this.searchAll();
|
||||
@@ -518,11 +520,11 @@ export default class DiscoverView extends Vue {
|
||||
throw JSON.stringify(results);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
} catch (e: any) {
|
||||
} catch (e: unknown) {
|
||||
logger.error("Error with search all: " + errorStringForLog(e));
|
||||
this.notify.error(
|
||||
e.userMessage || NOTIFY_DISCOVER_SEARCH_ERROR.message,
|
||||
(e as { userMessage?: string })?.userMessage ||
|
||||
NOTIFY_DISCOVER_SEARCH_ERROR.message,
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
} finally {
|
||||
|
||||
@@ -565,22 +565,22 @@
|
||||
<h2 class="text-xl font-semibold">What app version is this?</h2>
|
||||
<p>{{ package.version }} ({{ commitHash }})</p>
|
||||
|
||||
<div v-if="Capacitor.isNativePlatform()">
|
||||
<div v-if="isCapacitor">
|
||||
<h2 class="text-xl font-semibold">
|
||||
Do I have the latest version?
|
||||
</h2>
|
||||
<p v-if="Capacitor.getPlatform() === 'ios'">
|
||||
<p v-if="capabilities.isIOS">
|
||||
<a href="https://apps.apple.com/us/app/time-safari/id6742664907" target="_blank" class="text-blue-500">
|
||||
Check the App Store.
|
||||
</a>
|
||||
</p>
|
||||
<p v-else-if="Capacitor.getPlatform() === 'android'">
|
||||
<p v-else-if="!capabilities.isIOS && capabilities.isMobile">
|
||||
<a href="https://play.google.com/store/apps/details?id=app.timesafari.app" target="_blank" class="text-blue-500">
|
||||
Check the Play Store.
|
||||
</a>
|
||||
</p>
|
||||
<p v-else>
|
||||
Sorry, your platform of '{{ Capacitor.getPlatform() }}' is not recognized.
|
||||
Sorry, your platform is not recognized.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -592,12 +592,13 @@
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
import { useClipboard } from "@vueuse/core";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
// Capacitor import removed - using QRNavigationService instead
|
||||
|
||||
import * as Package from "../../package.json";
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import { APP_SERVER } from "../constants/app";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { QRNavigationService } from "@/services/QRNavigationService";
|
||||
|
||||
/**
|
||||
* HelpView.vue - Comprehensive Help System Component
|
||||
@@ -643,7 +644,7 @@ export default class HelpView extends Vue {
|
||||
showVerifiable = false;
|
||||
|
||||
APP_SERVER = APP_SERVER;
|
||||
Capacitor = Capacitor;
|
||||
// Capacitor reference removed - using QRNavigationService instead
|
||||
|
||||
// Ideally, we put no functionality in here, especially in the setup,
|
||||
// because we never want this page to have a chance of throwing an error.
|
||||
@@ -711,11 +712,10 @@ export default class HelpView extends Vue {
|
||||
* @private
|
||||
*/
|
||||
private handleQRCodeClick(): void {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
this.$router.push({ name: "contact-qr-scan-full" });
|
||||
} else {
|
||||
this.$router.push({ name: "contact-qr" });
|
||||
}
|
||||
const qrNavigationService = QRNavigationService.getInstance();
|
||||
const route = qrNavigationService.getQRScannerRoute();
|
||||
|
||||
this.$router.push(route);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -234,7 +234,6 @@ Raymer * @version 1.0.0 */
|
||||
:last-viewed-claim-id="feedLastViewedClaimId"
|
||||
:is-registered="isRegistered"
|
||||
:active-did="activeDid"
|
||||
:on-image-cache="cacheImageData"
|
||||
@load-claim="onClickLoadClaim"
|
||||
@view-image="openImageViewer"
|
||||
/>
|
||||
@@ -255,11 +254,7 @@ Raymer * @version 1.0.0 */
|
||||
|
||||
<ChoiceButtonDialog ref="choiceButtonDialog" />
|
||||
|
||||
<ImageViewer
|
||||
v-model:is-open="isImageViewerOpen"
|
||||
:image-url="selectedImage"
|
||||
:image-data="selectedImageData"
|
||||
/>
|
||||
<ImageViewer v-model:is-open="isImageViewerOpen" :image-url="selectedImage" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -434,9 +429,7 @@ export default class HomeView extends Vue {
|
||||
showShortcutBvc = false;
|
||||
userAgentInfo = new UAParser(); // see https://docs.uaparser.js.org/v2/api/ua-parser-js/get-os.html
|
||||
selectedImage = "";
|
||||
selectedImageData: Blob | null = null;
|
||||
isImageViewerOpen = false;
|
||||
imageCache: Map<string, Blob | null> = new Map();
|
||||
showProjectsDialog = false;
|
||||
|
||||
/**
|
||||
@@ -1614,23 +1607,6 @@ export default class HomeView extends Vue {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Caches image data for sharing
|
||||
*
|
||||
* @public
|
||||
* Called by ActivityListItem component function prop
|
||||
* @param imageUrl URL of image to cache
|
||||
*/
|
||||
async cacheImageData(imageUrl: string) {
|
||||
try {
|
||||
// For images that might fail CORS, just store the URL
|
||||
// The Web Share API will handle sharing the URL appropriately
|
||||
this.imageCache.set(imageUrl, null);
|
||||
} catch (error) {
|
||||
logger.warn("Failed to cache image:", error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens image viewer dialog
|
||||
*
|
||||
@@ -1639,7 +1615,6 @@ export default class HomeView extends Vue {
|
||||
* @param imageUrl URL of image to display
|
||||
*/
|
||||
async openImageViewer(imageUrl: string) {
|
||||
this.selectedImageData = this.imageCache.get(imageUrl) ?? null;
|
||||
this.selectedImage = imageUrl;
|
||||
this.isImageViewerOpen = true;
|
||||
}
|
||||
|
||||
@@ -234,7 +234,9 @@ export default class IdentitySwitcherView extends Vue {
|
||||
{
|
||||
did,
|
||||
settingsKeys: Object.keys(newSettings).filter(
|
||||
(k) => (newSettings as any)[k] !== undefined,
|
||||
(k) =>
|
||||
k in newSettings &&
|
||||
newSettings[k as keyof typeof newSettings] !== undefined,
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
@@ -221,10 +221,11 @@ export default class ImportAccountView extends Vue {
|
||||
|
||||
this.notify.success("Account imported successfully!", TIMEOUTS.STANDARD);
|
||||
this.$router.push({ name: "account" });
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
this.$logError("Import failed: " + error);
|
||||
this.notify.error(
|
||||
error.message || "Failed to import account.",
|
||||
(error instanceof Error ? error.message : String(error)) ||
|
||||
"Failed to import account.",
|
||||
TIMEOUTS.LONG,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ import {
|
||||
import { logger } from "../utils/logger";
|
||||
import { Account, AccountEncrypted } from "../db/tables/accounts";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { createNotifyHelpers, TIMEOUTS, NotifyFunction } from "@/utils/notify";
|
||||
import {
|
||||
NOTIFY_ACCOUNT_DERIVATION_SUCCESS,
|
||||
NOTIFY_ACCOUNT_DERIVATION_ERROR,
|
||||
@@ -100,7 +100,7 @@ import {
|
||||
export default class ImportAccountView extends Vue {
|
||||
$route!: RouteLocationNormalizedLoaded;
|
||||
$router!: Router;
|
||||
$notify!: (notification: any, timeout?: number) => void;
|
||||
$notify!: NotifyFunction;
|
||||
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ export default class OnboardMeetingListView extends Vue {
|
||||
if (response2.data?.data) {
|
||||
this.meetings = response2.data.data;
|
||||
}
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
this.$logAndConsole(
|
||||
"Error fetching meetings: " + errorStringForLog(error),
|
||||
true,
|
||||
|
||||
@@ -345,7 +345,9 @@ export default class OnboardMeetingView extends Vue {
|
||||
}
|
||||
|
||||
async created() {
|
||||
this.notify = createNotifyHelpers(this.$notify as any);
|
||||
this.notify = createNotifyHelpers(
|
||||
this.$notify as Parameters<typeof createNotifyHelpers>[0],
|
||||
);
|
||||
const settings = await this.$accountSettings();
|
||||
this.activeDid = settings?.activeDid || "";
|
||||
this.apiServer = settings?.apiServer || "";
|
||||
@@ -419,7 +421,7 @@ export default class OnboardMeetingView extends Vue {
|
||||
} else {
|
||||
this.newOrUpdatedMeetingInputs = this.blankMeeting();
|
||||
}
|
||||
} catch (error: any) {
|
||||
} catch (error: unknown) {
|
||||
this.newOrUpdatedMeetingInputs = this.blankMeeting();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@
|
||||
import { AxiosRequestConfig } from "axios";
|
||||
import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
// Capacitor import removed - using QRNavigationService instead
|
||||
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import EntityIcon from "../components/EntityIcon.vue";
|
||||
@@ -281,6 +281,7 @@ import { OnboardPage, iconForUnitCode } from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
import { QRNavigationService } from "@/services/QRNavigationService";
|
||||
import {
|
||||
NOTIFY_NO_ACCOUNT_ERROR,
|
||||
NOTIFY_PROJECT_LOAD_ERROR,
|
||||
@@ -464,8 +465,10 @@ export default class ProjectsView extends Vue {
|
||||
);
|
||||
this.notify.error(NOTIFY_PROJECT_LOAD_ERROR.message, TIMEOUTS.LONG);
|
||||
}
|
||||
} catch (error: any) {
|
||||
logger.error("Got error loading plans:", error.message || error);
|
||||
} catch (error: unknown) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
logger.error("Got error loading plans:", errorMessage);
|
||||
this.notify.error(NOTIFY_PROJECT_LOAD_ERROR.message, TIMEOUTS.LONG);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
@@ -578,8 +581,10 @@ export default class ProjectsView extends Vue {
|
||||
);
|
||||
this.notify.error(NOTIFY_OFFERS_LOAD_ERROR.message, TIMEOUTS.LONG);
|
||||
}
|
||||
} catch (error: any) {
|
||||
logger.error("Got error loading offers:", error.message || error);
|
||||
} catch (error: unknown) {
|
||||
const errorMessage =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
logger.error("Got error loading offers:", errorMessage);
|
||||
this.notify.error(NOTIFY_OFFERS_FETCH_ERROR.message, TIMEOUTS.LONG);
|
||||
} finally {
|
||||
this.isLoading = false;
|
||||
@@ -757,11 +762,10 @@ export default class ProjectsView extends Vue {
|
||||
* - Web-based QR interface for browser environments
|
||||
*/
|
||||
private handleQRCodeClick() {
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
this.$router.push({ name: "contact-qr-scan-full" });
|
||||
} else {
|
||||
this.$router.push({ name: "contact-qr" });
|
||||
}
|
||||
const qrNavigationService = QRNavigationService.getInstance();
|
||||
const route = qrNavigationService.getQRScannerRoute();
|
||||
|
||||
this.$router.push(route);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,17 @@
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div v-if="isNotProdServer">
|
||||
<h2 class="text-xl font-bold mb-4">User Registration</h2>
|
||||
<button :class="primaryButtonClasses" @click="registerMe()">
|
||||
Register Yourself
|
||||
</button>
|
||||
<button :class="primaryButtonClasses" @click="becomeUser0()">
|
||||
Become User 0 (who can register others)
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-8">
|
||||
<h2 class="text-xl font-bold mb-4">Notiwind Alerts</h2>
|
||||
|
||||
<!-- Notification test buttons using computed configuration -->
|
||||
@@ -99,7 +109,7 @@
|
||||
|
||||
<div>
|
||||
Register Passkey
|
||||
<button :class="primaryButtonClasses" @click="register()">
|
||||
<button :class="primaryButtonClasses" @click="registerPasskey()">
|
||||
Simplewebauthn
|
||||
</button>
|
||||
</div>
|
||||
@@ -235,6 +245,7 @@ import {
|
||||
registerAndSavePasskey,
|
||||
SHARED_PHOTO_BASE64_KEY,
|
||||
} from "../libs/util";
|
||||
import { testBecomeUser0, testServerRegisterUser } from "@/test";
|
||||
import { logger } from "../utils/logger";
|
||||
import { Account } from "../db/tables/accounts";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
@@ -300,6 +311,7 @@ export default class Help extends Vue {
|
||||
// for passkeys
|
||||
credIdHex?: string;
|
||||
activeDid?: string;
|
||||
apiServer?: string;
|
||||
jwt?: string;
|
||||
peerSetup?: PeerSetup;
|
||||
userName?: string;
|
||||
@@ -521,17 +533,6 @@ export default class Help extends Vue {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to trigger notification test
|
||||
* Centralizes notification testing logic
|
||||
*/
|
||||
triggerTestNotification(config: {
|
||||
notification: NotificationIface;
|
||||
timeout?: number;
|
||||
}) {
|
||||
this.$notify(config.notification, config.timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component initialization
|
||||
*
|
||||
@@ -541,6 +542,7 @@ export default class Help extends Vue {
|
||||
async mounted() {
|
||||
const settings = await this.$accountSettings();
|
||||
this.activeDid = settings.activeDid || "";
|
||||
this.apiServer = settings.apiServer || "";
|
||||
this.userName = settings.firstName;
|
||||
|
||||
const account = await retrieveAccountMetadata(this.activeDid);
|
||||
@@ -553,6 +555,43 @@ export default class Help extends Vue {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if running on production server
|
||||
*
|
||||
* @returns True if not on production server (enables test utilities)
|
||||
*/
|
||||
public isNotProdServer() {
|
||||
return this.apiServer !== AppString.PROD_ENDORSER_API_SERVER;
|
||||
}
|
||||
|
||||
async registerMe() {
|
||||
const response = await testServerRegisterUser();
|
||||
if (response.status === 201) {
|
||||
alert("Registration successful.");
|
||||
this.$router.push({ name: "home" }); // because this page checks for registered status and sets things if it detects a change
|
||||
} else {
|
||||
logger.error("Registration failure response:", response);
|
||||
alert("Registration failed: " + (response.data.error || response.data));
|
||||
}
|
||||
}
|
||||
|
||||
async becomeUser0() {
|
||||
await testBecomeUser0();
|
||||
alert("You are now User 0.");
|
||||
this.$router.push({ name: "home" }); // because this page checks for registered status and sets things if it detects a change
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to trigger notification test
|
||||
* Centralizes notification testing logic
|
||||
*/
|
||||
triggerTestNotification(config: {
|
||||
notification: NotificationIface;
|
||||
timeout?: number;
|
||||
}) {
|
||||
this.$notify(config.notification, config.timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles file upload for image sharing tests
|
||||
*
|
||||
@@ -609,7 +648,7 @@ export default class Help extends Vue {
|
||||
* Includes validation and user confirmation workflow
|
||||
* Uses notification helpers for consistent messaging
|
||||
*/
|
||||
public async register() {
|
||||
public async registerPasskey() {
|
||||
const DEFAULT_USERNAME = AppString.APP_NAME + " Tester";
|
||||
if (!this.userName) {
|
||||
const modalConfig = createPasskeyNameModal(
|
||||
|
||||
Reference in New Issue
Block a user