Get the links of the Tags in the Post as a URL driven query to work

Co-Authored-By: mattwr18 <mattwr18@gmail.com>
This commit is contained in:
Wolfgang Huß 2019-07-04 19:55:06 +02:00
parent e7b70ce7cd
commit 1c8dac7359
7 changed files with 96 additions and 9 deletions

View File

@ -13,7 +13,10 @@ const transporter = () => {
} }
const { SMTP_USERNAME: user, SMTP_PASSWORD: pass } = CONFIG const { SMTP_USERNAME: user, SMTP_PASSWORD: pass } = CONFIG
if (user && pass) { if (user && pass) {
configs.auth = { user, pass } configs.auth = {
user,
pass,
}
} }
return nodemailer.createTransport(configs) return nodemailer.createTransport(configs)
} }
@ -41,11 +44,21 @@ export default {
Mutation: { Mutation: {
requestPasswordReset: async (_, { email }, { driver }) => { requestPasswordReset: async (_, { email }, { driver }) => {
const code = uuid().substring(0, 6) const code = uuid().substring(0, 6)
const [user] = await createPasswordReset({ driver, code, email }) const [user] = await createPasswordReset({
driver,
code,
email,
})
if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) { if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) {
const name = (user && user.name) || '' const name = (user && user.name) || ''
const mailTemplate = user ? resetPasswordMail : wrongAccountMail const mailTemplate = user ? resetPasswordMail : wrongAccountMail
await transporter().sendMail(mailTemplate({ email, code, name })) await transporter().sendMail(
mailTemplate({
email,
code,
name,
}),
)
} }
return true return true
}, },
@ -62,7 +75,12 @@ export default {
SET u.password = $newHashedPassword SET u.password = $newHashedPassword
RETURN pr RETURN pr
` `
let transactionRes = await session.run(cypher, { stillValid, email, code, newHashedPassword }) let transactionRes = await session.run(cypher, {
stillValid,
email,
code,
newHashedPassword,
})
const [reset] = transactionRes.records.map(record => record.get('pr')) const [reset] = transactionRes.records.map(record => record.get('pr'))
const result = !!(reset && reset.properties.usedAt) const result = !!(reset && reset.properties.usedAt)
session.close() session.close()

View File

@ -1,5 +1,5 @@
<template> <template>
<ds-card> <ds-card class="filter-menu-card">
<ds-flex> <ds-flex>
<ds-flex-item class="filter-menu-title"> <ds-flex-item class="filter-menu-title">
<ds-heading size="h3">{{ $t('filter-menu.title') }}</ds-heading> <ds-heading size="h3">{{ $t('filter-menu.title') }}</ds-heading>
@ -20,6 +20,28 @@
</div> </div>
</ds-flex-item> </ds-flex-item>
</ds-flex> </ds-flex>
<div v-if="hashtag">
<ds-space margin-bottom="x-small" />
<ds-flex>
<ds-flex-item>
<ds-heading size="h3">{{ $t('filter-menu.hashtag-search', { hashtag }) }}</ds-heading>
</ds-flex-item>
<ds-flex-item>
<div class="filter-menu-buttons">
<ds-button
v-tooltip="{
content: this.$t('filter-menu.clearSearch'),
placement: 'left',
delay: { show: 500 },
}"
name="filter-by-followed-authors-only"
icon="close"
@click="clearSearch"
/>
</div>
</ds-flex-item>
</ds-flex>
</div>
</ds-card> </ds-card>
</template> </template>
@ -27,6 +49,7 @@
export default { export default {
props: { props: {
user: { type: Object, required: true }, user: { type: Object, required: true },
hashtag: { type: Object, default: null },
}, },
data() { data() {
return { return {
@ -50,11 +73,18 @@ export default {
: { author: { followedBy_some: { id: this.user.id } } } : { author: { followedBy_some: { id: this.user.id } } }
this.$emit('changeFilterBubble', this.filter) this.$emit('changeFilterBubble', this.filter)
}, },
clearSearch() {
this.$emit('clearSearch')
},
}, },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.filter-menu-card {
background-color: $background-color-soft;
}
.filter-menu-title { .filter-menu-title {
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -50,7 +50,6 @@ export default () => {
content content
contentExcerpt contentExcerpt
language language
image
} }
} }
`, `,

View File

@ -1,6 +1,8 @@
{ {
"filter-menu": { "filter-menu": {
"title": "Deine Filterblase" "title": "Deine Filterblase",
"hashtag-search": "Suche nach #{hashtag}",
"clearSearch": "Suche löschen"
}, },
"login": { "login": {
"copy": "Wenn Du bereits ein Konto bei Human Connection hast, melde Dich bitte hier an.", "copy": "Wenn Du bereits ein Konto bei Human Connection hast, melde Dich bitte hier an.",

View File

@ -1,6 +1,8 @@
{ {
"filter-menu": { "filter-menu": {
"title": "Your filter bubble" "title": "Your filter bubble",
"hashtag-search": "Searching for #{hashtag}",
"clearSearch": "Clear search"
}, },
"login": { "login": {
"copy": "If you already have a human-connection account, login here.", "copy": "If you already have a human-connection account, login here.",

View File

@ -2,7 +2,12 @@
<div> <div>
<ds-flex :width="{ base: '100%' }" gutter="base"> <ds-flex :width="{ base: '100%' }" gutter="base">
<ds-flex-item> <ds-flex-item>
<filter-menu :user="currentUser" @changeFilterBubble="changeFilterBubble" /> <filter-menu
:user="currentUser"
@changeFilterBubble="changeFilterBubble"
:hashtag="hashtag"
@clearSearch="clearSearch"
/>
</ds-flex-item> </ds-flex-item>
<hc-post-card <hc-post-card
v-for="(post, index) in uniq(Post)" v-for="(post, index) in uniq(Post)"
@ -41,12 +46,19 @@ export default {
HcLoadMore, HcLoadMore,
}, },
data() { data() {
const { hashtag = null } = this.$route.query
return { return {
// Initialize your apollo data // Initialize your apollo data
Post: [], Post: [],
page: 1, page: 1,
pageSize: 12, pageSize: 12,
filter: {}, filter: {},
hashtag,
}
},
mounted() {
if (this.hashtag) {
this.changeFilterBubble({ tags_some: { name: this.hashtag } })
} }
}, },
computed: { computed: {
@ -62,9 +74,21 @@ export default {
}, },
methods: { methods: {
changeFilterBubble(filter) { changeFilterBubble(filter) {
if (this.hashtag) {
filter = {
...filter,
tags_some: { name: this.hashtag },
}
}
this.filter = filter this.filter = filter
this.$apollo.queries.Post.refresh() this.$apollo.queries.Post.refresh()
}, },
clearSearch() {
this.$router.push({ path: '/' })
this.hashtag = null
delete this.filter.tags_some
this.changeFilterBubble(this.filter)
},
uniq(items, field = 'id') { uniq(items, field = 'id') {
return uniqBy(items, field) return uniqBy(items, field)
}, },

View File

@ -0,0 +1,12 @@
<template>
<div></div>
</template>
<script>
export default {
mounted() {
const { id: hashtag } = this.$route.params
this.$router.push({ path: '/', query: { hashtag } })
},
}
</script>