forked from jsnbuchanan/crowd-funder-for-time-pwa
Fix UserNameDialog open error and add defensive ref check
- Added ref="userNameDialog" to UserNameDialog in AccountViewView.vue template - Patched onEditName() to check for dialog ref and open() method before calling - Improved error notification to use NotificationIface fields (group, type, title, text) - Prevents "Cannot read properties of undefined (reading 'open')" error if dialog is missing
This commit is contained in:
@@ -100,7 +100,7 @@ import {
|
||||
} from "@vue-leaflet/vue-leaflet";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
|
||||
@Component({
|
||||
components: {
|
||||
@@ -109,6 +109,7 @@ import * as databaseUtil from "../db/databaseUtil";
|
||||
LMarker,
|
||||
LTileLayer,
|
||||
},
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class FeedFilters extends Vue {
|
||||
$router!: Router;
|
||||
@@ -122,7 +123,7 @@ export default class FeedFilters extends Vue {
|
||||
async open(onCloseIfChanged: () => void) {
|
||||
this.onCloseIfChanged = onCloseIfChanged;
|
||||
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
const settings = await this.$settings();
|
||||
this.hasVisibleDid = !!settings.filterFeedByVisible;
|
||||
this.isNearby = !!settings.filterFeedByNearby;
|
||||
if (settings.searchBoxes && settings.searchBoxes.length > 0) {
|
||||
@@ -136,7 +137,7 @@ export default class FeedFilters extends Vue {
|
||||
async toggleHasVisibleDid() {
|
||||
this.settingChanged = true;
|
||||
this.hasVisibleDid = !this.hasVisibleDid;
|
||||
await databaseUtil.updateDefaultSettings({
|
||||
await this.$updateSettings({
|
||||
filterFeedByVisible: this.hasVisibleDid,
|
||||
});
|
||||
}
|
||||
@@ -144,7 +145,7 @@ export default class FeedFilters extends Vue {
|
||||
async toggleNearby() {
|
||||
this.settingChanged = true;
|
||||
this.isNearby = !this.isNearby;
|
||||
await databaseUtil.updateDefaultSettings({
|
||||
await this.$updateSettings({
|
||||
filterFeedByNearby: this.isNearby,
|
||||
});
|
||||
}
|
||||
@@ -154,7 +155,7 @@ export default class FeedFilters extends Vue {
|
||||
this.settingChanged = true;
|
||||
}
|
||||
|
||||
await databaseUtil.updateDefaultSettings({
|
||||
await this.$updateSettings({
|
||||
filterFeedByNearby: false,
|
||||
filterFeedByVisible: false,
|
||||
});
|
||||
@@ -168,7 +169,7 @@ export default class FeedFilters extends Vue {
|
||||
this.settingChanged = true;
|
||||
}
|
||||
|
||||
await databaseUtil.updateDefaultSettings({
|
||||
await this.$updateSettings({
|
||||
filterFeedByNearby: true,
|
||||
filterFeedByVisible: true,
|
||||
});
|
||||
|
||||
@@ -185,4 +185,3 @@ export default class IdentitySection extends Vue {
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,11 +38,13 @@
|
||||
import { Vue, Component, Prop } from "vue-facing-decorator";
|
||||
|
||||
import { NotificationIface } from "../constants/app";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import { MASTER_SETTINGS_KEY } from "../db/tables/settings";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
|
||||
@Component
|
||||
@Component({
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class UserNameDialog extends Vue {
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
|
||||
@@ -62,7 +64,7 @@ export default class UserNameDialog extends Vue {
|
||||
*/
|
||||
async open(aCallback?: (name?: string) => void) {
|
||||
this.callback = aCallback || this.callback;
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
const settings = await this.$settings();
|
||||
this.givenName = settings.firstName || "";
|
||||
this.visible = true;
|
||||
}
|
||||
|
||||
@@ -95,4 +95,3 @@ export function useNotifications() {
|
||||
downloadStarted,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,4 +221,3 @@ export function createProfileService(
|
||||
): ProfileService {
|
||||
return new ProfileService(axios, partnerApiServer);
|
||||
}
|
||||
|
||||
@@ -276,4 +276,3 @@ export const NotificationMixin = {
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -260,12 +260,16 @@
|
||||
<h3
|
||||
id="advanced"
|
||||
class="text-blue-500 text-sm font-semibold mb-3 cursor-pointer"
|
||||
@click="showAdvanced = !showAdvanced"
|
||||
@click="toggleShowGeneralAdvanced"
|
||||
>
|
||||
{{ showAdvanced ? "Hide Advanced Settings" : "Show Advanced Settings" }}
|
||||
{{
|
||||
showGeneralAdvanced
|
||||
? "Hide Advanced Settings"
|
||||
: "Show Advanced Settings"
|
||||
}}
|
||||
</h3>
|
||||
<section
|
||||
v-if="showAdvanced || showGeneralAdvanced"
|
||||
v-if="showGeneralAdvanced"
|
||||
id="sectionAdvanced"
|
||||
aria-labelledby="advancedHeading"
|
||||
>
|
||||
@@ -740,6 +744,8 @@
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<UserNameDialog ref="userNameDialog" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -1595,11 +1601,20 @@ export default class AccountViewView extends Vue {
|
||||
|
||||
// IdentitySection event handlers
|
||||
onEditName() {
|
||||
(this.$refs.userNameDialog as InstanceType<typeof UserNameDialog>).open(
|
||||
(name?: string) => {
|
||||
const dialog = this.$refs.userNameDialog as any;
|
||||
if (dialog && typeof dialog.open === "function") {
|
||||
dialog.open((name?: string) => {
|
||||
if (name) this.givenName = name;
|
||||
},
|
||||
);
|
||||
});
|
||||
} else {
|
||||
this.$notify?.({
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Dialog Error",
|
||||
text: "Name dialog not available.",
|
||||
});
|
||||
console.error("UserNameDialog ref is missing or open() is not a function", dialog);
|
||||
}
|
||||
}
|
||||
onShowQrCode() {
|
||||
this.handleQRCodeClick();
|
||||
|
||||
Reference in New Issue
Block a user