Rename AppModule to InitModule

georg/add-typescript
Kasper Seweryn 2022-04-23 14:48:29 +02:00 zatwierdzone przez Georg Krause
rodzic b0b568e589
commit 1fd0db315c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 2970D504B2183D22
10 zmienionych plików z 20 dodań i 20 usunięć

Wyświetl plik

@ -1,4 +1,4 @@
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) {

Wyświetl plik

@ -1,7 +1,7 @@
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)
})

Wyświetl plik

@ -1,4 +1,4 @@
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)

Wyświetl plik

@ -1,4 +1,4 @@
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)

Wyświetl plik

@ -1,8 +1,8 @@
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/'),

Wyświetl plik

@ -1,8 +1,8 @@
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

Wyświetl plik

@ -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

Wyświetl plik

@ -1,7 +1,7 @@
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: '/' },

Wyświetl plik

@ -1,8 +1,8 @@
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')

Wyświetl plik

@ -1,8 +1,8 @@
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