Redirect to main user page after follow or unfollow.
This commit is contained in:
parent
e275c5a044
commit
bf6066e949
|
@ -20,9 +20,9 @@ navigation to the different sub-pages on the user page:
|
||||||
<div>Following: {{ profile.followingCount }}</div>
|
<div>Following: {{ profile.followingCount }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="authStore.loggedIn && !isOwnUser">
|
<div v-if="authStore.loggedIn && !isOwnUser" class="q-my-md">
|
||||||
<q-btn v-if="!profile.followingThisUser" label="Follow" @click="followUser"/>
|
<q-btn color="secondary" v-if="!profile.followingThisUser" label="Follow" @click="followUser"/>
|
||||||
<q-btn v-if="profile.followingThisUser" label="Unfollow" @click="unfollowUser"/>
|
<q-btn color="secondary" v-if="profile.followingThisUser" label="Unfollow" @click="unfollowUser"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PageMenu
|
<PageMenu
|
||||||
|
@ -61,7 +61,7 @@ import StandardCenteredPage from 'components/StandardCenteredPage.vue';
|
||||||
import {onMounted, ref, Ref, watch} from 'vue';
|
import {onMounted, ref, Ref, watch} from 'vue';
|
||||||
import {UserFollowResponse, UserProfile} from 'src/api/main/auth';
|
import {UserFollowResponse, UserProfile} from 'src/api/main/auth';
|
||||||
import api from 'src/api/main';
|
import api from 'src/api/main';
|
||||||
import {useRoute} from 'vue-router';
|
import {useRoute, useRouter} from 'vue-router';
|
||||||
import {useAuthStore} from 'stores/auth-store';
|
import {useAuthStore} from 'stores/auth-store';
|
||||||
import {showApiErrorToast, showInfoToast} from 'src/utils';
|
import {showApiErrorToast, showInfoToast} from 'src/utils';
|
||||||
import PageMenu from 'components/PageMenu.vue';
|
import PageMenu from 'components/PageMenu.vue';
|
||||||
|
@ -71,6 +71,7 @@ import UserFollowingPage from 'pages/user/UserFollowingPage.vue';
|
||||||
import {useDevStore} from 'stores/dev-store';
|
import {useDevStore} from 'stores/dev-store';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const router = useRouter();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
const devStore = useDevStore();
|
const devStore = useDevStore();
|
||||||
|
|
||||||
|
@ -109,6 +110,8 @@ async function followUser() {
|
||||||
const result = await api.auth.followUser(profile.value.id, authStore);
|
const result = await api.auth.followUser(profile.value.id, authStore);
|
||||||
if (result === UserFollowResponse.FOLLOWED) {
|
if (result === UserFollowResponse.FOLLOWED) {
|
||||||
await loadUser(profile.value.id);
|
await loadUser(profile.value.id);
|
||||||
|
// Put our user back at the target user's main page.
|
||||||
|
await router.replace(`/users/${profile.value.id}`);
|
||||||
} else if (result === UserFollowResponse.REQUESTED) {
|
} else if (result === UserFollowResponse.REQUESTED) {
|
||||||
showInfoToast('userPage.requestedToFollow');
|
showInfoToast('userPage.requestedToFollow');
|
||||||
}
|
}
|
||||||
|
@ -123,6 +126,8 @@ async function unfollowUser() {
|
||||||
try {
|
try {
|
||||||
await api.auth.unfollowUser(profile.value.id, authStore);
|
await api.auth.unfollowUser(profile.value.id, authStore);
|
||||||
await loadUser(profile.value.id);
|
await loadUser(profile.value.id);
|
||||||
|
// Put our user back at the target user's main page.
|
||||||
|
await router.replace(`/users/${profile.value.id}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showApiErrorToast(error);
|
showApiErrorToast(error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class IndexComponents {
|
||||||
.withField("name", 1f)
|
.withField("name", 1f)
|
||||||
.build(s),
|
.build(s),
|
||||||
10,
|
10,
|
||||||
Path.of("user-index")
|
Path.of("indexes", "users")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public class IndexComponents {
|
||||||
.withField("street_address", 0.1f)
|
.withField("street_address", 0.1f)
|
||||||
.build(s),
|
.build(s),
|
||||||
10,
|
10,
|
||||||
Path.of("gym-index")
|
Path.of("indexes", "gyms")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue