- Change server switching logs from info to debug level - Implement structured error logging for profile CRUD operations - Handle HTTP status codes 400, 401, 403, 404, 409 gracefully - Suppress full error stack traces for expected API responses - Maintain user notifications while improving console readability - Add timestamp and context to all profile-related error logs Improves developer experience by reducing console noise while preserving debugging information and user-facing error handling.
96 lines
3.4 KiB
Vue
96 lines
3.4 KiB
Vue
<template>
|
||
<div
|
||
class="absolute right-5 top-[max(0.75rem,env(safe-area-inset-top),var(--safe-area-inset-top,0px))]"
|
||
>
|
||
<span class="align-center text-red-500 mr-2">{{ message }}</span>
|
||
<span class="ml-2">
|
||
<router-link
|
||
:to="{ name: 'help' }"
|
||
class="text-xs uppercase bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white px-1.5 py-1 rounded-md ml-1"
|
||
>
|
||
Help
|
||
</router-link>
|
||
</span>
|
||
</div>
|
||
</template>
|
||
|
||
<script lang="ts">
|
||
import { Component, Vue, Prop } from "vue-facing-decorator";
|
||
|
||
import { AppString, NotificationIface } from "../constants/app";
|
||
import { PlatformServiceMixin } from "../utils/PlatformServiceMixin";
|
||
import { createNotifyHelpers, TIMEOUTS } from "../utils/notify";
|
||
import { logger } from "../utils/logger";
|
||
|
||
@Component({
|
||
mixins: [PlatformServiceMixin],
|
||
})
|
||
export default class TopMessage extends Vue {
|
||
// Enhanced PlatformServiceMixin v4.0 provides:
|
||
// - Cached database operations: this.$contacts(), this.$settings(), this.$accountSettings()
|
||
// - Settings shortcuts: this.$saveSettings(), this.$saveMySettings()
|
||
// - Cache management: this.$refreshSettings(), this.$clearAllCaches()
|
||
// - Ultra-concise database methods: this.$db(), this.$exec(), this.$query()
|
||
// - All methods use smart caching with TTL for massive performance gains
|
||
|
||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||
|
||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||
|
||
@Prop selected = "";
|
||
|
||
message = "";
|
||
|
||
async mounted() {
|
||
this.notify = createNotifyHelpers(this.$notify);
|
||
|
||
try {
|
||
// Load settings without overriding database values - fixes settings inconsistency
|
||
logger.debug("[TopMessage] 📥 Loading settings without overrides...");
|
||
const settings = await this.$accountSettings();
|
||
|
||
logger.debug("[TopMessage] 📊 Settings loaded:", {
|
||
activeDid: settings.activeDid,
|
||
apiServer: settings.apiServer,
|
||
warnIfTestServer: settings.warnIfTestServer,
|
||
warnIfProdServer: settings.warnIfProdServer,
|
||
component: "TopMessage",
|
||
timestamp: new Date().toISOString(),
|
||
});
|
||
|
||
// Only show warnings if the user has explicitly enabled them
|
||
if (
|
||
settings.warnIfTestServer &&
|
||
settings.apiServer &&
|
||
settings.apiServer !== AppString.PROD_ENDORSER_API_SERVER
|
||
) {
|
||
const didPrefix = settings.activeDid?.slice(11, 15);
|
||
this.message = "You're not using prod, user " + didPrefix;
|
||
logger.debug("[TopMessage] ⚠️ Test server warning displayed:", {
|
||
apiServer: settings.apiServer,
|
||
didPrefix: didPrefix,
|
||
});
|
||
} else if (
|
||
settings.warnIfProdServer &&
|
||
settings.apiServer &&
|
||
settings.apiServer === AppString.PROD_ENDORSER_API_SERVER
|
||
) {
|
||
const didPrefix = settings.activeDid?.slice(11, 15);
|
||
this.message = "You are using prod, user " + didPrefix;
|
||
logger.debug("[TopMessage] ⚠️ Production server warning displayed:", {
|
||
apiServer: settings.apiServer,
|
||
didPrefix: didPrefix,
|
||
});
|
||
} else {
|
||
logger.debug(
|
||
"[TopMessage] ℹ️ No warnings displayed - conditions not met",
|
||
);
|
||
}
|
||
} catch (err: unknown) {
|
||
logger.error("[TopMessage] ❌ Error loading settings:", err);
|
||
this.notify.error(JSON.stringify(err), TIMEOUTS.MODAL);
|
||
}
|
||
}
|
||
}
|
||
</script>
|