Commit 47e50905 authored by Kasper Seweryn's avatar Kasper Seweryn 🥞 Committed by Kasper Seweryn
Browse files

Rename AppModule to InitModule

parent 8ee6ea91
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import createAuthRefreshInterceptor from 'axios-auth-refresh'
import axios, { AxiosError } from 'axios'
......@@ -7,7 +7,7 @@ import logger from '~/logging'
import { parseAPIErrors } from '~/utils'
import Vue from 'vue'
export const install: AppModule = ({ app, store, router }) => {
export const install: InitModule = ({ app, store, router }) => {
axios.defaults.xsrfCookieName = 'csrftoken'
axios.defaults.xsrfHeaderName = 'X-CSRFToken'
axios.interceptors.request.use(function (config) {
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import jQuery from '~/jquery'
export const install: AppModule = ({ app, store }) => {
export const install: InitModule = ({ app, store }) => {
app.directive('title', function (el, binding) {
store.commit('ui/pageTitle', binding.value)
})
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import Vue from 'vue'
import time from '~/utils/time'
......@@ -123,7 +123,7 @@ export function unique (list: { [key: string]: unknown }[], property: string) {
return unique
}
export const install: AppModule = () => {
export const install: InitModule = () => {
Vue.filter('humanSize', humanSize)
Vue.filter('unique', unique)
Vue.filter('capitalize', capitalize)
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import HumanDate from '~/components/common/HumanDate.vue'
import HumanDuration from '~/components/common/HumanDuration.vue'
......@@ -20,7 +20,7 @@ import RenderedDescription from '~/components/common/RenderedDescription.vue'
import ContentForm from '~/components/common/ContentForm.vue'
import InlineSearchBar from '~/components/common/InlineSearchBar.vue'
export const install: AppModule = ({ app }) => {
export const install: InitModule = ({ app }) => {
app.component('HumanDate', HumanDate)
app.component('HumanDuration', HumanDuration)
app.component('Username', Username)
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import { watch } from '@vue/composition-api'
import axios from 'axios'
export const install: AppModule = async ({ store, router }) => {
export const install: InitModule = async ({ store, router }) => {
watch(() => store.state.instance.instanceUrl, async () => {
const [{ data }] = await Promise.all([
axios.get('instance/nodeinfo/2.0/'),
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
// slight hack to allow use to have internal links in <translate> tags
// while preserving router behaviour
export const install: AppModule = ({ router }) => {
export const install: InitModule = ({ router }) => {
document.documentElement.addEventListener('click', async (event) => {
const target = <HTMLAnchorElement> event.target
if (!target.matches('a.internal')) return
......
......@@ -3,9 +3,9 @@ import GetText from 'vue-gettext'
import locales from '~/locales.json'
import { usePreferredLanguages } from '@vueuse/core'
import { watch } from '@vue/composition-api'
import { AppModule } from '~/types'
import { InitModule } from '~/types'
export const install: AppModule = ({ store, app }) => {
export const install: InitModule = ({ store, app }) => {
const defaultLanguage = store.state.ui.currentLanguage ?? 'en_US'
const availableLanguages = locales.reduce((map: { [key: string]: string }, locale) => {
map[locale.code] = locale.label
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import { register } from 'register-service-worker'
export const install: AppModule = ({ store }) => {
export const install: InitModule = ({ store }) => {
if (import.meta.env.PROD) {
register(`${import.meta.env.BASE_URL}service-worker.js`, {
registrationOptions: { scope: '/' },
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import { watchEffect, watch } from '@vue/composition-api'
import { useWebSocket, whenever } from '@vueuse/core'
export const install: AppModule = ({ store }) => {
export const install: InitModule = ({ store }) => {
watch(() => store.state.instance.instanceUrl, () => {
const url = store.getters['instance/absoluteUrl']('api/v1/activity')
.replace(/^http/, 'ws')
......
import { AppModule } from '~/types'
import { InitModule } from '~/types'
import { useWindowSize } from '@vueuse/core'
import { watchEffect } from '@vue/composition-api'
export const install: AppModule = ({ store }) => {
export const install: InitModule = ({ store }) => {
// NOTE: Due to Vuex 3, when using store in watchEffect, it results in an infinite loop after committing
const { commit } = store
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment