Skip to content

Commit

Permalink
fix remaining bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Aug 30, 2024
1 parent 2005148 commit f2e2011
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 100 deletions.
57 changes: 46 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion apps/app-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"@tauri-apps/plugin-window-state": "^2.0.0-rc.0",
"@tauri-apps/plugin-shell": "^2.0.0-rc.0",
"@tauri-apps/plugin-updater": "^2.0.0-rc.0",
"@tauri-apps/plugin-process": "^2.0.0-rc.0",
"@vintl/vintl": "^4.4.1",
"dayjs": "^1.11.10",
"floating-vue": "^5.2.2",
Expand Down
8 changes: 4 additions & 4 deletions apps/app-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { handleError, useNotifications } from '@/store/notifications.js'
import { command_listener, warning_listener } from '@/helpers/events.js'
import { MinimizeIcon, MaximizeIcon } from '@/assets/icons'
import { type } from '@tauri-apps/plugin-os'
import { isDev, getOS } from '@/helpers/utils.js'
import { isDev, getOS, restartApp } from '@/helpers/utils.js'
import { initAnalytics, debugAnalytics, optOutAnalytics, trackEvent } from '@/helpers/analytics'
import { getCurrentWindow } from '@tauri-apps/api/window'
import { getVersion } from '@tauri-apps/api/app'
Expand All @@ -43,7 +43,6 @@ import { saveWindowState, StateFlags } from '@tauri-apps/plugin-window-state'
import { renderString } from '@modrinth/utils'
import { useFetch } from '@/helpers/fetch.js'
import { check } from '@tauri-apps/plugin-updater'
import { relaunch } from '@tauri-apps/plugin-process'
const themeStore = useTheming()
Expand Down Expand Up @@ -246,7 +245,8 @@ async function handleCommand(e) {
const updateAvailable = ref(false)
async function checkUpdates() {
const update = await check().catch(() => {})
const update = await check()
console.log(update)
updateAvailable.value = !!update
setTimeout(
Expand Down Expand Up @@ -293,7 +293,7 @@ async function checkUpdates() {
v-if="updateAvailable"
v-tooltip="'Install update'"
class="btn btn-outline btn-primary icon-only collapsed-button"
@click="relaunch()"
@click="restartApp()"
>
<DownloadIcon />
</button>
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/components/ui/AddContentButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const handleAddContentFromFile = async () => {
if (!newProject) return
for (const project of newProject) {
await add_project_from_path(props.instance.path, project).catch(handleError)
await add_project_from_path(props.instance.path, project.path).catch(handleError)
}
}
Expand Down
6 changes: 4 additions & 2 deletions apps/app-frontend/src/components/ui/InstanceCreationModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ const create_instance = async () => {
}
const upload_icon = async () => {
icon.value = await open({
const res = await open({
multiple: false,
filters: [
{
Expand All @@ -379,6 +379,8 @@ const upload_icon = async () => {
],
})
icon.value = res ? res.path : null
if (!icon.value) return
display_icon.value = convertFileSrc(icon.value)
}
Expand Down Expand Up @@ -415,7 +417,7 @@ const openFile = async () => {
const newProject = await open({ multiple: false })
if (!newProject) return
hide()
await install_from_file(newProject).catch(handleError)
await install_from_file(newProject.path).catch(handleError)
trackEvent('InstanceCreate', {
source: 'CreationModalFileOpen',
Expand Down
6 changes: 3 additions & 3 deletions apps/app-frontend/src/components/ui/JavaSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,17 @@ async function handleJavaFileInput() {
let filePath = await open()
if (filePath) {
let result = await get_jre(filePath)
let result = await get_jre(filePath.path)
if (!result) {
result = {
path: filePath,
path: filePath.path,
version: props.version.toString(),
architecture: 'x86',
}
}
trackEvent('JavaManualSelect', {
path: filePath,
path: filePath.path,
version: props.version,
})
Expand Down
12 changes: 6 additions & 6 deletions apps/app-frontend/src/components/ui/PromotionWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ onMounted(() => {
if (showAd.value) {
updateAdPosition(true)
resizeObserver = new ResizeObserver(updateAdPosition)
resizeObserver = new ResizeObserver(() => updateAdPosition())
resizeObserver.observe(adsWrapper.value)
intersectionObserver = new IntersectionObserver(updateAdPosition)
intersectionObserver = new IntersectionObserver(() => updateAdPosition())
intersectionObserver.observe(adsWrapper.value)
mutationObserver = new MutationObserver(updateAdPosition)
mutationObserver = new MutationObserver(() => updateAdPosition())
mutationObserver.observe(adsWrapper.value, { attributes: true, childList: true, subtree: true })
// Add scroll event listener
scrollHandler = () => {
requestAnimationFrame(updateAdPosition)
requestAnimationFrame(() => updateAdPosition())
}
window.addEventListener('scroll', scrollHandler, { passive: true })
}
})
function updateAdPosition(override = false) {
function updateAdPosition(overrideShown = false) {
if (adsWrapper.value) {
const rect = adsWrapper.value.getBoundingClientRect()
Expand All @@ -69,7 +69,7 @@ function updateAdPosition(override = false) {
}
}
init_ads_window(rect.left + window.scrollX, y, rect.right - rect.left, height, override)
init_ads_window(rect.left + window.scrollX, y, rect.right - rect.left, height, overrideShown)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const toggleCreation = () => {
}
const upload_icon = async () => {
icon.value = await open({
const res = await open({
multiple: false,
filters: [
{
Expand All @@ -150,6 +150,7 @@ const upload_icon = async () => {
},
],
})
icon.value = res ? res.path : null
if (!icon.value) return
display_icon.value = convertFileSrc(icon.value)
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/helpers/ads.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { invoke } from '@tauri-apps/api/core'

export async function init_ads_window(x, y, width, height, overrideShown) {
export async function init_ads_window(x, y, width, height, overrideShown = false) {
return await invoke('plugin:ads|init_ads_window', { x, y, width, height, overrideShown })
}

Expand Down
4 changes: 4 additions & 0 deletions apps/app-frontend/src/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export async function highlightModInProfile(profilePath, projectPath) {
return await highlightInFolder(fullPath)
}

export async function restartApp() {
return await invoke('restart_app')
}

export const releaseColor = (releaseType) => {
switch (releaseType) {
case 'release':
Expand Down
5 changes: 3 additions & 2 deletions apps/app-frontend/src/pages/Browse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ const isModProject = computed(() => ['modpack', 'mod'].includes(projectType.valu
height: fit-content;
min-height: calc(100vh - 3.25rem);
max-height: calc(100vh - 3.25rem);
width: 20rem;
overflow-y: auto;
-ms-overflow-style: none;
scrollbar-width: none;
Expand All @@ -902,8 +903,8 @@ const isModProject = computed(() => ['modpack', 'mod'].includes(projectType.valu
}
.search {
margin: 0 1rem 0.5rem calc(300px + 2.5rem);
width: calc(100% - calc(300px + 2.5rem));
margin: 0 1rem 0.5rem calc(20rem + 1rem);
width: calc(100% - calc(20rem + 1rem));
.offline {
margin: 1rem;
Expand Down
2 changes: 1 addition & 1 deletion apps/app-frontend/src/pages/instance/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ async function setIcon() {
if (!value) return
icon.value = value
icon.value = value.path
await edit_icon(props.instance.path, icon.value).catch(handleError)
trackEvent('InstanceSetIcon')
Expand Down
2 changes: 1 addition & 1 deletion apps/app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tauri-plugin-os = "2.0.0-rc"
tauri-plugin-shell = "2.0.0-rc"
tauri-plugin-dialog = "2.0.0-rc"
tauri-plugin-updater = { version = "2.0.0-rc" }
tauri-plugin-process = { version = "2.0.0-rc" }
tauri-plugin-single-instance = { version = "2.0.0-rc" }

tokio = { version = "1", features = ["full"] }
thiserror = "1.0"
Expand Down
3 changes: 1 addition & 2 deletions apps/app/capabilities/updater.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"main"
],
"permissions": [
"updater:default",
"process:default"
"updater:default"
]
}
2 changes: 1 addition & 1 deletion apps/app/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"ads":{"identifier":"ads","description":"","remote":{"urls":["https://modrinth.com/*","http://localhost:3000/*"]},"local":false,"webviews":["ads-window"],"permissions":["shell:allow-open","ads:default"]},"core":{"identifier":"core","description":"","local":true,"windows":["main"],"permissions":["core:default","core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-create","core:window:allow-maximize","core:window:allow-toggle-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-start-dragging","core:webview:allow-set-webview-zoom"]},"plugins":{"identifier":"plugins","description":"","local":true,"windows":["main"],"permissions":["dialog:allow-open","dialog:allow-confirm","shell:allow-open","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","deep-link:default","window-state:default","window-state:allow-restore-state","window-state:allow-save-window-state","auth:default","import:default","jre:default","logs:default","metadata:default","mr-auth:default","profile-create:default","pack:default","process:default","profile:default","cache:default","settings:default","tags:default","utils:default","ads:default"]},"updater":{"identifier":"updater","description":"","local":true,"windows":["main"],"permissions":["updater:default","process:default"]}}
{"ads":{"identifier":"ads","description":"","remote":{"urls":["https://modrinth.com/*","http://localhost:3000/*"]},"local":false,"webviews":["ads-window"],"permissions":["shell:allow-open","ads:default"]},"core":{"identifier":"core","description":"","local":true,"windows":["main"],"permissions":["core:default","core:path:default","core:event:default","core:window:default","core:app:default","core:resources:default","core:menu:default","core:tray:default","core:window:allow-create","core:window:allow-maximize","core:window:allow-toggle-maximize","core:window:allow-unmaximize","core:window:allow-minimize","core:window:allow-unminimize","core:window:allow-show","core:window:allow-hide","core:window:allow-close","core:window:allow-set-decorations","core:window:allow-start-dragging","core:webview:allow-set-webview-zoom"]},"plugins":{"identifier":"plugins","description":"","local":true,"windows":["main"],"permissions":["dialog:allow-open","dialog:allow-confirm","shell:allow-open","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","deep-link:default","window-state:default","window-state:allow-restore-state","window-state:allow-save-window-state","auth:default","import:default","jre:default","logs:default","metadata:default","mr-auth:default","profile-create:default","pack:default","process:default","profile:default","cache:default","settings:default","tags:default","utils:default","ads:default"]},"updater":{"identifier":"updater","description":"","local":true,"windows":["main"],"permissions":["updater:default"]}}
Loading

0 comments on commit f2e2011

Please sign in to comment.