Skip to content

Commit

Permalink
Merge branch 'app' into app-publish
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscant committed Jun 21, 2023
2 parents 38ec25c + 4eec7cf commit 1182be3
Show file tree
Hide file tree
Showing 207 changed files with 2,229 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/azure-functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
env:
NITRO_PRESET: azure-functions
IZNIK_API_V1: https://fdapilive.ilovefreegle.org/api
IZNIK_API_V2: https://api.ilovefreegle.org:8192/apiv2
IZNIK_API_V2: https://api.ilovefreegle.org/apiv2

- name: 'Deploy to Azure Functions'
uses: Azure/functions-action@v1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ npm install --legacy-peer-deps
Set some environment variables:
```
IZNIK_API_V1=https://fdapidbg.ilovefreegle.org/api
IZNIK_API_V2=https://api.ilovefreegle.org:8192/apiv2
IZNIK_API_V2=https://api.ilovefreegle.org/apiv2
```

(if running the Go Server locally then http://localhost:8192/api)
Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "org.ilovefreegle.direct"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1201
versionName "3.0.1"
versionCode 1202
versionName "3.0.2"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 4 additions & 0 deletions api/AddressAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class AddressAPI extends BaseAPI {
return this.$getv2('/address')
}

fetchByIdv2(id, logError = true) {
return this.$getv2('/address/' + id, [], logError)
}

add(data) {
return this.$put('/address', data)
}
Expand Down
18 changes: 17 additions & 1 deletion api/BaseAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ import { useAuthStore } from '~/stores/auth'
import { useMobileStore } from '~/stores/mobile'
import { useMiscStore } from '~/stores/misc'

let timer = 0

// We add fetch retrying.
// Note that $fetch and useFetch cause problems on Node v18, so we don't use them.
const ourFetch = fetchRetry(fetch, {
retries: 10,
retryOn: (attempt, error, response) => {
if (useMiscStore()?.unloading) {
// Don't retry if we're unloading.
console.log("Unloading - don't retry")
return false
}

// Retry on pretty much anything except errors which can legitimately be returned by the API server. These are
// the low 400s.
if (error !== null || response?.status > 404) {
Expand Down Expand Up @@ -262,6 +270,12 @@ export default class BaseAPI {
}

async $requestv2(method, path, config, logError = true, body = null) {
timer++
const timerLabel = path + ' api-' + timer

console.log('Start ', timerLabel)
console.time(timerLabel)

let status = null
let data = null

Expand Down Expand Up @@ -344,7 +358,7 @@ export default class BaseAPI {
// probably do the right thing.
// - otherwise throw an exception.
if (status !== 200 || !data) {
const statusstr = data && data.status ? data.status : 'Unknown'
const statusstr = status.toString()

// Whether or not we log this error to Sentry depends. Most errors are worth logging, because they're unexpected.
// But some API calls are expected to fail, and throw an exception which is then handled in the code. We don't
Expand Down Expand Up @@ -390,6 +404,8 @@ export default class BaseAPI {
)
}

console.timeEnd(timerLabel)

return data
}

Expand Down
48 changes: 9 additions & 39 deletions api/ChatAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ export default class ChatAPI extends BaseAPI {
return this.$getv2(`/chat/${chatid}/message`)
}

async listChats(since, search) {
return await this.$getv2('/chat', {
since,
search,
})
async listChats(since, search, logError) {
return await this.$getv2(
'/chat',
{
since,
search,
},
logError
)
}

fetchChat(chatid, logError) {
Expand Down Expand Up @@ -54,40 +58,6 @@ export default class ChatAPI extends BaseAPI {
return this.$post('/chatrooms', { id: chatid, status: 'Blocked' })
}

unseenCount(chatid) {
return this.$get('/chatrooms', {
count: true,
chattypes: ['User2User', 'User2Mod'],
})
}

hold(msgid) {
return this.$post('/chatmessages', { id: msgid, action: 'Hold' })
}

release(msgid) {
return this.$post('/chatmessages', { id: msgid, action: 'Release' })
}

redact(msgid) {
return this.$post('/chatmessages', { id: msgid, action: 'Redact' })
}

reject(msgid) {
return this.$post('/chatmessages', { id: msgid, action: 'Reject' })
}

approve(msgid) {
return this.$post('/chatmessages', { id: msgid, action: 'Approve' })
}

whitelist(msgid) {
return this.$post('/chatmessages', {
id: msgid,
action: 'ApproveAllFuture',
})
}

rsvp(id, chatid, value) {
return this.$patch('/chatmessages', {
roomid: chatid,
Expand Down
4 changes: 2 additions & 2 deletions api/CommunityEventAPI.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseAPI from '@/api/BaseAPI'

export default class CommunityEventAPI extends BaseAPI {
fetch(id) {
return this.$getv2('/communityevent/' + id)
fetch(id, logError = true) {
return this.$getv2('/communityevent/' + id, {}, logError)
}

list(id) {
Expand Down
7 changes: 7 additions & 0 deletions api/DashboardAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ export default class DashboardAPI extends BaseAPI {
const { dashboard, components } = await this.$get('/dashboard', params)
return dashboard || components
}

async fetchHeatmap(params) {
const { heatmap } = await this.$get('/dashboard', {
heatmap: true,
})
return heatmap
}
}
2 changes: 1 addition & 1 deletion api/NewsAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class NewsAPI extends BaseAPI {
}

async seen(id) {
await this.$post('/newsfeed', { id, action: 'Seen' })
await this.$post('/newsfeed?bump=' + id, { id, action: 'Seen' })
}

del(id) {
Expand Down
2 changes: 1 addition & 1 deletion api/NotificationAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import BaseAPI from '@/api/BaseAPI'

export default class NotificationAPI extends BaseAPI {
count() {
return this.$getv2('/notification/count')
return this.$getv2('/notification/count', {}, false)
}

list() {
Expand Down
4 changes: 0 additions & 4 deletions api/SessionAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@ export default class SessionAPI extends BaseAPI {
fetch(params) {
// Add the build date to the call. This is used by the server to spot out of date apps, but we need
// to make it clear that we're not an app at all.
const runtimeConfig = useRuntimeConfig()
params.webversion = runtimeConfig.public.BUILD_DATE
return this.$get('/session', params)
}

fetchv2(params, log = true) {
const runtimeConfig = useRuntimeConfig()
params.webversion = runtimeConfig.public.BUILD_DATE
return this.$getv2('/user', params, log)
}

Expand Down
4 changes: 2 additions & 2 deletions api/VolunteeringAPI.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BaseAPI from '@/api/BaseAPI'

export default class VolunteeringAPI extends BaseAPI {
fetch(id) {
return this.$getv2('/volunteering/' + id)
fetch(id, logError = true) {
return this.$getv2('/volunteering/' + id, {}, logError)
}

list(id) {
Expand Down
3 changes: 3 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { useImageStore } from './stores/image'
import { useDomainStore } from './stores/domain'
import { useLogoStore } from './stores/logo'
import { useLocationStore } from './stores/location'
import { useShortlinkStore } from './stores/shortlinks'
const route = useRoute()
Expand Down Expand Up @@ -83,6 +84,7 @@ const imageStore = useImageStore()
const domainStore = useDomainStore()
const logoStore = useLogoStore()
const locationStore = useLocationStore()
const shortlinkStore = useShortlinkStore()
groupStore.init(runtimeConfig)
messageStore.init(runtimeConfig)
Expand Down Expand Up @@ -113,6 +115,7 @@ imageStore.init(runtimeConfig)
domainStore.init(runtimeConfig)
logoStore.init(runtimeConfig)
locationStore.init(runtimeConfig)
shortlinkStore.init(runtimeConfig)
// We use a key to force the whole page to re-render if we have logged in. This is a sledgehammer way of
// re-calling all the setup() methods etc. Perhaps there's a better way to do this.
Expand Down
6 changes: 6 additions & 0 deletions assets/css/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ form {
}
}

.modal-content {
// Need to make this scrollable so that e.g. login modal can all be accessed on screens with small height.
overflow-y: auto !important;
max-height: 100% !important;
}

label {
font-weight: bold !important;
}
Expand Down
43 changes: 40 additions & 3 deletions components/AdaptiveMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
v-if="me"
v-model="selectedGroup"
label="Communities to view"
label-visually-hidden
label-sr-only
all
all-my
/>
Expand Down Expand Up @@ -282,13 +282,45 @@ export default {
const selectedType = ref(postType || 'All')
const showGroups = ref(props.startOnGroups)
const groupids = ref(props.initialGroupIds)
const swlat = ref(props.initialBounds[0][0])
const swlng = ref(props.initialBounds[0][1])
const nelat = ref(props.initialBounds[1][0])
const nelng = ref(props.initialBounds[1][1])
const search = ref(props.initialSearch)
const searchOn = ref(props.initialSearch)
const groupsInMap = ref(null)
const groupids = computed(() => {
const gids = props.initialGroupIds
const allGroups = Object.values(groupStore.list)
// Find groups from allGroups with an id in groupids
const groups = allGroups.filter((group) => {
if (groupsInMap.value) {
return groupsInMap.value.includes(group.id)
}
return gids.includes(group.id)
})
// Sort groups by namedisplay case-insensitive ascending
groups.sort((a, b) => {
const nameA = a.namedisplay.toUpperCase()
const nameB = b.namedisplay.toUpperCase()
if (nameA < nameB) {
return -1
}
if (nameA > nameB) {
return 1
}
// names must be equal
return 0
})
return groups.map((group) => group.id)
})
if (process.client) {
const L = await import('leaflet/dist/leaflet-src.esm')
Expand Down Expand Up @@ -317,6 +349,7 @@ export default {
nelng,
search,
searchOn,
groupsInMap,
}
},
data() {
Expand Down Expand Up @@ -576,7 +609,10 @@ export default {
}
},
groupsChanged(groupids) {
this.groupids = groupids
// When we're showing a region, we want to keep listing all the same groups even if we zoom about.
if (!this.region) {
this.groupsInMap = groupids
}
},
doSearch() {
if (this.search) {
Expand Down Expand Up @@ -605,6 +641,7 @@ export default {
.postcode {
position: absolute;
top: 0px;
right: 0px;
z-index: 20000;
}
Expand Down
5 changes: 4 additions & 1 deletion components/AdaptiveMapGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ export default {
required: true,
},
},
setup() {
setup(props) {
const groupStore = useGroupStore()
// Fetch the full group so that we get the tagline.
groupStore.fetch(props.id, true)
return {
groupStore,
}
Expand Down
2 changes: 1 addition & 1 deletion components/AutoComplete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export default {
// Force the list to show.
this.showList = true
this.startTimer()
let value = this.$refs.input.value
let value = this.$refs.input?.value
if (value) {
this.getData(value)
}
Expand Down
5 changes: 1 addition & 4 deletions components/ChatHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@
View profile
</b-button>
</div>
<div
v-if="chat.chattype === 'User2User' || chat.chattype === 'User2Mod'"
class="mr-2"
>
<div v-if="chat.chattype === 'User2User' || !unseen" class="mr-2">
<b-button
v-b-tooltip="
'Don\'t show this chat unless there\'s a new message'
Expand Down
10 changes: 9 additions & 1 deletion components/ChatMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,18 @@ export default {
}
</script>
<style scoped lang="scss">
@import '~bootstrap/scss/functions';
@import '~bootstrap/scss/variables';
@import '~bootstrap/scss/mixins/_breakpoints';
.chatbadge {
position: absolute;
top: 0px;
left: 25px;
left: 18px;
@include media-breakpoint-up(xl) {
left: 22px;
}
}
.chat__icon {
Expand Down
Loading

0 comments on commit 1182be3

Please sign in to comment.