refactor: rename functions to make sense

This commit is contained in:
tdgao
2026-07-24 09:13:50 -07:00
parent 6b3869a657
commit 3c61dda7be
5 changed files with 19 additions and 23 deletions
+2 -2
View File
@@ -92,10 +92,10 @@ import { useCheckDisableMouseover } from '@/composables/macCssFix.js'
import { config } from '@/config'
import {
ads_consent_listener,
get_ads_consent_required,
hide_ads_window,
init_ads_window,
perform_ads_consent_action,
should_show_ads_consent_popup,
show_ads_window,
} from '@/helpers/ads.js'
import { debugAnalytics, initAnalytics, trackEvent } from '@/helpers/analytics'
@@ -318,7 +318,7 @@ onMounted(async () => {
await useCheckDisableMouseover()
try {
unlistenAdsConsent = await ads_consent_listener(handleAdsConsentRequired)
handleAdsConsentRequired(await get_ads_consent_required())
handleAdsConsentRequired(await should_show_ads_consent_popup())
} catch (error) {
handleError(error)
}
+2 -2
View File
@@ -16,8 +16,8 @@ export async function hide_ads_window(reset) {
return await invoke('plugin:ads|hide_ads_window', { reset })
}
export async function get_ads_consent_required() {
return await invoke('plugin:ads|get_ads_consent_required')
export async function should_show_ads_consent_popup() {
return await invoke('plugin:ads|should_show_ads_consent_popup')
}
export async function perform_ads_consent_action(action) {
+4 -4
View File
@@ -278,11 +278,11 @@ fn main() {
"hide_ads_window",
"scroll_ads_window",
"show_ads_window",
"show_ads_consent_overlay",
"show_ads_consent_preferences",
"show_ads_consent_ui",
"expand_ads_consent_webview",
"open_ads_consent_preferences",
"hide_ads_consent_overlay",
"get_ads_consent_required",
"finish_ads_consent_flow",
"should_show_ads_consent_popup",
"perform_ads_consent_action",
"record_ads_click",
"open_link",
+3 -7
View File
@@ -35,17 +35,13 @@ async function invokeAdsConsentPopupMode(mode) {
try {
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
}
await invoke('plugin:ads|show_ads_consent_overlay', {
await invoke('plugin:ads|show_ads_consent_ui', {
notificationEnabled: mode === 'custom',
})
if (mode === 'fallback') {
await invoke('plugin:ads|show_ads_consent_preferences')
}
} catch {}
}
@@ -54,5 +50,5 @@ async function expandAdsConsentWebview() {
const invoke = getTauriInvoke()
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')
}
+8 -8
View File
@@ -363,11 +363,11 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
init_ads_window,
hide_ads_window,
show_ads_window,
show_ads_consent_overlay,
show_ads_consent_preferences,
show_ads_consent_ui,
expand_ads_consent_webview,
open_ads_consent_preferences,
hide_ads_consent_overlay,
get_ads_consent_required,
finish_ads_consent_flow,
should_show_ads_consent_popup,
perform_ads_consent_action,
record_ads_click,
open_link,
@@ -755,7 +755,7 @@ pub async fn hide_ads_window<R: Runtime>(
}
#[tauri::command]
pub async fn show_ads_consent_overlay<R: Runtime>(
pub async fn show_ads_consent_ui<R: Runtime>(
app: tauri::AppHandle<R>,
notification_enabled: bool,
) -> crate::api::Result<()> {
@@ -790,7 +790,7 @@ pub async fn show_ads_consent_overlay<R: Runtime>(
}
#[tauri::command]
pub async fn show_ads_consent_preferences<R: Runtime>(
pub async fn expand_ads_consent_webview<R: Runtime>(
app: tauri::AppHandle<R>,
) -> crate::api::Result<()> {
if let Some(webview) = app.webviews().get("ads-window") {
@@ -842,7 +842,7 @@ pub async fn open_ads_consent_preferences<R: Runtime>(
}
#[tauri::command]
pub async fn hide_ads_consent_overlay<R: Runtime>(
pub async fn finish_ads_consent_flow<R: Runtime>(
app: tauri::AppHandle<R>,
dpr: Option<f32>,
) -> crate::api::Result<()> {
@@ -883,7 +883,7 @@ pub async fn hide_ads_consent_overlay<R: Runtime>(
}
#[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>,
) -> crate::api::Result<bool> {
let state = app.state::<RwLock<AdsState>>();