UI only needs concrete client/source info

This commit is contained in:
B. Petersen
2026-08-11 15:06:55 +02:00
parent ee7bfb7937
commit a636f3a36e
3 changed files with 42 additions and 48 deletions

View File

@@ -64,7 +64,7 @@ use self::types::{
JsonrpcMessageListItem, MessageNotificationInfo, MessageSearchResult, MessageViewtype,
},
};
use crate::api::types::appversions::JsonrpcAppVersionInfo;
use crate::api::types::appversions::JsonrpcAppSource;
use crate::api::types::chat_list::{ChatListItemFetchResult, get_chat_list_item_by_id};
use crate::api::types::login_param::TransportListEntry;
use crate::api::types::qr::{QrObject, SecurejoinSource, SecurejoinUiPath};
@@ -2791,11 +2791,19 @@ impl CommandApi {
}
}
/// Get version information of clients.
async fn get_app_versions(&self, account_id: u32) -> Result<JsonrpcAppVersionInfo> {
/// Get version information of a specific client and source.
async fn get_app_version(
&self,
account_id: u32,
client_id: String,
source_id: String,
) -> Result<Option<JsonrpcAppSource>> {
let ctx = self.get_context(account_id).await?;
let info = deltachat::appversions::get_app_versions(&ctx).await?;
JsonrpcAppVersionInfo::from_core_type(info)
Ok(
deltachat::appversions::get_app_version(&ctx, &client_id, &source_id)
.await?
.map(|s| JsonrpcAppSource::from_core_type(s)),
)
}
}

View File

@@ -1,34 +1,11 @@
use anyhow::Result;
use deltachat::appversions::AppVersionInfo;
use deltachat::appversions::AppSource;
use serde::{Deserialize, Serialize};
use typescript_type_def::TypeDef;
/// Version information of clients.
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
#[serde(rename = "AppVersionInfo", rename_all = "camelCase")]
pub struct JsonrpcAppVersionInfo {
/// Array of clients with version information.
pub clients: Vec<JsonrpcAppClient>,
}
/// Version information of a single client, eg. "deltachat" or "ubuntutouch".
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
#[serde(rename = "AppClient", rename_all = "camelCase")]
pub struct JsonrpcAppClient {
/// ID how the client identifies itself, eg. "deltachat" or "ubuntutouch".
pub client_id: String,
/// Array of sources for that client.
pub sources: Vec<JsonrpcAppSource>,
}
/// Version information of a single source of a client, eg. "gplay" or "fdroid".
#[derive(Serialize, Deserialize, TypeDef, schemars::JsonSchema)]
#[serde(rename = "AppSource", rename_all = "camelCase")]
pub struct JsonrpcAppSource {
/// ID how the client identifies a source, eg. "gplay" or "fdroid".
pub app_id: String,
/// Always increasing version number.
pub version_integer: u32,
@@ -39,9 +16,12 @@ pub struct JsonrpcAppSource {
pub download_url: String,
}
impl JsonrpcAppVersionInfo {
pub fn from_core_type(info: AppVersionInfo) -> Result<Self> {
let value = serde_json::to_value(info)?;
Ok(serde_json::from_value(value)?)
impl JsonrpcAppSource {
pub fn from_core_type(source: AppSource) -> Self {
JsonrpcAppSource {
version_integer: source.version_integer,
version_string: source.version_string,
download_url: source.download_url,
}
}
}