mirror of
https://github.com/modrinth/code.git
synced 2026-09-02 13:05:50 +00:00
refactor: rename functions to make sense
This commit is contained in:
@@ -92,10 +92,10 @@ import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
|
|||||||
import { config } from '@/config'
|
import { config } from '@/config'
|
||||||
import {
|
import {
|
||||||
ads_consent_listener,
|
ads_consent_listener,
|
||||||
get_ads_consent_required,
|
|
||||||
hide_ads_window,
|
hide_ads_window,
|
||||||
init_ads_window,
|
init_ads_window,
|
||||||
perform_ads_consent_action,
|
perform_ads_consent_action,
|
||||||
|
should_show_ads_consent_popup,
|
||||||
show_ads_window,
|
show_ads_window,
|
||||||
} from '@/helpers/ads.js'
|
} from '@/helpers/ads.js'
|
||||||
import { debugAnalytics, initAnalytics, trackEvent } from '@/helpers/analytics'
|
import { debugAnalytics, initAnalytics, trackEvent } from '@/helpers/analytics'
|
||||||
@@ -318,7 +318,7 @@ onMounted(async () => {
|
|||||||
await useCheckDisableMouseover()
|
await useCheckDisableMouseover()
|
||||||
try {
|
try {
|
||||||
unlistenAdsConsent = await ads_consent_listener(handleAdsConsentRequired)
|
unlistenAdsConsent = await ads_consent_listener(handleAdsConsentRequired)
|
||||||
handleAdsConsentRequired(await get_ads_consent_required())
|
handleAdsConsentRequired(await should_show_ads_consent_popup())
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
handleError(error)
|
handleError(error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export async function hide_ads_window(reset) {
|
|||||||
return await invoke('plugin:ads|hide_ads_window', { reset })
|
return await invoke('plugin:ads|hide_ads_window', { reset })
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function get_ads_consent_required() {
|
export async function should_show_ads_consent_popup() {
|
||||||
return await invoke('plugin:ads|get_ads_consent_required')
|
return await invoke('plugin:ads|should_show_ads_consent_popup')
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function perform_ads_consent_action(action) {
|
export async function perform_ads_consent_action(action) {
|
||||||
|
|||||||
+4
-4
@@ -278,11 +278,11 @@ fn main() {
|
|||||||
"hide_ads_window",
|
"hide_ads_window",
|
||||||
"scroll_ads_window",
|
"scroll_ads_window",
|
||||||
"show_ads_window",
|
"show_ads_window",
|
||||||
"show_ads_consent_overlay",
|
"show_ads_consent_ui",
|
||||||
"show_ads_consent_preferences",
|
"expand_ads_consent_webview",
|
||||||
"open_ads_consent_preferences",
|
"open_ads_consent_preferences",
|
||||||
"hide_ads_consent_overlay",
|
"finish_ads_consent_flow",
|
||||||
"get_ads_consent_required",
|
"should_show_ads_consent_popup",
|
||||||
"perform_ads_consent_action",
|
"perform_ads_consent_action",
|
||||||
"record_ads_click",
|
"record_ads_click",
|
||||||
"open_link",
|
"open_link",
|
||||||
|
|||||||
@@ -35,17 +35,13 @@ async function invokeAdsConsentPopupMode(mode) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (mode === 'hidden') {
|
if (mode === 'hidden') {
|
||||||
await invoke('plugin:ads|hide_ads_consent_overlay', { dpr: window.devicePixelRatio })
|
await invoke('plugin:ads|finish_ads_consent_flow', { dpr: window.devicePixelRatio })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
await invoke('plugin:ads|show_ads_consent_overlay', {
|
await invoke('plugin:ads|show_ads_consent_ui', {
|
||||||
notificationEnabled: mode === 'custom',
|
notificationEnabled: mode === 'custom',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (mode === 'fallback') {
|
|
||||||
await invoke('plugin:ads|show_ads_consent_preferences')
|
|
||||||
}
|
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,5 +50,5 @@ async function expandAdsConsentWebview() {
|
|||||||
const invoke = getTauriInvoke()
|
const invoke = getTauriInvoke()
|
||||||
if (!invoke) throw new Error('Tauri invoke is unavailable in the ads webview')
|
if (!invoke) throw new Error('Tauri invoke is unavailable in the ads webview')
|
||||||
|
|
||||||
await invoke('plugin:ads|show_ads_consent_preferences')
|
await invoke('plugin:ads|expand_ads_consent_webview')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,11 +363,11 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
|||||||
init_ads_window,
|
init_ads_window,
|
||||||
hide_ads_window,
|
hide_ads_window,
|
||||||
show_ads_window,
|
show_ads_window,
|
||||||
show_ads_consent_overlay,
|
show_ads_consent_ui,
|
||||||
show_ads_consent_preferences,
|
expand_ads_consent_webview,
|
||||||
open_ads_consent_preferences,
|
open_ads_consent_preferences,
|
||||||
hide_ads_consent_overlay,
|
finish_ads_consent_flow,
|
||||||
get_ads_consent_required,
|
should_show_ads_consent_popup,
|
||||||
perform_ads_consent_action,
|
perform_ads_consent_action,
|
||||||
record_ads_click,
|
record_ads_click,
|
||||||
open_link,
|
open_link,
|
||||||
@@ -755,7 +755,7 @@ pub async fn hide_ads_window<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn show_ads_consent_overlay<R: Runtime>(
|
pub async fn show_ads_consent_ui<R: Runtime>(
|
||||||
app: tauri::AppHandle<R>,
|
app: tauri::AppHandle<R>,
|
||||||
notification_enabled: bool,
|
notification_enabled: bool,
|
||||||
) -> crate::api::Result<()> {
|
) -> crate::api::Result<()> {
|
||||||
@@ -790,7 +790,7 @@ pub async fn show_ads_consent_overlay<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn show_ads_consent_preferences<R: Runtime>(
|
pub async fn expand_ads_consent_webview<R: Runtime>(
|
||||||
app: tauri::AppHandle<R>,
|
app: tauri::AppHandle<R>,
|
||||||
) -> crate::api::Result<()> {
|
) -> crate::api::Result<()> {
|
||||||
if let Some(webview) = app.webviews().get("ads-window") {
|
if let Some(webview) = app.webviews().get("ads-window") {
|
||||||
@@ -842,7 +842,7 @@ pub async fn open_ads_consent_preferences<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn hide_ads_consent_overlay<R: Runtime>(
|
pub async fn finish_ads_consent_flow<R: Runtime>(
|
||||||
app: tauri::AppHandle<R>,
|
app: tauri::AppHandle<R>,
|
||||||
dpr: Option<f32>,
|
dpr: Option<f32>,
|
||||||
) -> crate::api::Result<()> {
|
) -> crate::api::Result<()> {
|
||||||
@@ -883,7 +883,7 @@ pub async fn hide_ads_consent_overlay<R: Runtime>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn get_ads_consent_required<R: Runtime>(
|
pub async fn should_show_ads_consent_popup<R: Runtime>(
|
||||||
app: tauri::AppHandle<R>,
|
app: tauri::AppHandle<R>,
|
||||||
) -> crate::api::Result<bool> {
|
) -> crate::api::Result<bool> {
|
||||||
let state = app.state::<RwLock<AdsState>>();
|
let state = app.state::<RwLock<AdsState>>();
|
||||||
|
|||||||
Reference in New Issue
Block a user