Skip to content

Commit

Permalink
refactor: ♻️ run linter
Browse files Browse the repository at this point in the history
  • Loading branch information
CRBroughton committed Nov 24, 2023
1 parent 71a14c7 commit 17fe912
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 81 deletions.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ onMounted(async () => {
watch(() => user.value?.images, () => {
if (
user.value?.images !== undefined &&
user.value?.images !== null
user.value?.images !== undefined
&& user.value?.images !== null
) {
useTimeoutFn(() => {
notificationsStore.triggerForagableNotification(user.value?.images)
Expand Down
5 changes: 1 addition & 4 deletions src/components/AddMarker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ function hide() {
emits('hide')
}
function setSelectedItem(event: UserImage) {
Object.assign(selectedItem, event)
Object.assign(selectedItem, event)
}
function create() {
Expand All @@ -61,7 +60,6 @@ function create() {
lng: lng.value,
lat: lat.value,
})
}
</script>

Expand Down Expand Up @@ -121,7 +119,6 @@ h1 {
font-size: 1.2em;
}
.slide-enter-active {
transition: all 0.2s ease-out;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/ItemDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mapboxStore = useMapbox()
const { selectedItem, selectedCollection } = storeToRefs(mapboxStore)
const pocketbaseStore = usePocketBase()
const { selectedItemPocketbase } = storeToRefs(pocketbaseStore)
const { selectedItemPocketbase } = storeToRefs(pocketbaseStore)
watch(() => selectedItem.value, () => {
if (selectedItem.value !== undefined)
Expand Down
10 changes: 3 additions & 7 deletions src/components/ServerSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ interface Emits {
}
const state = useStorage('forager-store', {
server: import.meta.env.VITE_POCKETBASE_URL,
},
localStorage,
{ mergeDefaults: true })
}, localStorage, { mergeDefaults: true })
const serverIsAlive = ref(false)
const serverClasses = computed(() => {
Expand All @@ -21,9 +18,9 @@ const serverClasses = computed(() => {
const debouncedFunction = useDebounceFn(async () => {
const { response } = await useFetch(`${state.value.server}/api/health`)
if (response.value?.status === 200)
if (response.value?.status === 200)
serverIsAlive.value = true
else
else
serverIsAlive.value = false
}, 1000)
Expand All @@ -48,7 +45,6 @@ checkConnectivityDeBounce()
</div>
<input v-model="state.server" class="login-input" type="text" name="server" placeholder="Pocketbase server address" @keydown="checkConnectivityDeBounce">
</div>

<BaseButton @click="emit('hide')">
Submit
</BaseButton>
Expand Down
2 changes: 0 additions & 2 deletions src/mapbox/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export function createLayers(map: mapboxgl.Map) {
},
})


// Add label layer
map.addLayer({
id: 'marker-labels',
Expand All @@ -47,7 +46,6 @@ export function createLayers(map: mapboxgl.Map) {
},
})


// Add clustering layer
map.addLayer({
id: 'clusters',
Expand Down
18 changes: 5 additions & 13 deletions src/stores/mapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type { LandmarksRecord } from '../pocketbase-types'
import { usePocketBase } from '@/stores'
import { user } from '@/utils/pocketbase'


export const useMapbox = defineStore('mapbox-store', () => {
const userStore = usePocketBase()
mapboxgl.accessToken = userStore.user?.mapboxAPIKey
Expand Down Expand Up @@ -92,7 +91,6 @@ export const useMapbox = defineStore('mapbox-store', () => {
return itemLayer.value
}


const initMapbox = async () => {
map = new mapboxgl.Map({
container: 'map',
Expand Down Expand Up @@ -120,9 +118,10 @@ export const useMapbox = defineStore('mapbox-store', () => {
},
})

if (map)
if (map)
createLandmarks(map)
})
},
)

map?.addSource('items', {
type: 'geojson',
Expand All @@ -135,10 +134,6 @@ export const useMapbox = defineStore('mapbox-store', () => {
clusterRadius: 50,
})





// const { getRoute } = usePocketBase()
// const lineCoords = await getRoute('4t2ttp1beq31p2r')

Expand Down Expand Up @@ -180,7 +175,6 @@ export const useMapbox = defineStore('mapbox-store', () => {
// add the DEM source as a terrain layer with exaggerated height
map?.setTerrain({ source: 'mapbox-dem', exaggeration: 1.5 })
})

}
map.on('click', async (e: MapMouseEvent) => {
if (user.value?.lat === 0 && user.value.lng === 0) {
Expand Down Expand Up @@ -225,12 +219,12 @@ export const useMapbox = defineStore('mapbox-store', () => {
selectedCollection.value = 'landmarks'
})
map.on('mouseenter', 'landmark', () => {
if (map)
if (map)
map.getCanvas().style.cursor = 'pointer'
})

map.on('mouseleave', 'landmark', () => {
if (map)
if (map)
map.getCanvas().style.cursor = ''
})
}
Expand Down Expand Up @@ -258,7 +252,6 @@ export const useMapbox = defineStore('mapbox-store', () => {
type: 'FeatureCollection',
features: itemLayer.value,
})

}

const addMarker = async (lng: number, lat: number, selectedImage: UserImage) => {
Expand Down Expand Up @@ -303,7 +296,6 @@ export const useMapbox = defineStore('mapbox-store', () => {
await deleteItem(id, selectedCollection.value)

if (selectedCollection.value === 'items') {

items.value = await getItems()

const itemLayer = ref<Feature[]>([])
Expand Down
28 changes: 12 additions & 16 deletions src/stores/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@ export const notifications = defineStore('notifications-store', () => {
}
}
const createNotification = (notification: Notification) => {
return new Notification(notification.title,
{ body: notification.content?.body },
)
return new Notification(notification.title, { body: notification.content?.body })
}

const months = [
'January',
'February',
'March',
'April',
'May',
'April',
'May',
'June',
'July',
'July',
'August',
'September',
'October',
'October',
'November',
'December',
]
Expand Down Expand Up @@ -72,7 +70,7 @@ export const notifications = defineStore('notifications-store', () => {
await pb.collection('notifications').create<NotificationsRecord>(notification)
}
catch (error) {
if (isError(error))
if (isError(error))
setErrorMessage(error)
}
}
Expand All @@ -83,25 +81,24 @@ export const notifications = defineStore('notifications-store', () => {

const triggerForagableNotification = async (items: ItemsRecordWithID[]) => {
let customItems: string[] = []
if (items === undefined)
if (items === undefined)
return

if (filterMonthlyForagables(items).length === 0)
if (filterMonthlyForagables(items).length === 0)
return

const hasStoredMonthlyUpdate = await getStoredNotifications('monthly-update')
if (hasStoredMonthlyUpdate === true)
if (hasStoredMonthlyUpdate === true)
return


filterMonthlyForagables(items).forEach((item) => {
customItems = [...customItems, ` ${item.name}`]
})

const newMonthlyNotification = {
title:'Monthly foragables!',
title: 'Monthly foragables!',
content: {
body:`You can find${ customItems } this month`,
body: `You can find${customItems} this month`,
},
}
createNotification(newMonthlyNotification)
Expand All @@ -112,7 +109,6 @@ export const notifications = defineStore('notifications-store', () => {
title: newMonthlyNotification.title,
body: newMonthlyNotification.content.body,
})

}

return {
Expand Down
Loading

0 comments on commit 17fe912

Please sign in to comment.