Skip to content

Commit

Permalink
Merge pull request #34 from Freegle/remove-wait-for-ref
Browse files Browse the repository at this point in the history
Remove wait for ref
  • Loading branch information
edwh authored Oct 12, 2023
2 parents ab11e8b + 9d0254a commit 45998fd
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 91 deletions.
1 change: 0 additions & 1 deletion components/DraggableMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ export default {
async ready() {
const self = this
await this.waitForRef('map')
if (process.client) {
this.mapObject = this.$refs.map.leafletObject
Expand Down
4 changes: 2 additions & 2 deletions components/ExternalDa.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
</div>
</template>
<script setup>
import { nextTick } from 'vue'
import { useMiscStore } from '../stores/misc'
import { ref, computed, onBeforeUnmount } from '#imports'
import { waitForRef } from '~/composables/useWaitForRef'
const props = defineProps({
adUnitPath: {
Expand Down Expand Up @@ -108,7 +108,7 @@ async function visibilityChanged(visible) {
isVisible.value = visible
shownFirst = true
await waitForRef(uniqueid)
await nextTick()
window.googletag = window.googletag || { cmd: [] }
window.googletag.cmd.push(function () {
Expand Down
3 changes: 1 addition & 2 deletions components/LoginModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ export default {
this.forceLogin = false
this.$router.push('/forgot')
},
async installGoogleSDK() {
installGoogleSDK() {
if (
window &&
window.google &&
Expand All @@ -637,7 +637,6 @@ export default {
document.getElementById('googleLoginButton')
)
await this.waitForRef('googleLoginButton')
console.log('Found google button ref')
window.google.accounts.id.renderButton(
document.getElementById('googleLoginButton'),
Expand Down
5 changes: 4 additions & 1 deletion components/MessageReplySection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
</template>
<script>
import { mapWritableState } from 'pinia'
import { nextTick } from 'vue'
import { useMessageStore } from '../stores/message'
import { useAuthStore } from '../stores/auth'
import { useReplyStore } from '../stores/reply'
Expand Down Expand Up @@ -220,7 +221,9 @@ export default {
// Show the new user modal.
this.newUserPassword = ret.password
this.showNewUser = true
await this.waitForRef('newUserModal')
await nextTick()
// Now that we are logged in, we can reply.
this.$refs.newUserModal?.show()
Expand Down
3 changes: 1 addition & 2 deletions components/NewsReply.vue
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,10 @@ export default {
this.showProfileModal = true
},
async replyReply() {
console.log('Replying to', this.replyid, this.reply)
this.replyingTo = this.replyid
this.showReplyBox = true
await this.waitForRef('replybox')
await this.$nextTick()
this.$refs.replybox.$el.focus()
// Reply with tag.
Expand Down
5 changes: 2 additions & 3 deletions components/NewsThread.vue
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ export default {
this.scrollDownTo = this.scrollTo
}
},
async focusComment() {
await this.waitForRef('threadcomment')
focusComment() {
this.$refs.threadcomment.$el.focus()
},
focusedComment() {
Expand Down Expand Up @@ -472,7 +471,7 @@ export default {
this.threadcomment += '\n'
}
},
async show() {
show() {
this.showEditModal = true
},
async save() {
Expand Down
2 changes: 1 addition & 1 deletion components/OurMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export default {
}
if (this.scrollIntoView) {
await this.waitForRef('msg')
await this.$nextTick()
this.$refs.msg.scrollIntoView()
}
},
Expand Down
4 changes: 1 addition & 3 deletions components/PostCode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ export default {
return runtimeConfig.public.APIv1 + '/locations'
},
},
async mounted() {
await this.waitForRef('autocomplete')
mounted() {
if (this.$refs.autocomplete) {
if (this.focus) {
// Focus on postcode to grab their attention.
Expand Down
1 change: 0 additions & 1 deletion components/PostMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ export default {
async ready() {
const self = this
this.waitForRef('map')
this.$emit('update:ready', true)
this.mapObject = this.$refs.map.leafletObject
this.$refs.map.leafletObject.fitBounds(this.initialBounds)
Expand Down
9 changes: 4 additions & 5 deletions components/PostMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default {
photoid: id,
})
},
drop(e) {
async drop(e) {
// Although it's probably not widely used (I didn't know it even worked) in the old code you could drag and drog
// a file onto the Add photos button. So we should handle that too here.
const droppedFiles = e.dataTransfer.files
Expand All @@ -195,10 +195,9 @@ export default {
this.pondBrowse = false
// Give pond time to render.
this.waitForRef('filepond').then(() => {
;[...droppedFiles].forEach((f) => {
this.$refs.filepond.addFile(f)
})
await this.$nextTick()
;[...droppedFiles].forEach((f) => {
this.$refs.filepond.addFile(f)
})
},
hidePhotoButton() {
Expand Down
1 change: 0 additions & 1 deletion components/SpinButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
</template>
<script setup>
import { ref, defineAsyncComponent } from '#imports'
import { waitForRef } from '~/composables/useWaitForRef'
const ConfirmModal = defineAsyncComponent(() => import('./ConfirmModal'))
Expand Down
6 changes: 2 additions & 4 deletions components/VisualiseMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,22 +180,20 @@ export default {
setTimeout(() => {
// Show the reply text.
this.showReplies = true
setTimeout(async () => {
setTimeout(() => {
// Collect - move the touser to the fromuser's location, stop showing the other replies.
this.showOthers = false
this.showReplies = false
await this.waitForRef('touser')
this.$refs.touser.setLatLng(
this.item.fromlat,
this.item.fromlng
)
setTimeout(async () => {
setTimeout(() => {
if (this.$refs.touser && this.item) {
this.$refs.touser.setLatLng(
this.item.tolat,
this.item.tolng
)
await this.waitForRef('message')
this.$refs.message.setLatLng(
this.item.tolat,
this.item.tolng
Expand Down
19 changes: 0 additions & 19 deletions composables/useWaitForRef.js

This file was deleted.

1 change: 0 additions & 1 deletion mixins/replyToPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export default {
)

// Open the chat, which will send the message and go to the chat. The chat will clear the store.
await this.waitForRef('replyToPostChatButton')
await this.$refs.replyToPostChatButton.openChat(
null,
this.replyToSend.replyMessage,
Expand Down
5 changes: 2 additions & 3 deletions pages/help.vue
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,8 @@ export default {
return date.format('Do MMMM, YYYY') + ' at ' + date.format('HH:mm')
},
},
async mounted() {
mounted() {
// Scan the FAQs above and extract the plain text for each one, and then construct a search index.
await this.waitForRef('faq')
const faqs = this.$refs.faq.children
this.forIndex = []
Expand All @@ -424,7 +423,7 @@ export default {
})
},
methods: {
async supporterInfo() {
supporterInfo() {
this.showInfoModal = true
},
},
Expand Down
1 change: 0 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ export default {
},
async play() {
if (process.client) {
await this.waitForRef('video')
try {
const videoEl = document.querySelector('video')
videoEl.muted = true
Expand Down
41 changes: 0 additions & 41 deletions plugins/waitForRef.js

This file was deleted.

0 comments on commit 45998fd

Please sign in to comment.