Skip to content

Commit df061ff

Browse files
committed
feat: handle when user clicks link to another users profile, reload user mod notes
1 parent ff8e1dd commit df061ff

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/components/modals/profile/ModerationNotes.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
</div>
4242
</div>
4343
</div>
44-
<div v-if="userNotes" class="mod-notes pagination-simple">
44+
<div v-if="userNotes.data.length" class="mod-notes pagination-simple">
4545
<button @click="pullPage(-1)" :disabled="!userNotes?.prev">&#10094; Prev</button>
4646
<label>Page {{userNotes.page}}</label>
4747
<button @click="pullPage(1)" :disabled="!userNotes?.next">Next &#10095;</button>
4848
</div>
49-
<div v-if="!userNotes">
49+
<div v-if="!userNotes.data.length">
5050
<h5 class="no-comments">No Moderation Notes to Display</h5>
5151
</div>
5252
</div>
@@ -72,7 +72,7 @@
7272

7373
<script>
7474
import Modal from '@/components/layout/Modal.vue'
75-
import { reactive, toRefs, inject, onBeforeMount } from 'vue'
75+
import { reactive, toRefs, inject, onBeforeMount, onBeforeUpdate } from 'vue'
7676
import { cloneDeep } from 'lodash'
7777
import humanDate from '@/composables/filters/humanDate'
7878
import { usersApi } from '@/api'
@@ -90,6 +90,13 @@ export default {
9090
limit: 5
9191
}).then(d => v.userNotes = d).catch(() => {}))
9292
93+
/* This handles user clicking link switching from one user's profile to another's */
94+
onBeforeUpdate(() => props.user.id !== v.userNotes.user_id ? usersApi.notes({
95+
user_id: props.user.id,
96+
page: 1,
97+
limit: 5
98+
}).then(d => v.userNotes = d).catch(() => {}) : null)
99+
93100
/* Template Methods */
94101
const pullPage = inc => usersApi.notes({
95102
user_id: props.user.id,

0 commit comments

Comments
 (0)