mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 00:36:38 -04:00

* Add AnkiHub section to preferences screen * Add short intro for AnkiWeb and AnkiHub to syncing section * Add AnkiHub login screen * Implement login methods in backend * Set minimum dialog width * Add missing colon * Respect the ANKIHUB_APP_URL env var This is used by the add-on. * Simplify login error reporting * Fix from_prefs_screen not passed to subcall * Add missing ankihub_pb2 import * Install AnkiHub add-on after sign-in * Avoid .exec() * Update ftl/core/sync.ftl Co-authored-by: Damien Elmes <dae@users.noreply.github.com> * Split translation string * Support login by username/email * Fix entered username/email not being passed back to on_done * Remove unused import * Move to 'Third-party services' section * Tweak login dialog's heading * Remove 'third-party' from intro text * Tweak copy * Prefix profile keys * Tweak strings * Remove description from login dialog * Remove signup links * Clear credentials in ankihub_logout() * Call .adjustSize() * Title Case * Add padding to third-party services, and fix tab order from other PR
34 lines
1.1 KiB
Rust
34 lines
1.1 KiB
Rust
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
use super::Backend;
|
|
use crate::ankihub::login::ankihub_login;
|
|
use crate::ankihub::login::ankihub_logout;
|
|
use crate::ankihub::login::LoginResponse;
|
|
use crate::prelude::*;
|
|
|
|
impl From<LoginResponse> for anki_proto::ankihub::LoginResponse {
|
|
fn from(value: LoginResponse) -> Self {
|
|
anki_proto::ankihub::LoginResponse {
|
|
token: value.token.unwrap_or_default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl crate::services::BackendAnkiHubService for Backend {
|
|
fn ankihub_login(
|
|
&self,
|
|
input: anki_proto::ankihub::LoginRequest,
|
|
) -> Result<anki_proto::ankihub::LoginResponse> {
|
|
let rt = self.runtime_handle();
|
|
let fut = ankihub_login(input.id, input.password, self.web_client());
|
|
|
|
rt.block_on(fut).map(|a| a.into())
|
|
}
|
|
|
|
fn ankihub_logout(&self, input: anki_proto::ankihub::LogoutRequest) -> Result<()> {
|
|
let rt = self.runtime_handle();
|
|
let fut = ankihub_logout(input.token, self.web_client());
|
|
rt.block_on(fut)
|
|
}
|
|
}
|