Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theseus): Fixed multiple bugs #1304

Merged
merged 14 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/app-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"vue": "^3.4.21",
"vue-multiselect": "3.0.0-beta.3",
"vue-router": "4.3.0",
"vue-virtual-scroller": "2.0.0-beta.8"
"vue-typed-virtual-list": "^1.0.10"
},
"devDependencies": {
"@tauri-apps/cli": "^1.5.11",
Expand Down
6 changes: 3 additions & 3 deletions apps/app-frontend/src/assets/stylesheets/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ input {

* {
scrollbar-width: auto;
scrollbar-color: var(--color-button-bg) var(--color-bg);
scrollbar-color: var(--color-scrollbar) var(--color-bg);
}

/* Chrome, Edge, and Safari */
*::-webkit-scrollbar {
width: var(--gap-md);
border: 3px solid var(--color-bg);
border: 3px solid var(--color-scrollbar);
}

*::-webkit-scrollbar-track {
Expand All @@ -115,7 +115,7 @@ input {
}

*::-webkit-scrollbar-thumb {
background-color: var(--color-button-bg);
background-color: var(--color-scrollbar);
border-radius: var(--radius-lg);
border: 3px solid var(--color-bg);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/app-frontend/src/components/ui/ExportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ const initFiles = async () => {
disabled:
folder === 'profile.json' ||
folder.startsWith('modrinth_logs') ||
folder.startsWith('.fabric') ||
folder.includes('.DS_Store'),
folder.startsWith('.fabric'),
}))
.filter((pathData) => !pathData.path.includes('.DS_Store'))
.forEach((pathData) => {
const parent = pathData.path.split(sep).slice(0, -1).join(sep)
if (parent !== '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,7 @@ onMounted(() => {
}
}

:deep {
.checkbox {
border: none;
}
:deep(.checkbox) {
border: none;
}
</style>
2 changes: 1 addition & 1 deletion apps/app-frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import App from '@/App.vue'
import { createPinia } from 'pinia'
import '@modrinth/assets/omorphia.scss'
import '@/assets/stylesheets/global.scss'
import 'floating-vue/dist/style.css'
import FloatingVue from 'floating-vue'
import 'floating-vue/dist/style.css'
import { get_opening_command, initialize_state } from '@/helpers/state'
import loadCssMixin from './mixins/macCssFix.js'
import { get } from '@/helpers/settings'
Expand Down
32 changes: 13 additions & 19 deletions apps/app-frontend/src/pages/Browse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,14 @@ const [categories, loaders, availableGameVersions] = await Promise.all([
refreshSearch(),
])

const filteredLoaders = computed(() => {
return loaders.value.filter((loader) => {
return projectType.value === 'mod' || projectType.value === 'modpack'
? loader.supported_project_types[0] === 'mod'
: loader.supported_project_types[0] === projectType.value
})
})

const selectableProjectTypes = computed(() => {
const values = [
{ label: 'Shaders', href: `/browse/shader` },
Expand Down Expand Up @@ -518,14 +526,8 @@ const selectableProjectTypes = computed(() => {
const showVersions = computed(
() => instanceContext.value === null || ignoreInstanceGameVersions.value,
)
const showLoaders = computed(
() =>
(projectType.value !== 'datapack' &&
projectType.value !== 'resourcepack' &&
projectType.value !== 'shader' &&
instanceContext.value === null) ||
ignoreInstanceLoaders.value,
)

const isModProject = computed(() => ['modpack', 'mod'].includes(projectType.value))

onUnmounted(() => unlistenOffline())
</script>
Expand Down Expand Up @@ -596,17 +598,9 @@ onUnmounted(() => unlistenOffline())
>
<ClearIcon /> Clear filters
</Button>
<div v-if="showLoaders" class="loaders">
<div v-if="isModProject || projectType === 'shader'" class="loaders">
<h2>Loaders</h2>
<div
v-for="loader in loaders.filter(
(l) =>
(projectType !== 'mod' && l.supported_project_types?.includes(projectType)) ||
(projectType === 'mod' &&
['fabric', 'forge', 'quilt', 'neoforge'].includes(l.name)),
)"
:key="loader"
>
<div v-for="loader in filteredLoaders" :key="loader">
<SearchFilter
:active-filters="orFacets"
:icon="loader.icon"
Expand Down Expand Up @@ -656,7 +650,7 @@ onUnmounted(() => unlistenOffline())
/>
</div>
</div>
<div v-if="projectType !== 'datapack'" class="environment">
<div v-if="isModProject" class="environment">
<h2>Environments</h2>
<SearchFilter
:active-filters="selectedEnvironments"
Expand Down
12 changes: 5 additions & 7 deletions apps/app-frontend/src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,12 @@ async function refreshDir() {
margin: 1rem 0;
}

:deep {
.login-screen-modal {
.modal-container .modal-body {
width: auto;
:deep(.login-screen-modal) {
.modal-container .modal-body {
width: auto;

.content {
background: none;
}
.content {
background: none;
}
}
}
Expand Down
45 changes: 23 additions & 22 deletions apps/app-frontend/src/pages/instance/Logs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,28 +59,28 @@
</div>
</div>
<div class="log-text">
<RecycleScroller
v-slot="{ item }"
<VirtualScroller
ref="logContainer"
class="scroller"
:default-size="20"
:items="displayProcessedLogs"
direction="vertical"
:item-size="20"
key-field="id"
>
<div class="user no-wrap">
<span :style="{ color: item.prefixColor, 'font-weight': item.weight }">{{
item.prefix
}}</span>
<span :style="{ color: item.textColor }">{{ item.text }}</span>
</div>
</RecycleScroller>
<template #item="{ ref }">
<div class="user no-wrap">
<span :style="{ color: ref.prefixColor, 'font-weight': ref.weight }">{{
ref.prefix
}}</span>
<span :style="{ color: ref.textColor }">{{ ref.text }}</span>
</div>
</template>
</VirtualScroller>
</div>
<ShareModal
ref="shareModal"
header="Share Log"
share-title="Instance Log"
share-text="Check out this log from an instance on the Modrinth App"
:open-in-new-tab="false"
link
/>
</Card>
Expand All @@ -104,13 +104,13 @@ import { useRoute } from 'vue-router'
import { process_listener } from '@/helpers/events.js'
import { handleError } from '@/store/notifications.js'
import { ofetch } from 'ofetch'

import { RecycleScroller } from 'vue-virtual-scroller'
import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
import { createVirtualScroller } from 'vue-typed-virtual-list'

dayjs.extend(isToday)
dayjs.extend(isYesterday)

const VirtualScroller = createVirtualScroller()

const route = useRoute()

const props = defineProps({
Expand Down Expand Up @@ -412,15 +412,20 @@ function handleUserScroll() {
interval.value = setInterval(async () => {
if (logs.value.length > 0) {
logs.value[0] = await getLiveStdLog()
const logContainerElement = logContainer.value.$el
const scroll =
logContainerElement.scrollHeight -
logContainerElement.scrollTop -
logContainerElement.clientHeight
// const scroll = logContainer.value.$el.scrollHeight - logContainer.value.$el.scrollTop - logContainer.value.$el.clientHeight

const scroll = logContainer.value.getScroll()
// Allow resetting of userScrolled if the user scrolls to the bottom
if (selectedLogIndex.value === 0) {
if (scroll.end >= logContainer.value.$el.scrollHeight - 10) userScrolled.value = false
if (scroll <= 10) userScrolled.value = false
if (!userScrolled.value) {
await nextTick()
isAutoScrolling.value = true
logContainer.value.scrollToItem(displayProcessedLogs.value.length - 1)
logContainer.value.scrollTo(displayProcessedLogs.value.length - 1)
setTimeout(() => (isAutoScrolling.value = false), 50)
}
}
Expand Down Expand Up @@ -489,10 +494,6 @@ onUnmounted(() => {
white-space: nowrap; /* Keeps content on a single line */
white-space: normal;
color-scheme: dark;

.no-wrap {
white-space: pre;
}
}

.filter-checkbox {
Expand Down
6 changes: 2 additions & 4 deletions apps/app-frontend/src/pages/instance/Mods.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
ref="shareModal"
share-title="Sharing modpack content"
share-text="Check out the projects I'm using in my modpack!"
:open-in-new-tab="false"
/>
<ExportModal v-if="projects.length > 0" ref="exportModal" :instance="instance" />
<ModpackVersionModal
Expand Down Expand Up @@ -1110,6 +1111,7 @@ onUnmounted(() => {
}
}
</style>

<style lang="scss">
.updating-indicator {
height: 2.25rem !important;
Expand All @@ -1121,10 +1123,6 @@ onUnmounted(() => {
}
}

.v-popper--theme-tooltip .v-popper__inner {
background: #fff !important;
}

.select-checkbox {
button.checkbox {
border: none;
Expand Down
31 changes: 19 additions & 12 deletions apps/app/src/api/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pub async fn should_disable_mouseover() -> bool {
}

#[tauri::command]
pub fn show_in_folder(path: PathBuf) -> Result<()> {
pub fn show_in_folder(mut path: PathBuf) -> Result<()> {
{
#[cfg(target_os = "windows")]
{
Expand All @@ -101,19 +101,26 @@ pub fn show_in_folder(path: PathBuf) -> Result<()> {
{
use std::fs::metadata;

if path.to_string_lossy().to_string().contains(',') {
let path_string = path.to_string_lossy().to_string();

if metadata(&path)?.is_dir() {
Command::new("xdg-open").arg(&path).spawn()?;
} else if path_string.contains(',') {
// see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76
let new_path = match metadata(&path)?.is_dir() {
true => path,
false => {
let mut path2 = path.clone();
path2.pop();
path2
}
};
Command::new("xdg-open").arg(&new_path).spawn()?;
} else {
path.pop();
Command::new("xdg-open").arg(&path).spawn()?;
} else {
Command::new("dbus-send")
.args([
"--session",
"--dest=org.freedesktop.FileManager1",
"--type=method_call",
"/org/freedesktop/FileManager1",
"org.freedesktop.FileManager1.ShowItems",
format!("array:string:file://{}", path_string).as_str(),
"string:\"\"",
])
.spawn()?;
}
}

Expand Down
14 changes: 9 additions & 5 deletions packages/app-lib/src/state/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use serde::{Deserialize, Serialize};
use std::io::Cursor;
use std::{
collections::HashMap,
ffi::OsStr,
path,
path::{Path, PathBuf},
};
use uuid::Uuid;
Expand Down Expand Up @@ -65,7 +67,6 @@ impl ProfilePathId {
.ok_or_else(|| {
crate::ErrorKind::FSError(format!(
"Path {path:?} does not correspond to a profile",
path = path
))
})?;
Ok(Self(path))
Expand Down Expand Up @@ -150,22 +151,22 @@ impl From<InnerProjectPathUnix> for RawProjectPath {
pub struct ProjectPathId(pub PathBuf);
impl ProjectPathId {
// Create a new ProjectPathId from a full file path
pub async fn from_fs_path(path: &PathBuf) -> crate::Result<Self> {
pub async fn from_fs_path(path: &Path) -> crate::Result<Self> {
// This is avoiding dunce::canonicalize deliberately. On Windows, paths will always be convert to UNC,
// but this is ok because we are stripping that with the prefix. Using std::fs avoids different behaviors with dunce that
// come with too-long paths
let profiles_dir: PathBuf = std::fs::canonicalize(
State::get().await?.directories.profiles_dir().await,
)?;
let path: PathBuf = std::fs::canonicalize(path)?;
// Normal canonizing resolves symlinks, which results in "path not corresponding to profile" error
let path = path::absolute(path)?;
let path = path
.strip_prefix(profiles_dir)
.ok()
.map(|p| p.components().skip(1).collect::<PathBuf>())
.ok_or_else(|| {
crate::ErrorKind::FSError(format!(
"Path {path:?} does not correspond to a profile",
path = path
))
})?;
Ok(Self(path))
Expand Down Expand Up @@ -485,7 +486,9 @@ impl Profile {
.map_err(|e| IOError::with_path(e, &new_path))?
{
let subpath = subpath.map_err(IOError::from)?.path();
if subpath.is_file() {
if subpath.is_file()
&& subpath.file_name() != Some(OsStr::new(".DS_Store"))
{
files.push(subpath);
}
}
Expand Down Expand Up @@ -609,6 +612,7 @@ impl Profile {
})?;
if archive.by_name("fabric.mod.json").is_ok()
|| archive.by_name("quilt.mod.json").is_ok()
|| archive.by_name("META-INF/neoforge.mods.toml").is_ok()
|| archive.by_name("META-INF/mods.toml").is_ok()
|| archive.by_name("mcmod.info").is_ok()
{
Expand Down
2 changes: 1 addition & 1 deletion packages/app-lib/src/state/projects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl ProjectType {
pub fn get_from_loaders(loaders: Vec<String>) -> Option<Self> {
if loaders
.iter()
.any(|x| ["fabric", "forge", "quilt"].contains(&&**x))
.any(|x| ["fabric", "forge", "quilt", "neoforge"].contains(&&**x))
{
Some(ProjectType::Mod)
} else if loaders.iter().any(|x| x == "datapack") {
Expand Down
1 change: 1 addition & 0 deletions packages/app-lib/src/util/jre.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ pub async fn check_java_at_filepath(path: &Path) -> Option<JavaVersion> {
.arg("-cp")
.arg(file_path.parent().unwrap())
.arg("JavaInfo")
.env_remove("_JAVA_OPTIONS")
.output()
.ok()?;

Expand Down
Loading