Skip to content

Commit

Permalink
Fixed elrumo#1252
Browse files Browse the repository at this point in the history
  • Loading branch information
elrumo committed Jul 27, 2021
1 parent 280365e commit f06e232
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 47 deletions.
49 changes: 29 additions & 20 deletions website/macos-big-sur-icons/src/components/AccountDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
class="coral-Form-field"
type="text"
v-on:change="validate($event, 'username')"
v-on:keyup="validate($event, 'username')"
:value="getUser.userData.username"
>
</div>
Expand All @@ -60,6 +61,7 @@
labelledby="user-bio-label"
style="height:75px"
v-on:keyup="validate($event, 'bio')"
v-on:change="validate($event, 'bio')"
:value="getUser.userData.bio"
>{{getUser.userData.bio}}</textarea>

Expand Down Expand Up @@ -88,6 +90,7 @@
class="coral-Form-field"
type="text"
v-on:change="validate($event, 'twitterHandle')"
v-on:keyup="validate($event, 'twitterHandle')"
:value="getUser.userData.twitterHandle"
>
</div>
Expand Down Expand Up @@ -142,6 +145,7 @@
class="coral-Form-field"
type="url"
v-on:change="validate($event, 'credit')"
v-on:keyup="validate($event, 'credit')"
:value="getUser.userData.credit"
>
</div>
Expand Down Expand Up @@ -227,36 +231,40 @@ export default {
hasChanged: false,
toUpdate:{},
isReset: false,
isLoading: false
// isLoading: false
}
},
methods:{
...mapActions(['showToast', 'setUser']),
...mapActions([
'showToast',
'setUser',
'setData',
]),
async resetPassword(){
let parent = this;
let parent = this;
let email = Parse.User.current().get("email");
let email = Parse.User.current().get("email");
if (parent.isReset) {
parent.isLoading = true;
parent.isReset = false;
if (parent.isReset) {
// parent.isLoading = true;
parent.isReset = false;
Parse.User.requestPasswordReset(email).then(()=>{
parent.showToast({
id: "toastMessage",
message: "Check your email",
variant: "success"
})
})
} else{
document.getElementById("resetPasswordDialog").show()
parent.isReset = true;
}
Parse.User.requestPasswordReset(email).then(()=>{
parent.showToast({
id: "toastMessage",
message: "Check your email",
variant: "success"
})
})
},
} else{
document.getElementById("resetPasswordDialog").show()
parent.isReset = true;
}
},
async requestUserData(){
let parent = this;
Expand Down Expand Up @@ -354,6 +362,7 @@ export default {
for(let key in toUpdate){
ParseUser.set(key, toUpdate[key])
parent.setData({state: 'user', key: key, data: toUpdate[key]})
}
ParseUser.save().then((data) =>{
Expand Down
1 change: 0 additions & 1 deletion website/macos-big-sur-icons/src/components/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@ import dotenv from 'dotenv'; // Used to access env varaibles
dotenv.config()
// TODO: remove credentials
const VUE_APP_PARSE_APP_ID = process.env.VUE_APP_PARSE_APP_ID
const VUE_APP_PARSE_JAVASCRIPT_KEY = process.env.VUE_APP_PARSE_JAVASCRIPT_KEY
Expand Down
38 changes: 28 additions & 10 deletions website/macos-big-sur-icons/src/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ export default new Vuex.Store({
singleResourceData: {},
moreResources: getPages(10),

user: {},
user: {
bio: "",
credit: "",
id: "",
twitterHandle: "",
username: ""
},
userData: Parse.User.current(),

loading: true,
Expand Down Expand Up @@ -85,8 +91,6 @@ export default new Vuex.Store({
let concatArray = iconData.concatArray

if (concatArray) {
// let newItems = [...store[iconData.arr]]
// console.log("newItems: ", newItems);
store[iconData.arr] = store[iconData.arr].concat(iconData.data)
} else if (Array.isArray(iconData.data) && !concatArray) {
store[iconData.arr] = iconData.data
Expand All @@ -96,7 +100,17 @@ export default new Vuex.Store({
},

setDataToArr(store, iconData){
store[iconData.arr] = iconData.data
if (iconData.key) {
let tempArr = {};
// Duplicates object and adds it back to state so that Vuex sees that it has been updated.
for(let key in store[iconData.arr]){
tempArr[key] = store[iconData.arr][key];
}
tempArr[iconData.key] = iconData.data;
store[iconData.arr] = tempArr;
} else{
store[iconData.arr] = iconData.data;
}
},

pushBlogs(store, blogData){
Expand Down Expand Up @@ -149,7 +163,12 @@ export default new Vuex.Store({
},

setData(store, data){
store.commit('setDataToArr', {arr: data.state, data: data.data})
console.log("data.state: ", data);
if (data.key) {
store.commit('setDataToArr', {arr: data.state, key: data.key, data: data.data})
} else{
store.commit('setDataToArr', {arr: data.state, data: data.data})
}
},

async loadMoreIcons(store){
Expand Down Expand Up @@ -352,11 +371,6 @@ export default new Vuex.Store({
console.log("icon.type: ", result.get('appName'));
}

// // Set type if empty
// if (!icon.category) {
// dataToPush.iconData.category = {id: ""}
// }

for(let data in icon){
dataToPush.iconData[data] = icon[data]
}
Expand Down Expand Up @@ -691,6 +705,10 @@ export default new Vuex.Store({
return ordered
},

getUserInfo(store){
return store.user
},

getUser(store){
let parseUserObj = Parse.User.current()
let userData = JSON.parse(JSON.stringify(store.userData))
Expand Down
39 changes: 23 additions & 16 deletions website/macos-big-sur-icons/src/views/UserProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
<!-- User info -->
<div class="profile-info-wrapper">
<div class="profile-header-wrapper">

<div class="profile-name-social">
<h3 class="coral-Heading--L m-0">
{{ user.username }}
{{ getUserInfo.username }}
</h3>

<a v-if="user.twitterHandle" target="_blank" :href="user.twitterHandle" class="margin-auto relative">
<a v-if="getUserInfo.twitterHandle" target="_blank" :href="getUserInfo.twitterHandle" class="margin-auto relative">
<IconUI class="absolute-center-vertical" width="18px" :img="resources.twitter" alt="Twitter Logo"/>
</a>
<div target="_blank" @click="copyUserUrl" class="margin-auto relative pointer">
Expand All @@ -52,15 +51,15 @@
<div class="profile-descrption-box">
<div v-if="loading.user" class="loading-placeholder m-b-10"></div>
<div v-if="loading.user" class="loading-placeholder m-b-10"></div>
<p v-if="user.bio" class="coral-Body--L m-b-5">
{{ user.bio }}
<p v-if="getUserInfo.bio" class="coral-Body--L m-b-5">
{{ getUserInfo.bio }}
</p>

<a v-if="user.credit" target="_blank" :href="user.credit" class="margin-auto relative">
<a v-if="getUserInfo.credit" target="_blank" :href="getUserInfo.credit" class="margin-auto relative">
<!-- <p class="coral-Body--XS"> -->
<IconUI class="absolute-center-vertical" width="14px" :img="resources.link" alt="Credit link"/>
<span class="p-l-20">
{{ user.credit.replace("https://", "") }}
{{ getUserInfo.credit.replace("https://", "") }}
</span>
<!-- </p> -->
</a>
Expand Down Expand Up @@ -231,6 +230,8 @@ export default {
'emptyArr',
'showToast',
'setDataToArr',
'setData',
'pushDataToArr',
'adClick'
]),
Expand Down Expand Up @@ -279,20 +280,19 @@ export default {
})
})
let twitterHandle = userInfo.get("twitterHandle") // Check if twitterHandle is a URL or not
if (twitterHandle) user.twitterHandle = twitterHandle
user.credit = userInfo.get("credit")
user.username = userInfo.get("username")
user.bio = userInfo.get("bio")
user.id = userInfo.id
parent.setData({state: 'user', data: user})
if (Parse.User.current() && user.username == Parse.User.current().getUsername()) {
user.isOwner = true
}
let twitterHandle = userInfo.get("twitterHandle") // Check if twitterHandle is a URL or not
if (twitterHandle && twitterHandle.includes("twitter.com")) {
user.twitterHandle = twitterHandle
} else{
user.twitterHandle = "https://twitter.com/"+userInfo.get("twitterHandle")
}
parent.loading.user = false
} else{
Expand All @@ -316,6 +316,12 @@ export default {
let parent = this
parent.iconsToShow = status
},
userData(){
let parent = this
console.log("parent.user: ", parent.$store.state.user);
return parent.$store.state.user
},
scrolled() {
let parent = this
Expand Down Expand Up @@ -358,7 +364,8 @@ export default {
'getAppCategories',
'approvedIconsCount',
'isLoading',
'getSelectedIcon'
'getSelectedIcon',
'getUserInfo'
]),
iconsCount(){
Expand Down

0 comments on commit f06e232

Please sign in to comment.