Skip to content

Commit

Permalink
feat: change tag separator
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Oct 18, 2022
1 parent 03b27da commit c6d3c1f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions assets/js/RouterHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class RouterHelper {
static generatePostsRoute(domain, page, tags) {
const route = {
path: '/',
query: {},
query: {}
}

if (domain != null) {
Expand All @@ -20,7 +20,7 @@ export class RouterHelper {

// Fix: separate tags by commas instead of repeating `tags`, like so: `&tags=example1&tags=example2`
if (tags != null && Array.isArray(tags) && tags.length) {
route.query.tags = tags.join(',')
route.query.tags = tags.join('|')
}

return route
Expand Down
55 changes: 29 additions & 26 deletions store/booru.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { booruTypeList, defaultBooruList, findBoorusWithValueByKey, } from '~/assets/lib/rule-34-shared-resources/src/util/BooruUtils.js'
import {
booruTypeList,
defaultBooruList,
findBoorusWithValueByKey
} from '~/assets/lib/rule-34-shared-resources/src/util/BooruUtils.js'
import { RouterHelper } from '~/assets/js/RouterHelper'

export const state = () => ({
history: {
lastDomainUsed: defaultBooruList[0].domain,
lastDomainUsed: defaultBooruList[0].domain
},

posts: {
data: [],
},
data: []
}
})

export const getters = {
Expand Down Expand Up @@ -73,8 +77,8 @@ export const getters = {
return []
}

return tags.split(',')
},
return tags.split('|')
}
}

export const mutations = {
Expand All @@ -84,7 +88,7 @@ export const mutations = {

setPostsData(state, value) {
state.posts.data = Object.freeze(value)
},
}
}

export const actions = {
Expand All @@ -101,12 +105,12 @@ export const actions = {

if (booru == null) {
this.$sentry.captureException(
new Error(`Could not find booru with domain: ${ value }`),
new Error(`Could not find booru with domain: ${value}`),
{
extra: {
domain: value,
booruList: getters.getBooruList,
},
booruList: getters.getBooruList
}
}
)
return
Expand Down Expand Up @@ -205,15 +209,15 @@ export const actions = {
posts: {
limit: rootState.user.settings.postsPerPage.value,
pageID: getters.getPageID,
tags: getters.getTags.join(','),
score: rootState.user.settings.score.value,
tags: getters.getTags.join('|'),
score: rootState.user.settings.score.value
},

singlePost: {
id: postID,
id: postID
},

tags: { tag, limit: 15, order: 'count' },
tags: { tag, limit: 15, order: 'count' }
}

const urlToFetch = new URL(
Expand Down Expand Up @@ -297,22 +301,23 @@ export const actions = {
const ACTIVE_BOORU_DOMAIN = getters.getActiveBooru.domain

try {
const response = await dispatch('simpleApiFetch',
const response = await dispatch(
'simpleApiFetch',
{
url,
url
},
{ root: true }
)

// This is how a final booru object looks like
const POSTS = response.data.map((POST) => {
return {
id: `${ ACTIVE_BOORU_DOMAIN }-${ POST.id }`,
id: `${ACTIVE_BOORU_DOMAIN}-${POST.id}`,
data: POST,
meta_data: {
booru_domain: ACTIVE_BOORU_DOMAIN,
created_at: null,
},
created_at: null
}
}
})

Expand All @@ -324,8 +329,7 @@ export const actions = {

//
} catch (error) {

this.$toast.error(`Could not fetch posts: "${ error.message }"`)
this.$toast.error(`Could not fetch posts: "${error.message}"`)
}
},

Expand All @@ -338,26 +342,25 @@ export const actions = {
const response = await dispatch(
'simpleApiFetch',
{
url,
url
},
{ root: true }
)

// This is how a final Booru Tag object looks like
const TAGS = response.data.map((TAG) => {
return {
id: `${ ACTIVE_BOORU_DOMAIN }-${ TAG.name }`,
id: `${ACTIVE_BOORU_DOMAIN}-${TAG.name}`,
name: TAG.name,
count: TAG.count,
count: TAG.count
}
})

return TAGS

//
} catch (error) {

// this.$toast.error(`Could not search tags: "${ error.message }"`)
}
},
}
}

0 comments on commit c6d3c1f

Please sign in to comment.