Skip to content

Commit

Permalink
fix more
Browse files Browse the repository at this point in the history
  • Loading branch information
Geometrically committed Sep 30, 2024
1 parent c7715ec commit 63399df
Show file tree
Hide file tree
Showing 18 changed files with 138 additions and 62 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion apps/app-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@modrinth/app-frontend",
"private": true,
"version": "0.8.7",
"version": "0.8.8",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ const createInstance = async () => {
@click="installModal.hide()"
>
<Avatar
:src="profile.icon_path ? tauri.convertFileSrc(profile.icon_path) : null"
:src="profile.icon_path ? convertFileSrc(profile.icon_path) : null"
class="profile-image"
/>
{{ profile.name }}
Expand Down
19 changes: 19 additions & 0 deletions apps/app-frontend/src/pages/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,25 @@ async function purgeCache() {
<span class="label__title size-card-header">Privacy</span>
</h3>
</div>
<div class="adjacent-input">
<label for="opt-out-analytics">
<span class="label__title">Personalized ads</span>
<span class="label__description">
Modrinth's ad provider, Aditude, shows ads based on your preferences. By disabling this
option, you opt out and ads will no longer be shown based on your interests.
</span>
</label>
<Toggle
id="opt-out-analytics"
:model-value="settings.personalized_ads"
:checked="settings.personalized_ads"
@update:model-value="
(e) => {
settings.personalized_ads = e
}
"
/>
</div>
<div class="adjacent-input">
<label for="opt-out-analytics">
<span class="label__title">Telemetry</span>
Expand Down
2 changes: 1 addition & 1 deletion apps/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "theseus_gui"
version = "0.8.7"
version = "0.8.8"
description = "The Modrinth App is a desktop application for managing your Minecraft mods"
license = "GPL-3.0-only"
repository = "https://github.com/modrinth/code/apps/app/"
Expand Down
1 change: 1 addition & 0 deletions apps/app/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ fn main() {
"show_ads_window",
"record_ads_click",
"open_link",
"get_ads_personalization",
])
.default_permission(
DefaultPermissionRule::AllowAllCommands,
Expand Down
2 changes: 1 addition & 1 deletion apps/app/gen/schemas/acl-manifests.json

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions apps/app/gen/schemas/desktop-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@
"type": "string",
"const": "ads:default"
},
{
"description": "Enables the get_ads_personalization command without any pre-configured scope.",
"type": "string",
"const": "ads:allow-get-ads-personalization"
},
{
"description": "Enables the hide_ads_window command without any pre-configured scope.",
"type": "string",
Expand Down Expand Up @@ -360,6 +365,11 @@
"type": "string",
"const": "ads:allow-show-ads-window"
},
{
"description": "Denies the get_ads_personalization command without any pre-configured scope.",
"type": "string",
"const": "ads:deny-get-ads-personalization"
},
{
"description": "Denies the hide_ads_window command without any pre-configured scope.",
"type": "string",
Expand Down
10 changes: 10 additions & 0 deletions apps/app/gen/schemas/macOS-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@
"type": "string",
"const": "ads:default"
},
{
"description": "Enables the get_ads_personalization command without any pre-configured scope.",
"type": "string",
"const": "ads:allow-get-ads-personalization"
},
{
"description": "Enables the hide_ads_window command without any pre-configured scope.",
"type": "string",
Expand Down Expand Up @@ -360,6 +365,11 @@
"type": "string",
"const": "ads:allow-show-ads-window"
},
{
"description": "Denies the get_ads_personalization command without any pre-configured scope.",
"type": "string",
"const": "ads:deny-get-ads-personalization"
},
{
"description": "Denies the hide_ads_window command without any pre-configured scope.",
"type": "string",
Expand Down
10 changes: 9 additions & 1 deletion apps/app/src/api/ads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::time::{Duration, Instant};
use tauri::plugin::TauriPlugin;
use tauri::{Emitter, LogicalPosition, LogicalSize, Manager, Runtime};
use tauri_plugin_shell::ShellExt;
use theseus::settings;
use tokio::sync::RwLock;

pub struct AdsState {
Expand Down Expand Up @@ -50,6 +51,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
show_ads_window,
record_ads_click,
open_link,
get_ads_personalization,
])
.build()
}
Expand Down Expand Up @@ -82,7 +84,7 @@ pub async fn init_ads_window<R: Runtime>(
let _ = webview.set_size(LogicalSize::new(width, height));
}
} else if let Some(window) = app.get_window("main") {
let window = window.add_child(
let _ = window.add_child(
tauri::webview::WebviewBuilder::new(
"ads-window",
WebviewUrl::External(
Expand Down Expand Up @@ -206,3 +208,9 @@ pub async fn open_link<R: Runtime>(

Ok(())
}

#[tauri::command]
pub async fn get_ads_personalization() -> crate::api::Result<bool> {
let res = settings::get().await?;
Ok(res.personalized_ads)
}
2 changes: 1 addition & 1 deletion apps/app/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
]
},
"productName": "Modrinth App",
"version": "0.8.7",
"version": "0.8.8",
"mainBinaryName": "Modrinth App",
"identifier": "ModrinthApp",
"plugins": {
Expand Down
37 changes: 27 additions & 10 deletions apps/frontend/src/public/promo-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,27 @@
</head>
<body>
<div class="ads-container">
<a id="plus-link" href="https://modrinth.com/plus" target="_blank"></a>
<div id="plus-link"></div>
<div id="modrinth-rail-1" />
</div>
<script>
window.tude = window.tude || { cmd: [] };
tude.cmd.push(function () {
tude.refreshAdsViaDivMappings([
{
divId: "modrinth-rail-1",
baseDivId: "pb-slot-square-2",
},
]);
});
window.__TAURI_INTERNALS__.invoke("plugin:ads|get_ads_personalization", {})
.then((personalized) => {
window.tude = window.tude || { cmd: [] };

tude.cmd.push(function () {
tude.refreshAdsViaDivMappings([
{
divId: "modrinth-rail-1",
baseDivId: "pb-slot-square-2",
},
]);

tude.setPrivacySettings({
personalizedAds: personalized ?? true,
})
});
});

window.addEventListener(
"message",
Expand Down Expand Up @@ -84,6 +92,15 @@
});

document.addEventListener("contextmenu", (event) => event.preventDefault());

const plusLink = document.getElementById("plus-link");
plusLink.addEventListener('click', function() {
window.__TAURI_INTERNALS__.invoke("plugin:ads|record_ads_click", {});
window.__TAURI_INTERNALS__.invoke("plugin:ads|open_link", {
path: 'https://modrinth.com/plus',
origin: 'https://modrinth.com',
});
});
</script>
</body>
</html>

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.

This file was deleted.

2 changes: 1 addition & 1 deletion packages/app-lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "theseus"
version = "0.8.7"
version = "0.8.8"
authors = ["Jai A <[email protected]>"]
edition = "2021"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE settings ADD COLUMN personalized_ads INTEGER NOT NULL DEFAULT TRUE;
Loading

0 comments on commit 63399df

Please sign in to comment.