Skip to content

Commit

Permalink
Merge pull request #661 from SamR1/mark-notification-as-read-on-click
Browse files Browse the repository at this point in the history
Mark notification as read on click
  • Loading branch information
SamR1 authored Dec 18, 2024
2 parents 3e54932 + 2738884 commit c5920e3
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 87 deletions.
4 changes: 2 additions & 2 deletions fittrackee/dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<link rel="stylesheet" href="/static/css/fork-awesome.min.css"/>
<link rel="stylesheet" href="/static/css/leaflet.css"/>
<title>FitTrackee</title>
<script type="module" crossorigin src="/static/index-Bb43FHRT.js"></script>
<script type="module" crossorigin src="/static/index-DkoQ8pId.js"></script>
<link rel="modulepreload" crossorigin href="/static/charts-BDOr5tL2.js">
<link rel="modulepreload" crossorigin href="/static/maps-DkiRMund.js">
<link rel="stylesheet" crossorigin href="/static/css/maps-CIGW-MKW.css">
<link rel="stylesheet" crossorigin href="/static/css/index-CFTbC7L9.css">
<link rel="stylesheet" crossorigin href="/static/css/index-DQTEmVQT.css">
</head>
<body>
<div id="app"></div>
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions fittrackee_client/src/components/Comment/Comment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
displayOptions.dateFormat
)
"
@click="$emit('commentLinkClicked')"
>
{{
formatDistance(new Date(comment.created_at), new Date(), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
comments-loading="null"
:for-notification="true"
:action="action"
@commentLinkClicked="$emit('commentLinkClicked')"
/>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions fittrackee_client/src/components/Common/StaticMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
backgroundImage: `url(${imageUrl})`,
}"
:aria-label="$t('workouts.WORKOUT_MAP')"
@click="$emit('workoutLinkClicked')"
/>
<div class="map-attribution">
<a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@
:display-object-name="notification.type.startsWith('user_warning')"
:comment="notification.comment"
:action="notification.report_action"
@commentLinkClicked="markAsReadOnClick(notification)"
/>
</template>
<RelationshipDetail
v-else-if="displayRelationshipCard(notification.type)"
:notification="notification"
:authUser="authUser"
@updatedUserRelationship="emitReload"
@userLinkClicked="markAsReadOnClick(notification)"
/>
<ReportNotification
v-else-if="
Expand All @@ -88,13 +90,15 @@
) && notification.report
"
:report="notification.report"
@reportButtonClicked="markAsReadOnClick(notification)"
/>
<template v-else-if="notification.workout">
<WorkoutForUser
:action="notification.report_action"
:display-appeal="notification.type !== 'user_warning'"
:display-object-name="notification.type.startsWith('user_warning')"
:workout="notification.workout"
@workoutLinkClicked="markAsReadOnClick(notification)"
/>
</template>
<div
Expand Down Expand Up @@ -126,6 +130,7 @@
v-else-if="!notification.report_action?.appeal"
class="appeal-link"
:to="`profile/moderation/sanctions/${notification.report_action.id}`"
@click="markAsReadOnClick(notification)"
>
{{ $t('user.APPEAL') }}
</router-link>
Expand Down Expand Up @@ -168,6 +173,11 @@
function updateReadStatus(notificationId: number, markedAsRead: boolean) {
emit('updateReadStatus', { notificationId, markedAsRead })
}
function markAsReadOnClick(notification: INotification) {
if (!notification.marked_as_read) {
updateReadStatus(notification.id, true)
}
}
function displayCommentCard(notificationType: TNotificationType): boolean {
return (
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
<div class="follow-request-user">
<UserPicture :user="notification.from" />
<div class="user-name">
<router-link :to="`/users/${notification.from.username}`">
<router-link
:to="`/users/${notification.from.username}`"
@click="$emit('userLinkClicked')"
>
{{ notification.from.username }}
</router-link>
</div>
Expand Down Expand Up @@ -54,7 +57,7 @@
const props = defineProps<Props>()
const { authUser, notification } = toRefs(props)
const emit = defineEmits(['updatedUserRelationship'])
const emit = defineEmits(['updatedUserRelationship', 'userLinkClicked'])
const store = useStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</span>
</div>
<div class="report-button">
<button @click="$router.push(`/admin/reports/${report.id}`)">
<button @click="displayReport(report.id)">
{{ $t('admin.APP_MODERATION.VIEW_REPORT') }} #{{ report.id }}
</button>
</div>
Expand All @@ -37,6 +37,7 @@

<script setup lang="ts">
import { toRefs } from 'vue'
import { useRouter } from 'vue-router'
import CommentForUser from '@/components/Comment/CommentForUser.vue'
import UserPicture from '@/components/User/UserPicture.vue'
Expand All @@ -48,6 +49,15 @@
}
const props = defineProps<Props>()
const { report } = toRefs(props)
const emit = defineEmits(['reportButtonClicked'])
const router = useRouter()
function displayReport(reportId: number) {
router.push(`/admin/reports/${reportId}`)
emit('reportButtonClicked')
}
</script>

<style scoped lang="scss">
Expand Down
29 changes: 20 additions & 9 deletions fittrackee_client/src/components/Workout/WorkoutCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
name: 'Workout',
params: { workoutId: workout.id },
}"
@click="$emit('workoutLinkClicked')"
>
{{ workout.title }}
</router-link>
Expand All @@ -39,13 +40,18 @@
</div>
</div>
<div class="workout-map">
<StaticMap v-if="workout.with_gpx" :workout="workout" />
<StaticMap
v-if="workout.with_gpx"
:workout="workout"
@workoutLinkClicked="$emit('workoutLinkClicked')"
/>
<router-link
v-else-if="workout.id"
:to="{
name: 'Workout',
params: { workoutId: workout.id },
}"
@click="$emit('workoutLinkClicked')"
>
<div class="no-map">
{{ $t('workouts.NO_MAP') }}
Expand All @@ -55,14 +61,7 @@
<div
class="workout-data"
:class="{ 'without-elevation': !hasElevation(workout) }"
@click="
workout.id
? $router.push({
name: 'Workout',
params: { workoutId: workout.id },
})
: null
"
@click="navigateToWorkout(workout)"
>
<div class="img">
<SportImage
Expand Down Expand Up @@ -138,6 +137,7 @@
import Username from '@/components/User/Username.vue'
import UserPicture from '@/components/User/UserPicture.vue'
import useApp from '@/composables/useApp'
import router from '@/router'
import type { ISport } from '@/types/sports'
import type { IUserProfile } from '@/types/user'
import type { IWorkout } from '@/types/workouts'
Expand All @@ -160,6 +160,8 @@
const { locale } = useApp()
const emit = defineEmits(['workoutLinkClicked'])
const workoutDateWithTZ = computed(() =>
formatDate(workout.value.workout_date, timezone.value, dateFormat.value)
)
Expand All @@ -176,6 +178,15 @@
workout.descent !== null
)
}
function navigateToWorkout(workout: IWorkout) {
if (workout.id) {
router.push({
name: 'Workout',
params: { workoutId: workout.id },
})
emit('workoutLinkClicked')
}
}
</script>

<style lang="scss" scoped>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:useImperialUnits="imperialUnits"
:dateFormat="dateFormat"
:timezone="timezone"
@workoutLinkClicked="$emit('workoutLinkClicked')"
/>
<WorkoutActionAppeal
v-if="action && displayWorkoutAppeal"
Expand Down

0 comments on commit c5920e3

Please sign in to comment.