Compare commits
12 Commits
1.3
...
release/an
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d098c9f76 | |||
| 2101aa7b14 | |||
| 65b3b9013a | |||
| 7056a7f836 | |||
| fd3660858e | |||
| 45285892de | |||
| 64d7394ffa | |||
| 69892a4d08 | |||
| a4bd28b22c | |||
| 335ded4752 | |||
| d40eb1886e | |||
| de06e449be |
58
.gitea/workflows/android-release.yaml
Normal file
58
.gitea/workflows/android-release.yaml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
name: Android Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'release/android/*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
ANDROID_SDK_ROOT: ${{ gitea.workspace }}/android-sdk
|
||||||
|
ANDROID_HOME: ${{ gitea.workspace }}/android-sdk
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-android-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Gitea's default act_runner labels map ubuntu-22.04 to node:16-bullseye,
|
||||||
|
# so keep the GitHub-hosted actions on their Node 16-compatible v3 line.
|
||||||
|
- name: Install system dependencies
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y ca-certificates git openjdk-17-jdk unzip wget
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install Android SDK components
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/android-commandlinetools.zip
|
||||||
|
|
||||||
|
rm -rf "$ANDROID_SDK_ROOT"
|
||||||
|
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||||
|
|
||||||
|
unzip -q /tmp/android-commandlinetools.zip -d /tmp/android-commandlinetools
|
||||||
|
mv /tmp/android-commandlinetools/cmdline-tools "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
||||||
|
|
||||||
|
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" --licenses
|
||||||
|
"$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" \
|
||||||
|
"platform-tools" \
|
||||||
|
"build-tools;33.0.1" \
|
||||||
|
"platforms;android-33"
|
||||||
|
|
||||||
|
- name: Build Android release APKs
|
||||||
|
working-directory: android
|
||||||
|
run: ./gradlew assembleRelease
|
||||||
|
|
||||||
|
- name: Upload release artifacts
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: kordophone-android-release
|
||||||
|
path: |
|
||||||
|
android/app/build/outputs/apk/release/*.apk
|
||||||
|
android/app/build/outputs/apk/release/output-metadata.json
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 90
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
|
ext/
|
||||||
target/
|
target/
|
||||||
|
|||||||
2
server/.gitmodules → .gitmodules
vendored
2
server/.gitmodules → .gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "CocoaHTTPServer"]
|
[submodule "CocoaHTTPServer"]
|
||||||
path = CocoaHTTPServer
|
path = server/CocoaHTTPServer
|
||||||
url = https://github.com/robbiehanson/CocoaHTTPServer.git
|
url = https://github.com/robbiehanson/CocoaHTTPServer.git
|
||||||
2
android/.idea/gradle.xml
generated
2
android/.idea/gradle.xml
generated
@@ -5,7 +5,7 @@
|
|||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="jbr-17" />
|
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
1
android/.idea/vcs.xml
generated
1
android/.idea/vcs.xml
generated
@@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -24,7 +24,7 @@ data class ServerConfig(
|
|||||||
fun loadFromSettings(context: Context): ServerConfig {
|
fun loadFromSettings(context: Context): ServerConfig {
|
||||||
val prefs = getSharedPreferences(context)
|
val prefs = getSharedPreferences(context)
|
||||||
return ServerConfig(
|
return ServerConfig(
|
||||||
serverName = prefs.getString("serverName", null),
|
serverName = prefs.getString("serverName", null).normalizedBaseUrl(),
|
||||||
authentication = ServerAuthentication.loadFromEncryptedSettings(context)
|
authentication = ServerAuthentication.loadFromEncryptedSettings(context)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ data class ServerConfig(
|
|||||||
fun saveToSettings(context: Context) {
|
fun saveToSettings(context: Context) {
|
||||||
val prefs = getSharedPreferences(context)
|
val prefs = getSharedPreferences(context)
|
||||||
prefs.edit {
|
prefs.edit {
|
||||||
putString("serverName", serverName)
|
putString("serverName", serverName.normalizedBaseUrl())
|
||||||
apply()
|
apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,6 +45,11 @@ data class ServerConfig(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun String?.normalizedBaseUrl(): String? {
|
||||||
|
val value = this?.trim()?.takeIf { it.isNotEmpty() } ?: return null
|
||||||
|
return if (value.endsWith("/")) value else "$value/"
|
||||||
|
}
|
||||||
|
|
||||||
data class ServerAuthentication(
|
data class ServerAuthentication(
|
||||||
val username: String,
|
val username: String,
|
||||||
val password: String,
|
val password: String,
|
||||||
@@ -101,7 +106,9 @@ class ServerConfigRepository @Inject constructor(
|
|||||||
|
|
||||||
fun applyConfig(applicator: ServerConfig.() -> Unit) {
|
fun applyConfig(applicator: ServerConfig.() -> Unit) {
|
||||||
val config = _serverConfig.value.copy()
|
val config = _serverConfig.value.copy()
|
||||||
_serverConfig.value = config.apply(applicator)
|
_serverConfig.value = config.apply(applicator).also {
|
||||||
|
it.serverName = it.serverName.normalizedBaseUrl()
|
||||||
|
}
|
||||||
_serverConfig.value.saveToSettings(context)
|
_serverConfig.value.saveToSettings(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,8 +104,10 @@ class APIClientFactory {
|
|||||||
return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.NOT_CONFIGURED)
|
return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.NOT_CONFIGURED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val normalizedServerString = serverString.ensureTrailingSlash()
|
||||||
|
|
||||||
// Try to parse server string
|
// Try to parse server string
|
||||||
val serverURL = HttpUrl.parse(serverString)
|
val serverURL = HttpUrl.parse(normalizedServerString)
|
||||||
?: return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.INVALID_HOST_URL)
|
?: return InvalidConfigurationAPIClient(InvalidConfigurationAPIClient.Issue.INVALID_HOST_URL)
|
||||||
|
|
||||||
return RetrofitAPIClient(serverURL.url(), authentication)
|
return RetrofitAPIClient(serverURL.url(), authentication)
|
||||||
@@ -113,6 +115,10 @@ class APIClientFactory {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun String.ensureTrailingSlash(): String {
|
||||||
|
return if (endsWith("/")) this else "$this/"
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Is this a dumb idea?
|
// TODO: Is this a dumb idea?
|
||||||
class InvalidConfigurationAPIClient(val issue: Issue): APIClient {
|
class InvalidConfigurationAPIClient(val issue: Issue): APIClient {
|
||||||
enum class Issue {
|
enum class Issue {
|
||||||
@@ -215,4 +221,4 @@ fun URL.authenticatedWebSocketURL(serverPath: String, params: Map<String, String
|
|||||||
}
|
}
|
||||||
|
|
||||||
return URL(requestURL.build().toString())
|
return URL(requestURL.build().toString())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,13 +55,13 @@ data class UploadAttachmentResponse(
|
|||||||
)
|
)
|
||||||
|
|
||||||
interface APIInterface {
|
interface APIInterface {
|
||||||
@GET("/version")
|
@GET("version")
|
||||||
suspend fun getVersion(): ResponseBody
|
suspend fun getVersion(): ResponseBody
|
||||||
|
|
||||||
@GET("/conversations")
|
@GET("conversations")
|
||||||
suspend fun getConversations(): Response<List<Conversation>>
|
suspend fun getConversations(): Response<List<Conversation>>
|
||||||
|
|
||||||
@GET("/messages")
|
@GET("messages")
|
||||||
suspend fun getMessages(
|
suspend fun getMessages(
|
||||||
@Query("guid") conversationGUID: String,
|
@Query("guid") conversationGUID: String,
|
||||||
@Query("limit") limit: Int? = null,
|
@Query("limit") limit: Int? = null,
|
||||||
@@ -69,19 +69,19 @@ interface APIInterface {
|
|||||||
@Query("afterMessageGUID") afterMessageGUID: GUID? = null,
|
@Query("afterMessageGUID") afterMessageGUID: GUID? = null,
|
||||||
): Response<List<Message>>
|
): Response<List<Message>>
|
||||||
|
|
||||||
@POST("/sendMessage")
|
@POST("sendMessage")
|
||||||
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
|
suspend fun sendMessage(@Body request: SendMessageRequest): Response<SendMessageResponse>
|
||||||
|
|
||||||
@POST("/markConversation")
|
@POST("markConversation")
|
||||||
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
|
suspend fun markConversation(@Query("guid") conversationGUID: String): Response<Void>
|
||||||
|
|
||||||
@GET("/attachment")
|
@GET("attachment")
|
||||||
suspend fun fetchAttachment(@Query("guid") guid: String, @Query("preview") preview: Boolean = false): ResponseBody
|
suspend fun fetchAttachment(@Query("guid") guid: String, @Query("preview") preview: Boolean = false): ResponseBody
|
||||||
|
|
||||||
@POST("/uploadAttachment")
|
@POST("uploadAttachment")
|
||||||
suspend fun uploadAttachment(@Query("filename") filename: String, @Body body: RequestBody): Response<UploadAttachmentResponse>
|
suspend fun uploadAttachment(@Query("filename") filename: String, @Body body: RequestBody): Response<UploadAttachmentResponse>
|
||||||
|
|
||||||
@POST("/authenticate")
|
@POST("authenticate")
|
||||||
suspend fun authenticate(@Body request: AuthenticationRequest): Response<AuthenticationResponse>
|
suspend fun authenticate(@Body request: AuthenticationRequest): Response<AuthenticationResponse>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,4 +93,4 @@ fun <T> Response<T>.bodyOnSuccessOrThrow(): T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
throw ResponseDecodeError(errorBody()!!)
|
throw ResponseDecodeError(errorBody()!!)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import net.buzzert.kordophone.backend.db.CachedChatDatabase
|
|||||||
import net.buzzert.kordophone.backend.model.Message
|
import net.buzzert.kordophone.backend.model.Message
|
||||||
import net.buzzert.kordophone.backend.model.OutgoingMessage
|
import net.buzzert.kordophone.backend.model.OutgoingMessage
|
||||||
import net.buzzert.kordophone.backend.server.APIClient
|
import net.buzzert.kordophone.backend.server.APIClient
|
||||||
|
import net.buzzert.kordophone.backend.server.APIClientFactory
|
||||||
import net.buzzert.kordophone.backend.server.APIInterface
|
import net.buzzert.kordophone.backend.server.APIInterface
|
||||||
import net.buzzert.kordophone.backend.server.Authentication
|
import net.buzzert.kordophone.backend.server.Authentication
|
||||||
import net.buzzert.kordophone.backend.server.ChatRepository
|
import net.buzzert.kordophone.backend.server.ChatRepository
|
||||||
@@ -38,6 +39,16 @@ class BackendTests {
|
|||||||
return Pair(repository, mockServer)
|
return Pair(repository, mockServer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testCreateClientAcceptsBaseUrlWithoutTrailingSlash() {
|
||||||
|
val client = APIClientFactory.createClient(
|
||||||
|
"https://example.com/api",
|
||||||
|
Authentication("test", "test")
|
||||||
|
)
|
||||||
|
|
||||||
|
assertTrue(client.isConfigured)
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testGetVersion() = runBlocking {
|
fun testGetVersion() = runBlocking {
|
||||||
val (repository, mockServer) = mockRepository()
|
val (repository, mockServer) = mockRepository()
|
||||||
@@ -342,4 +353,4 @@ class BackendTests {
|
|||||||
assertEquals(messagesToGenerate, allMessages.count())
|
assertEquals(messagesToGenerate, allMessages.count())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
core/Cargo.lock
generated
2
core/Cargo.lock
generated
@@ -1274,7 +1274,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kordophoned"
|
name = "kordophoned"
|
||||||
version = "1.0.1"
|
version = "1.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "kordophoned"
|
name = "kordophoned"
|
||||||
version = "1.0.1"
|
version = "1.3.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "GPL-3.0"
|
license = "GPL-3.0"
|
||||||
description = "Client daemon for the Kordophone chat protocol"
|
description = "Client daemon for the Kordophone chat protocol"
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ all: setup
|
|||||||
setup: build/
|
setup: build/
|
||||||
meson build
|
meson build
|
||||||
|
|
||||||
VER := 1.0.2
|
VER_RAW := $(shell git -C .. describe --tags --abbrev=0 2>/dev/null || git -C .. describe --tags 2>/dev/null || printf '0.0.0')
|
||||||
|
VER := $(patsubst v%,%,$(VER_RAW))
|
||||||
TMP := $(shell mktemp -d)
|
TMP := $(shell mktemp -d)
|
||||||
rpm:
|
rpm:
|
||||||
git -C .. archive --format=tar.gz --prefix=kordophone/ -o $(TMP)/v$(VER).tar.gz HEAD
|
git -C .. archive --format=tar.gz --prefix=kordophone/ -o $(TMP)/v$(VER).tar.gz HEAD
|
||||||
rpmbuild -ba dist/rpm/kordophone.spec --define "_sourcedir $(TMP)"
|
rpmbuild -ba dist/rpm/kordophone.spec --define "_sourcedir $(TMP)" --define "app_version $(VER)"
|
||||||
|
|
||||||
deb:
|
deb:
|
||||||
./dist/deb/build-deb.sh $(VER)
|
./dist/deb/build-deb.sh $(VER)
|
||||||
|
|||||||
2
gtk/dist/deb/build-deb.sh
vendored
2
gtk/dist/deb/build-deb.sh
vendored
@@ -37,7 +37,7 @@ Priority: optional
|
|||||||
Architecture: ${ARCH}
|
Architecture: ${ARCH}
|
||||||
Maintainer: James Magahern <james@magahern.com>
|
Maintainer: James Magahern <james@magahern.com>
|
||||||
Installed-Size: ${INSTALLED_SIZE_KB}
|
Installed-Size: ${INSTALLED_SIZE_KB}
|
||||||
Depends: libgtk-4-1, libadwaita-1-0, libglib2.0-0, libgee-0.8-2, libsecret-1-0, kordophoned (>= 1.0.0)
|
Depends: libgtk-4-1, libadwaita-1-0, libglib2.0-0, libgee-0.8-2, libsecret-1-0, kordophoned (>= 1.3.0)
|
||||||
Description: GTK4/Libadwaita client for Kordophone
|
Description: GTK4/Libadwaita client for Kordophone
|
||||||
A GTK4/Libadwaita Linux client for the Kordophone client daemon.
|
A GTK4/Libadwaita Linux client for the Kordophone client daemon.
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
5
gtk/dist/rpm/kordophone.spec
vendored
5
gtk/dist/rpm/kordophone.spec
vendored
@@ -1,5 +1,5 @@
|
|||||||
Name: kordophone
|
Name: kordophone
|
||||||
Version: 1.0.2
|
Version: %{?app_version}%{!?app_version:1.3.0}
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: GTK4/Libadwaita client for Kordophone
|
Summary: GTK4/Libadwaita client for Kordophone
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ Requires: libadwaita
|
|||||||
Requires: glib2
|
Requires: glib2
|
||||||
Requires: libgee
|
Requires: libgee
|
||||||
Requires: libsecret
|
Requires: libsecret
|
||||||
Requires: kordophoned >= 1.0.0
|
Requires: kordophoned >= 1.3.0
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A GTK4/Libadwaita Linux Client for the Kordophone client daemon.
|
A GTK4/Libadwaita Linux Client for the Kordophone client daemon.
|
||||||
@@ -49,4 +49,3 @@ popd
|
|||||||
%changelog
|
%changelog
|
||||||
* Fri Aug 8 2025 James Magahern <james@magahern.com>
|
* Fri Aug 8 2025 James Magahern <james@magahern.com>
|
||||||
- Updated rpmspec
|
- Updated rpmspec
|
||||||
|
|
||||||
|
|||||||
@@ -60,22 +60,31 @@ private class ImageBubbleLayout : BubbleLayout
|
|||||||
this.is_downloaded = false;
|
this.is_downloaded = false;
|
||||||
this.cached_texture = TextureCache.get_instance().get_texture(attachment_guid);
|
this.cached_texture = TextureCache.get_instance().get_texture(attachment_guid);
|
||||||
|
|
||||||
|
if (this.cached_texture != null) {
|
||||||
|
this.image_size = Graphene.Size() {
|
||||||
|
width = (float)this.cached_texture.get_width(),
|
||||||
|
height = (float)this.cached_texture.get_height()
|
||||||
|
};
|
||||||
|
SizeCache.get_instance().set_size(attachment_guid, this.image_size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate image dimensions for layout
|
// Calculate image dimensions for layout
|
||||||
calculate_image_dimensions(image_size);
|
calculate_image_dimensions(image_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculate_image_dimensions(Graphene.Size? image_size) {
|
private void calculate_image_dimensions(Graphene.Size? image_size) {
|
||||||
if (image_size != null) {
|
|
||||||
this.image_size = image_size;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cached_size = SizeCache.get_instance().get_size(attachment_guid);
|
var cached_size = SizeCache.get_instance().get_size(attachment_guid);
|
||||||
if (cached_size != null) {
|
if (cached_size != null) {
|
||||||
this.image_size = cached_size;
|
this.image_size = cached_size;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (image_size != null) {
|
||||||
|
this.image_size = image_size;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.image_size = Graphene.Size() { width = 200.0f, height = 150.0f };
|
this.image_size = Graphene.Size() { width = 200.0f, height = 150.0f };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,8 @@ private class TranscriptDrawingArea : Widget
|
|||||||
|
|
||||||
private void recompute_message_layouts() {
|
private void recompute_message_layouts() {
|
||||||
var container_width = get_width();
|
var container_width = get_width();
|
||||||
float max_width = container_width * 0.90f;
|
float max_width = container_width * 0.80f;
|
||||||
|
float image_max_width = max_width * 0.70f;
|
||||||
|
|
||||||
DateTime? last_date = null;
|
DateTime? last_date = null;
|
||||||
string? last_sender = null;
|
string? last_sender = null;
|
||||||
@@ -371,7 +372,7 @@ private class TranscriptDrawingArea : Widget
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var image_layout = new ImageBubbleLayout(attachment.guid, message.from_me, this, max_width, image_size);
|
var image_layout = new ImageBubbleLayout(attachment.guid, message.from_me, this, image_max_width, image_size);
|
||||||
image_layout.id = @"image-$(attachment.guid)";
|
image_layout.id = @"image-$(attachment.guid)";
|
||||||
|
|
||||||
if (animate) {
|
if (animate) {
|
||||||
|
|||||||
@@ -159,7 +159,6 @@ public class TranscriptView : Adw.Bin
|
|||||||
}
|
}
|
||||||
|
|
||||||
delegate void OpenPath(string path);
|
delegate void OpenPath(string path);
|
||||||
private ulong attachment_downloaded_handler_id = 0;
|
|
||||||
private void open_attachment(string attachment_guid) {
|
private void open_attachment(string attachment_guid) {
|
||||||
OpenPath open_path = (path) => {
|
OpenPath open_path = (path) => {
|
||||||
try {
|
try {
|
||||||
@@ -180,10 +179,17 @@ public class TranscriptView : Adw.Bin
|
|||||||
|
|
||||||
// TODO: Should probably indicate progress here.
|
// TODO: Should probably indicate progress here.
|
||||||
|
|
||||||
attachment_downloaded_handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
ulong handler_id = 0;
|
||||||
|
handler_id = Repository.get_instance().attachment_downloaded.connect((guid) => {
|
||||||
if (guid == attachment_guid) {
|
if (guid == attachment_guid) {
|
||||||
open_path(attachment_info.path);
|
try {
|
||||||
Repository.get_instance().disconnect(attachment_downloaded_handler_id);
|
var updated_attachment_info = Repository.get_instance().get_attachment_info(attachment_guid);
|
||||||
|
open_path(updated_attachment_info.path);
|
||||||
|
} catch (GLib.Error e) {
|
||||||
|
warning("Failed to get attachment info after download: %s", e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
Repository.get_instance().disconnect(handler_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user