diff --git a/src/db/tables/settings.ts b/src/db/tables/settings.ts
index dbc4cf0c9..671b50466 100644
--- a/src/db/tables/settings.ts
+++ b/src/db/tables/settings.ts
@@ -20,11 +20,12 @@ export type Settings = {
filterFeedByNearby?: boolean; // filter by nearby
filterFeedByVisible?: boolean; // filter by visible users ie. anyone not hidden
- firstName?: string; // User's first name
+ firstName?: string; // user's full name
isRegistered?: boolean;
lastName?: string; // deprecated - put all names in firstName
- lastNotifiedClaimId?: string; // Last notified claim ID
- lastViewedClaimId?: string; // Last viewed claim ID
+ lastNotifiedClaimId?: string;
+ lastViewedClaimId?: string;
+ profileImageUrl?: string;
reminderTime?: number; // Time in milliseconds since UNIX epoch for reminders
reminderOn?: boolean; // Toggle to enable or disable reminders
diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue
index fb0b505c4..08755864b 100644
--- a/src/views/AccountViewView.vue
+++ b/src/views/AccountViewView.vue
@@ -68,6 +68,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
();
@Component({
- components: { QuickNav, TopMessage },
+ components: { GiftedPhotoDialog, QuickNav, TopMessage },
})
export default class AccountViewView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
@@ -586,10 +611,12 @@ export default class AccountViewView extends Vue {
isRegistered = false;
isSubscribed = false;
notificationMaybeChanged = false;
+ profileImageUrl: string | null = null;
publicHex = "";
publicBase64 = "";
webPushServer = "";
webPushServerInput = "";
+
limitsMessage = "";
loadingLimits = false;
showContactGives = false;
@@ -1260,5 +1287,87 @@ export default class AccountViewView extends Vue {
-1,
);
}
+
+ openPhotoDialog() {
+ (this.$refs.photoDialog as GiftedPhotoDialog).open((imgUrl) => {
+ this.profileImageUrl = imgUrl;
+ console.log("Got image URL:", imgUrl);
+ });
+ }
+
+ confirmDeleteImage() {
+ this.$notify(
+ {
+ group: "modal",
+ type: "confirm",
+ title: "Are you sure you want to delete your profile picture?",
+ text: "",
+ onYes: this.deleteImage,
+ },
+ -1,
+ );
+ }
+
+ async deleteImage() {
+ if (!this.profileImageUrl) {
+ return;
+ }
+ try {
+ const identity = await this.getIdentity(this.activeDid);
+ if (!identity) {
+ throw Error("No identity found.");
+ }
+ const token = await accessToken(identity);
+ const response = await this.axios.delete(
+ DEFAULT_IMAGE_API_SERVER +
+ "/image/" +
+ encodeURIComponent(this.profileImageUrl),
+ {
+ headers: {
+ Authorization: `Bearer ${token}`,
+ },
+ },
+ );
+ if (response.status === 204) {
+ // don't bother with a notification
+ // (either they'll simply continue or they're canceling and going back)
+ } else {
+ console.error("Non-success deleting image:", response);
+ this.$notify(
+ {
+ group: "alert",
+ type: "danger",
+ title: "Error",
+ text: "There was a problem deleting the image.",
+ },
+ 5000,
+ );
+ // keep the imageUrl in localStorage so the user can try again if they want
+ return;
+ }
+
+ this.profileImageUrl = "";
+ } catch (error) {
+ console.error("Error deleting image:", error);
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ if ((error as any).response.status === 404) {
+ console.log("The image was already deleted:", error);
+
+ this.profileImageUrl = "";
+
+ // it already doesn't exist so we won't say anything to the user
+ } else {
+ this.$notify(
+ {
+ group: "alert",
+ type: "danger",
+ title: "Error",
+ text: "There was an error deleting the image.",
+ },
+ 5000,
+ );
+ }
+ }
+ }
}