Skip to content
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 @@ -9,7 +9,7 @@
"tsc:check": "vue-tsc --noEmit",
"lint": "eslint . && prettier --check .",
"fix": "eslint . --fix && prettier --write .",
"intl:extract": "formatjs extract \"{,src/components,src/composables,src/helpers,src/pages,src/store}/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore node_modules --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
"intl:extract": "formatjs extract \"src/**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore node_modules --out-file src/locales/en-US/index.json --format crowdin --preserve-whitespace",
"test": "vue-tsc --noEmit"
},
"dependencies": {
Expand Down
30 changes: 30 additions & 0 deletions apps/app-frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import QuickInstanceSwitcher from '@/components/ui/QuickInstanceSwitcher.vue'
import UpdateModal from '@/components/ui/UpdateModal.vue'
import { get_available_capes, get_available_skins } from './helpers/skins'
import { generateSkinPreviews } from './helpers/rendering/batch-skin-renderer'
import { defineMessages, useVIntl } from '@vintl/vintl'

const themeStore = useTheming()

Expand Down Expand Up @@ -109,6 +110,18 @@ onUnmounted(() => {
document.querySelector('body').removeEventListener('auxclick', handleAuxClick)
})

const { formatMessage } = useVIntl()
const messages = defineMessages({
updateInstalledToastTitle: {
id: 'app.update.complete-toast.title',
defaultMessage: 'Version {version} was successfully installed!',
},
updateInstalledToastText: {
id: 'app.update.complete-toast.text',
defaultMessage: 'Click here to view the changelog.',
},
})

async function setupApp() {
stateInitialized.value = true
const {
Expand All @@ -122,6 +135,7 @@ async function setupApp() {
toggle_sidebar,
developer_mode,
feature_flags,
pending_update_toast_for_version,
} = await getSettings()

if (default_page === 'Library') {
Expand Down Expand Up @@ -218,6 +232,22 @@ async function setupApp() {
} catch (error) {
console.warn('Failed to generate skin previews in app setup.', error)
}

if (pending_update_toast_for_version !== null) {
const settings = await getSettings()
settings.pending_update_toast_for_version = null
await setSettings(settings)

const version = await getVersion()
if (pending_update_toast_for_version === version) {
notifications.addNotification({
type: 'success',
title: formatMessage(messages.updateInstalledToastTitle, { version }),
text: formatMessage(messages.updateInstalledToastText),
clickAction: () => openUrl('https://modrinth.com/news/changelog?filter=app'),
})
}
}
}

const stateFailed = ref(false)
Expand Down
1 change: 0 additions & 1 deletion apps/app-frontend/src/components/ui/UpdateModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const emit = defineEmits<{
}>()

const { formatMessage } = useVIntl()

const messages = defineMessages({
header: {
id: 'app.update.modal-header',
Expand Down
2 changes: 2 additions & 0 deletions apps/app-frontend/src/helpers/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ export type AppSettings = {

developer_mode: boolean
feature_flags: Record<FeatureFlag, boolean>

skipped_update: string | null
pending_update_toast_for_version: string | null
}

// Get full settings object
Expand Down
6 changes: 6 additions & 0 deletions apps/app-frontend/src/locales/en-US/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
"app.update.changelog": {
"message": "Changelog"
},
"app.update.complete-toast.text": {
"message": "Click here to view the changelog."
},
"app.update.complete-toast.title": {
"message": "Version {version} was successfully installed!"
},
"app.update.copied-error": {
"message": "Copied to clipboard!"
},
Expand Down
14 changes: 14 additions & 0 deletions apps/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,22 @@ fn main() {
if matches!(event, tauri::RunEvent::Exit) {
let update_data = app.state::<PendingUpdateData>().inner();
if let Some((update, data)) = &*update_data.0.lock().unwrap() {
fn set_changelog_toast(version: Option<String>) {
let toast_result: theseus::Result<()> = tauri::async_runtime::block_on(async move {
let mut settings = settings::get().await?;
settings.pending_update_toast_for_version = version;
settings::set(settings).await?;
Ok(())
});
if let Err(e) = toast_result {
tracing::warn!("Failed to set pending_update_toast: {e}")
}
}

set_changelog_toast(Some(update.version.clone()));
if let Err(e) = update.install(data) {
tracing::error!("Error while updating: {e}");
set_changelog_toast(None);

DialogBuilder::message()
.set_level(MessageLevel::Error)
Expand Down

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

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE settings
ADD COLUMN pending_update_toast_for_version TEXT NULL;
13 changes: 10 additions & 3 deletions packages/app-lib/src/state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ pub struct Settings {

pub developer_mode: bool,
pub feature_flags: HashMap<FeatureFlag, bool>,

pub skipped_update: Option<String>,
pub pending_update_toast_for_version: Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Copy, Eq, Hash, PartialEq)]
Expand All @@ -65,7 +67,7 @@ impl Settings {
mc_memory_max, mc_force_fullscreen, mc_game_resolution_x, mc_game_resolution_y, hide_on_process_start,
hook_pre_launch, hook_wrapper, hook_post_exit,
custom_dir, prev_custom_dir, migrated, json(feature_flags) feature_flags, toggle_sidebar,
skipped_update
skipped_update, pending_update_toast_for_version
FROM settings
"
)
Expand Down Expand Up @@ -120,6 +122,8 @@ impl Settings {
.and_then(|x| serde_json::from_str(x).ok())
.unwrap_or_default(),
skipped_update: res.skipped_update,
pending_update_toast_for_version: res
.pending_update_toast_for_version,
})
}

Expand Down Expand Up @@ -174,7 +178,9 @@ impl Settings {
toggle_sidebar = $26,
feature_flags = $27,
hide_nametag_skins_page = $28,
skipped_update = $29

skipped_update = $29,
pending_update_toast_for_version = $30
",
max_concurrent_writes,
max_concurrent_downloads,
Expand Down Expand Up @@ -204,7 +210,8 @@ impl Settings {
self.toggle_sidebar,
feature_flags,
self.hide_nametag_skins_page,
self.skipped_update
self.skipped_update,
self.pending_update_toast_for_version,
)
.execute(exec)
.await?;
Expand Down
11 changes: 9 additions & 2 deletions packages/ui/src/components/base/Notifications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
@mouseenter="stopTimer(item)"
@mouseleave="setNotificationTimer(item)"
>
<div class="vue-notification-template vue-notification" :class="{ [item.type]: true }">
<div
class="vue-notification-template vue-notification"
:class="{ [item.type]: true }"
@click="item.clickAction"
>
<div class="notification-title" v-html="item.title"></div>
<div class="notification-content" v-html="item.text"></div>
</div>
Expand All @@ -31,11 +35,14 @@ const notifications = ref([])

defineExpose({
addNotification: (notification) => {
notification.clickAction = notification.clickAction ?? (() => {})

const existingNotif = notifications.value.find(
(x) =>
x.text === notification.text &&
x.title === notification.title &&
x.type === notification.type,
x.type === notification.type &&
x.clickAction === notification.clickAction,
)
if (existingNotif) {
setNotificationTimer(existingNotif)
Expand Down