feat(web,server): external domain setting (#6146)
* feat: external domain setting * chore: open api * mobile: handle serverconfig-externalDomain --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:immich_mobile/modules/search/ui/thumbnail_with_info.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/models/shared_link.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/providers/shared_link.provider.dart';
|
||||
import 'package:immich_mobile/routing/router.dart';
|
||||
import 'package:immich_mobile/shared/providers/server_info.provider.dart';
|
||||
import 'package:immich_mobile/shared/ui/confirm_dialog.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
||||
import 'package:immich_mobile/utils/image_url_builder.dart';
|
||||
@@ -71,7 +72,11 @@ class SharedLinkItem extends ConsumerWidget {
|
||||
final imageSize = math.min(context.width / 4, 100.0);
|
||||
|
||||
void copyShareLinkToClipboard() {
|
||||
final serverUrl = getServerUrl();
|
||||
final externalDomain = ref.read(
|
||||
serverInfoProvider.select((s) => s.serverConfig.externalDomain),
|
||||
);
|
||||
final serverUrl =
|
||||
externalDomain.isNotEmpty ? externalDomain : getServerUrl();
|
||||
if (serverUrl == null) {
|
||||
ImmichToast.show(
|
||||
context: context,
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:immich_mobile/extensions/build_context_extensions.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/models/shared_link.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/providers/shared_link.provider.dart';
|
||||
import 'package:immich_mobile/modules/shared_link/services/shared_link.service.dart';
|
||||
import 'package:immich_mobile/shared/providers/server_info.provider.dart';
|
||||
import 'package:immich_mobile/shared/ui/immich_toast.dart';
|
||||
import 'package:immich_mobile/utils/url_helper.dart';
|
||||
|
||||
@@ -353,7 +354,11 @@ class SharedLinkEditPage extends HookConsumerWidget {
|
||||
expiresAt: expiryAfter.value == 0 ? null : calculateExpiry(),
|
||||
);
|
||||
ref.invalidate(sharedLinksStateProvider);
|
||||
final serverUrl = getServerUrl();
|
||||
final externalDomain = ref.read(
|
||||
serverInfoProvider.select((s) => s.serverConfig.externalDomain),
|
||||
);
|
||||
final serverUrl =
|
||||
externalDomain.isNotEmpty ? externalDomain : getServerUrl();
|
||||
if (newLink != null && serverUrl != null) {
|
||||
newShareLink.value = "$serverUrl/share/${newLink.key}";
|
||||
copyLinkToClipboard();
|
||||
|
||||
@@ -2,35 +2,40 @@ import 'package:openapi/api.dart';
|
||||
|
||||
class ServerConfig {
|
||||
final int trashDays;
|
||||
final String externalDomain;
|
||||
|
||||
const ServerConfig({
|
||||
required this.trashDays,
|
||||
required this.externalDomain,
|
||||
});
|
||||
|
||||
ServerConfig copyWith({
|
||||
int? trashDays,
|
||||
String? externalDomain,
|
||||
}) {
|
||||
return ServerConfig(
|
||||
trashDays: trashDays ?? this.trashDays,
|
||||
externalDomain: externalDomain ?? this.externalDomain,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ServerConfig(trashDays: $trashDays)';
|
||||
}
|
||||
String toString() =>
|
||||
'ServerConfig(trashDays: $trashDays, externalDomain: $externalDomain)';
|
||||
|
||||
ServerConfig.fromDto(ServerConfigDto dto) : trashDays = dto.trashDays;
|
||||
ServerConfig.fromDto(ServerConfigDto dto)
|
||||
: trashDays = dto.trashDays,
|
||||
externalDomain = dto.externalDomain;
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
|
||||
return other is ServerConfig && other.trashDays == trashDays;
|
||||
return other is ServerConfig &&
|
||||
other.trashDays == trashDays &&
|
||||
other.externalDomain == externalDomain;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode {
|
||||
return trashDays.hashCode;
|
||||
}
|
||||
int get hashCode => trashDays.hashCode ^ externalDomain.hashCode;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||
),
|
||||
serverConfig: const ServerConfig(
|
||||
trashDays: 30,
|
||||
externalDomain: '',
|
||||
),
|
||||
serverDiskInfo: const ServerDiskInfo(
|
||||
diskAvailable: "0",
|
||||
@@ -74,7 +75,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||
if (appVersion["major"]! > serverVersion.major) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_major".tr(),
|
||||
versionMismatchErrorMessage:
|
||||
"profile_drawer_server_out_of_date_major".tr(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -82,7 +84,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||
if (appVersion["major"]! < serverVersion.major) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_major".tr(),
|
||||
versionMismatchErrorMessage:
|
||||
"profile_drawer_client_out_of_date_major".tr(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -90,7 +93,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||
if (appVersion["minor"]! > serverVersion.minor) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage: "profile_drawer_server_out_of_date_minor".tr(),
|
||||
versionMismatchErrorMessage:
|
||||
"profile_drawer_server_out_of_date_minor".tr(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +102,8 @@ class ServerInfoNotifier extends StateNotifier<ServerInfo> {
|
||||
if (appVersion["minor"]! < serverVersion.minor) {
|
||||
state = state.copyWith(
|
||||
isVersionMismatch: true,
|
||||
versionMismatchErrorMessage: "profile_drawer_client_out_of_date_minor".tr(),
|
||||
versionMismatchErrorMessage:
|
||||
"profile_drawer_client_out_of_date_minor".tr(),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user