Skip to content

Commit 4ad6daa

Browse files
authored
fix: DI nonsense (#4174)
* fix: DI nonsense * fix: lint * fix: client try di issue * fix: injects outside of context * fix: use .catch * refactor: convert projects.vue to composition API. * fix: moderation checklist notif pos change watcher * fix: lint issues
1 parent 9b5f172 commit 4ad6daa

File tree

32 files changed

+320
-325
lines changed

32 files changed

+320
-325
lines changed

apps/app-frontend/src/components/RowDisplay.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,14 @@ const handleOptionsClick = async (args) => {
165165
await navigator.clipboard.writeText(args.item.path)
166166
break
167167
case 'install': {
168-
await installVersion(args.item.project_id, null, null, 'ProjectCardContextMenu')
168+
await installVersion(
169+
args.item.project_id,
170+
null,
171+
null,
172+
'ProjectCardContextMenu',
173+
() => {},
174+
() => {},
175+
).catch(handleError)
169176
170177
break
171178
}

apps/app-frontend/src/components/ui/Instance.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const stop = async (e, context) => {
9494
const repair = async (e) => {
9595
e?.stopPropagation()
9696
97-
await finish_install(props.instance)
97+
await finish_install(props.instance).catch(handleError)
9898
}
9999
100100
const openFolder = async () => {

apps/app-frontend/src/components/ui/SearchCard.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118

119119
<script setup>
120120
import { CheckIcon, DownloadIcon, HeartIcon, PlusIcon, TagsIcon } from '@modrinth/assets'
121-
import { Avatar, ButtonStyled } from '@modrinth/ui'
121+
import { Avatar, ButtonStyled, injectNotificationManager } from '@modrinth/ui'
122122
import { formatCategory, formatNumber } from '@modrinth/utils'
123123
import dayjs from 'dayjs'
124124
import relativeTime from 'dayjs/plugin/relativeTime'
@@ -128,6 +128,8 @@ import { useRouter } from 'vue-router'
128128
import { install as installVersion } from '@/store/install.js'
129129
dayjs.extend(relativeTime)
130130
131+
const { handleError } = injectNotificationManager()
132+
131133
const router = useRouter()
132134
133135
const props = defineProps({
@@ -175,7 +177,7 @@ async function install() {
175177
(profile) => {
176178
router.push(`/instance/${profile}`)
177179
},
178-
)
180+
).catch(handleError)
179181
}
180182
181183
const modpack = computed(() => props.project.project_type === 'modpack')

apps/app-frontend/src/components/ui/URLConfirmModal.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ defineExpose({
3939
4040
async function install() {
4141
confirmModal.value.hide()
42-
await installVersion(project.value.id, version.value.id, null, 'URLConfirmModal')
42+
await installVersion(
43+
project.value.id,
44+
version.value.id,
45+
null,
46+
'URLConfirmModal',
47+
() => {},
48+
() => {},
49+
).catch(handleError)
4350
}
4451
</script>
4552

apps/app-frontend/src/components/ui/install_flow/ModInstallModal.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async function install(instance) {
110110
}
111111
112112
await installMod(instance.path, version.id).catch(handleError)
113-
await installVersionDependencies(instance, version)
113+
await installVersionDependencies(instance, version).catch(handleError)
114114
115115
instance.installedMod = true
116116
instance.installing = false
@@ -185,7 +185,7 @@ const createInstance = async () => {
185185
await router.push(`/instance/${encodeURIComponent(id)}/`)
186186
187187
const instance = await get(id, true)
188-
await installVersionDependencies(instance, versions.value[0])
188+
await installVersionDependencies(instance, versions.value[0]).catch(handleError)
189189
190190
trackEvent('InstanceCreate', {
191191
profile_name: name.value,

apps/app-frontend/src/components/ui/instance_settings/JavaSettings.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const { formatMessage } = useVIntl()
1616
1717
const props = defineProps<InstanceSettingsTabProps>()
1818
19-
const globalSettings = (await get().catch(handleError)) as AppSettings
19+
const globalSettings = (await get().catch(handleError)) as unknown as AppSettings
2020
2121
const overrideJavaInstall = ref(!!props.instance.java_path)
2222
const optimalJava = readonly(await get_optimal_jre_key(props.instance.path).catch(handleError))
@@ -36,7 +36,10 @@ const envVars = ref(
3636
3737
const overrideMemorySettings = ref(!!props.instance.memory)
3838
const memory = ref(props.instance.memory ?? globalSettings.memory)
39-
const { maxMemory, snapPoints } = await useMemorySlider()
39+
const { maxMemory, snapPoints } = (await useMemorySlider().catch(handleError)) as unknown as {
40+
maxMemory: number
41+
snapPoints: number[]
42+
}
4043
4144
const editProfileObject = computed(() => {
4245
const editProfile: {

apps/app-frontend/src/components/ui/settings/DefaultInstanceSettings.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
<script setup lang="ts">
2-
import { Slider, Toggle } from '@modrinth/ui'
2+
import { injectNotificationManager, Slider, Toggle } from '@modrinth/ui'
33
import { ref, watch } from 'vue'
44
55
import useMemorySlider from '@/composables/useMemorySlider'
66
import { get, set } from '@/helpers/settings.ts'
77
8+
const { handleError } = injectNotificationManager()
9+
810
const fetchSettings = await get()
911
fetchSettings.launchArgs = fetchSettings.extra_launch_args.join(' ')
1012
fetchSettings.envVars = fetchSettings.custom_env_vars.map((x) => x.join('=')).join(' ')
1113
1214
const settings = ref(fetchSettings)
1315
14-
const { maxMemory, snapPoints } = await useMemorySlider()
16+
const { maxMemory, snapPoints } = (await useMemorySlider().catch(handleError)) as unknown as {
17+
maxMemory: number
18+
snapPoints: number[]
19+
}
1520
1621
watch(
1722
settings,

apps/app-frontend/src/composables/useMemorySlider.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { injectNotificationManager } from '@modrinth/ui'
21
import { computed, ref } from 'vue'
32

43
import { get_max_memory } from '@/helpers/jre.js'
54

65
export default async function () {
7-
const { handleError } = injectNotificationManager()
8-
const maxMemory = ref(Math.floor((await get_max_memory().catch(handleError)) / 1024))
6+
const maxMemory = ref(Math.floor((await get_max_memory()) / 1024))
97

108
const snapPoints = computed(() => {
119
let points = []

apps/app-frontend/src/helpers/fetch.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { injectNotificationManager } from '@modrinth/ui'
21
import { getVersion } from '@tauri-apps/api/app'
32
import { fetch } from '@tauri-apps/plugin-http'
43

@@ -11,9 +10,9 @@ export const useFetch = async (url, item, isSilent) => {
1110
})
1211
} catch (err) {
1312
if (!isSilent) {
14-
const { handleError } = injectNotificationManager()
15-
handleError({ message: `Error fetching ${item}` })
13+
throw err
14+
} else {
15+
console.error(err)
1616
}
17-
console.error(err)
1817
}
1918
}

apps/app-frontend/src/helpers/profile.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* So, for example, addDefaultInstance creates a blank Profile object, where the Rust struct is serialized,
44
* and deserialized into a usable JS object.
55
*/
6-
import { injectNotificationManager } from '@modrinth/ui'
76
import { invoke } from '@tauri-apps/api/core'
87

98
import { install_to_existing_profile } from '@/helpers/pack.js'
@@ -194,16 +193,15 @@ export async function edit_icon(path, iconPath) {
194193
}
195194

196195
export async function finish_install(instance) {
197-
const { handleError } = injectNotificationManager()
198196
if (instance.install_stage !== 'pack_installed') {
199197
let linkedData = instance.linked_data
200198
await install_to_existing_profile(
201199
linkedData.project_id,
202200
linkedData.version_id,
203201
instance.name,
204202
instance.path,
205-
).catch(handleError)
203+
)
206204
} else {
207-
await install(instance.path, false).catch(handleError)
205+
await install(instance.path, false)
208206
}
209207
}

0 commit comments

Comments
 (0)