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 Jul 5, 2023
2 parents 664900c + ea7750f commit f28a404
Show file tree
Hide file tree
Showing 40 changed files with 313 additions and 72 deletions.
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 1205
versionName "3.0.3"
versionCode 1207
versionName "3.0.5"
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 android/app/src/main/res/xml/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
<widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<access origin="*" />

<feature name="Calendar">
<param name="android-package" value="nl.xservices.plugins.Calendar"/>
</feature>

<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
</feature>
Expand Down
4 changes: 2 additions & 2 deletions api/BaseAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class BaseAPI {
console.log('Log it?', log)

if (log) {
Sentry.captureException(
Sentry.captureMessage(
'API request failed ' +
path +
' returned HTTP ' +
Expand Down Expand Up @@ -368,7 +368,7 @@ export default class BaseAPI {
const log = typeof logError === 'function' ? logError(data) : logError

if (log) {
Sentry.captureException(
Sentry.captureMessage(
'API request failed ' +
path +
' returned HTTP ' +
Expand Down
4 changes: 4 additions & 0 deletions api/CommunityEventAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class CommunityEventAPI extends BaseAPI {
return this.$getv2('/communityevent')
}

listGroup(id) {
return this.$getv2('/communityevent/group/' + id)
}

save(data) {
return this.$patch('/communityevent', data)
}
Expand Down
4 changes: 2 additions & 2 deletions api/ConfigAPI.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 ConfigAPI extends BaseAPI {
async get(params) {
const ret = await this.$get('/config', params)
return ret.values
// https://api.ilovefreegle.org/apiv2/config/app_fd_version_android_latest etc
return await this.$getv2('/config/' + params.key)
}
}
4 changes: 4 additions & 0 deletions api/VolunteeringAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ export default class VolunteeringAPI extends BaseAPI {
return this.$getv2('/volunteering')
}

listGroup(id) {
return this.$getv2('/volunteering/group/' + id)
}

save(data) {
return this.$patch('/volunteering', data)
}
Expand Down
20 changes: 16 additions & 4 deletions app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<MainHeader />
</client-only>
<NuxtLayout v-if="ready">
<NuxtPage :key="loginCount" />
<NuxtPage />
</NuxtLayout>
</div>
</template>
<script setup>
import { useRoute } from 'vue-router'
import { computed } from 'vue'
import { computed, watch, nextTick, reloadNuxtApp } from '#imports'
import { useNoticeboardStore } from './stores/noticeboard'
import { useAuthStore } from './stores/auth'
import { useGroupStore } from './stores/group'
Expand Down Expand Up @@ -117,12 +117,24 @@ 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.
// We use a key to force the whole page to re-load 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, but using a key on
// NuxtPage results in errors which can cause the JS to bomb out.
let loginKey = ref(0)
const loginCount = computed(() => {
return authStore.loginCount
})
watch(loginCount, async () => {
if (!route.query.k) {
await reloadNuxtApp({
force: true,
persistState: false
})
}
})
try {
if (route.query.u && route.query.k) {
// We are impersonating.
Expand Down
2 changes: 2 additions & 0 deletions capacitor.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const config: CapacitorConfig = {
},
android: {
includePlugins: [
"cordova-plugin-calendar",
"cordova-plugin-inappbrowser",
"@capacitor/app-launcher",
"@capacitor/browser",
Expand All @@ -53,6 +54,7 @@ const config: CapacitorConfig = {
scheme: 'App', // Freegle
contentInset: 'automatic',
includePlugins: [
"cordova-plugin-calendar",
"cordova-plugin-inappbrowser",
"@capacitor/app-launcher",
"@capacitor/browser",
Expand Down
64 changes: 61 additions & 3 deletions components/AddToCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</template>
<script>
import saveAs from 'save-file'
import { useMobileStore } from '@/stores/mobile'
export default {
props: {
Expand All @@ -29,11 +30,68 @@ export default {
methods: {
async download(e) {
// https://www.npmjs.com/package/save-file
console.log("AddToCalendar download")
e.preventDefault()
e.stopPropagation()
const blob = new Blob([this.ics], { type: 'text/calendar;charset=utf-8' })
await saveAs(blob, 'freegle-handover.ics')
const mobileStore = useMobileStore()
if( !mobileStore.isApp){
const blob = new Blob([this.ics], { type: 'text/calendar;charset=utf-8' })
await saveAs(blob, 'freegle-handover.ics')
return
}
/*const blob = new Blob([this.ics], { type: 'application/octet-stream' })
const link = document.createElement('a')
link.href = URL.createObjectURL(blob)
link.download = 'freegle-handover.ics'
link.click()
URL.revokeObjectURL(link.href)*/
/*// https://capacitorjs.com/docs/apis/filesystem
await Filesystem.writeFile({
path: 'freegle-handover.ics',
data: this.ics,
directory: Directory.Documents,
encoding: Encoding.UTF8,
})*/
// webcal://localhost/myCalendar.ics
// https://www.npmjs.com/package/cordova-plugin-calendar
function getCalProp(lines,name){
name += ':'
const namelen = name.length
for(let i=0;i<lines.length;i++){
const line = lines[i]
if( line.length>=namelen){
if( line.substring(0,namelen)===name){
let rv = line.substring(namelen)
while (++i < lines.length) {
const nextline = lines[i]
if (nextline.substring(0,1)!==' ') break
rv += nextline.substring(1)
}
return rv
}
}
}
return ''
}
const lines = this.ics.split('\r\n')
const dtstart = getCalProp(lines, 'DTSTART;TZID=Europe/London') // 20210109T110000
const year = parseInt(dtstart.substring(0,4))
const month = parseInt(dtstart.substring(4,6))-1
const dom = parseInt(dtstart.substring(6,8))
const hour = parseInt(dtstart.substring(9,11))
const mins = parseInt(dtstart.substring(11,13))
const secs = parseInt(dtstart.substring(13,15))
const startDate = new Date(year, month, dom, hour, mins, secs)
const endDate = new Date(startDate.getTime()+5*60*1000)
const title = getCalProp(lines, 'SUMMARY')
const eventLocation = ''
const notes = getCalProp(lines, 'DESCRIPTION')
const success = function (message) { console.log("Add calendar success", JSON.stringify(message)) }
const error = function (message) { alert("Error: " + message) } // TODO
console.log('window.plugins',window.plugins)
window.plugins.calendar.createEventInteractively(title, eventLocation, notes, startDate, endDate, success, error)
},
},
}
Expand Down
10 changes: 8 additions & 2 deletions components/ChatButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
</template>
<script>
import { useChatStore } from '../stores/chat'
import { useMessageStore } from '../stores/message'
import { useRouter } from '#imports'
export default {
Expand Down Expand Up @@ -83,9 +84,11 @@ export default {
},
setup() {
const chatStore = useChatStore()
const messageStore = useMessageStore()
return {
chatStore,
messageStore,
}
},
methods: {
Expand Down Expand Up @@ -130,10 +133,13 @@ export default {
console.log('Sent')
if (firstmsgid) {
// Refresh the message so that our reply will show.
await this.chatStore.fetchMessages(chatid, true)
// Update the message so that the reply count is updated. No need to wait.
this.messageStore.fetch(firstmsgid, true)
}
// Refresh the message so that our reply will show.
await this.chatStore.fetchMessages(chatid, true)
this.$emit('sent')
}
Expand Down
22 changes: 13 additions & 9 deletions components/ChatMessageCompleted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<div class="small">
<v-icon icon="info-circle" />
<span v-if="refmsg?.type === 'Offer'">
This is no longer available.
</span>
This is no longer available.
</span>
<span v-else> Thanks, this has now been received. </span>
</div>
</NoticeMessage>
Expand All @@ -44,7 +44,9 @@
This is no longer available.
</span>
<span v-else> Thanks, this has now been received. </span>
<div class="text-muted small">This is an automated message.</div>
<div class="text-muted small">
This is an automated message.
</div>
</div>
</b-card-text>
</b-card>
Expand Down Expand Up @@ -76,8 +78,8 @@
<div class="text-muted small">
<v-icon icon="info-circle" />
<span v-if="refmsg?.type === 'Offer'">
This is no longer available.
</span>
This is no longer available.
</span>
<span v-else> Thanks, this has now been received. </span>
</div>
</NoticeMessage>
Expand All @@ -87,11 +89,13 @@
</div>
<div v-else>
<v-icon icon="info-circle" />
<span v-if="refmsg.type === 'Offer'">
<span v-if="refmsg?.type === 'Offer'">
We've let them know this is no longer available.
</span>
<span v-else> This has now been received. </span>
<div class="text-muted small">This is an automated message.</div>
<div class="text-muted small">
This is an automated message.
</div>
</div>
</b-card-text>
</b-card>
Expand All @@ -101,11 +105,11 @@
</div>
</template>
<script>
import ChatBase from '~/components/ChatBase'
import NoticeMessage from './NoticeMessage'
import ChatBase from '~/components/ChatBase'
export default {
components: {NoticeMessage},
components: { NoticeMessage },
extends: ChatBase,
}
</script>
2 changes: 1 addition & 1 deletion components/ChatMessageSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export default {
this.imageBroken = true
},
click() {
if (this.message.fromuser === this.myid) {
if (this.myid && this.message.fromuser === this.myid) {
this.$router.push('/mypost/' + this.id)
} else {
this.$router.push('/message/' + this.id)
Expand Down
6 changes: 5 additions & 1 deletion components/DraggableMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ export default {
required: false,
default: 5,
},
maxZoom: {
type: Number,
required: false,
default: MAX_MAP_ZOOM,
}
},
async setup() {
const runtimeConfig = useRuntimeConfig()
Expand All @@ -73,7 +78,6 @@ export default {
mapObject: null,
center: [53.945, -2.5209],
zoom: 14,
maxZoom: MAX_MAP_ZOOM,
}
},
computed: {
Expand Down
Loading

0 comments on commit f28a404

Please sign in to comment.