mirror of
https://github.com/chatmail/core.git
synced 2026-09-22 13:01:21 +03:00
UI only needs concrete client/source info
This commit is contained in:
@@ -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)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user