14
14
<v-text-field v-model =" Profile.displayName" label =" Full name" ></v-text-field >
15
15
<v-text-field v-model =" selectedPhoto.name" label =" Avatar" prepend-icon =' attach_file' @click =" $refs.avatar.click()" ></v-text-field >
16
16
<input type =" file" style =" display : none " ref =" avatar" accept =" image/*" @change =" getFile" >
17
-
18
17
</div >
19
18
</v-card-title >
20
19
<v-card-actions >
@@ -69,7 +68,6 @@ export default {
69
68
methods: {
70
69
getFile (e ) {
71
70
this .selectedPhoto = e .target .files [0 ]
72
- console .log (this .selectedPhoto )
73
71
},
74
72
updateAvatar () {
75
73
if (! this .selectedPhoto ) {
@@ -80,27 +78,24 @@ export default {
80
78
this .$storage .upload ({
81
79
ref: ` /images/${ name} ` ,
82
80
file: this .selectedPhoto ,
83
- progress : snapshot => {},
81
+ progress : snapshot => { },
84
82
error : err => {
85
83
this .message = err .message
86
84
this .snackbar = true
87
85
},
88
86
completed : downloadURL => {
89
87
this .updateProfilePicture (downloadURL)
90
88
.then (() => {
91
- console .log (" profile updated" )
92
- this .synchronize ()
93
- console .log (this .$auth .user ())
94
- this .message = ' Your avatar has been updated'
95
- this .snackbar = true
96
- this .selectedPhoto = { name: " " }
97
- this .ready = false ;
89
+ this .message = ' Your profile info has been updated'
90
+ this .snackbar = true
91
+ this .selectedPhoto = { name: " " }
92
+ this .ready = false
98
93
}).catch (error => {
99
- this .message = error .message ;
94
+ this .message = error .message
100
95
this .snackbar = true
101
96
})
102
97
}
103
- });
98
+ })
104
99
},
105
100
updateProfilePicture (fileName ) {
106
101
return this .$auth .updateProfilePicture (fileName)
@@ -111,19 +106,15 @@ export default {
111
106
.user ()
112
107
.updateProfile (this .Profile .toJson ())
113
108
.then (() => {
114
- this .snackbar = true
115
- this . message = ' You have updated your profile successfully '
116
- this . ready = false
109
+ if ( this .selectedPhoto . type != undefined ) {
110
+ this . updateAvatar ()
111
+ }
117
112
})
118
113
.catch (error => {
119
114
this .message = error .message
120
115
this .snackbar = true
121
116
this .ready = false
122
117
});
123
-
124
- if (this .selectedPhoto .type != undefined ) {
125
- this .updateAvatar ()
126
- }
127
118
},
128
119
synchronize () {
129
120
this .Profile .setPhotoURL (this .$auth .user ().photoURL )
0 commit comments