Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 59 additions & 4 deletions lib/blocs/shared_file/shared_file_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,16 @@ class SharedFileCubit extends Cubit<SharedFileState> {
final resolution = _resolution;
final fileKey = _lastAttemptedFileKey;

emit(current.copyWith(activityStatus: SharedFileActivityStatus.loading));
emit(current.copyWith(
activityStatus: SharedFileActivityStatus.loading,
// The version the link named is already in hand - it is what the page is
// showing. It renders the moment the list is opened, and the rest of the
// history fills in around it, so expanding never costs a wait and a
// failed lookup never empties the list.
activityRevisions: current.activityRevisions.isEmpty
? [current.sharedRevision]
: current.activityRevisions,
));

try {
final entities = await _bounded(
Expand Down Expand Up @@ -371,6 +380,45 @@ class SharedFileCubit extends Cubit<SharedFileState> {
}
}

/// Makes [revision] what the page shows and downloads.
///
/// The version list's own action. [showLatestRevision] and
/// [showSharedRevision] remain the banner's two shortcuts; this is the
/// general case behind them, so a recipient can pick any version the file
/// has rather than only the two the page happens to offer.
///
/// The banner stays honest afterwards because "a newer version exists" is
/// re-derived from where the selection landed: on the newest revision there
/// is nothing newer to offer, and on any older one there is.
///
/// Selecting is deliberate, so unlike the freshness check it *does* move the
/// download target - that is the whole point of the control. Nothing moves it
/// on the recipient's behalf.
Future<void> showRevision(FileRevision revision) async {
final current = state;

if (current is! SharedFileLoadSuccess) {
return;
}

// Already the target. Re-emitting would drop the license for no reason.
if (revision.dataTxId == current.revision.dataTxId) {
return;
}

final history = current.activityRevisions;
final isNewest =
history.isNotEmpty && revision.dataTxId == history.first.dataTxId;

emit(_withTarget(current, revision, showsLatestRevision: isNewest));

await _fetchLicense(
revision,
current.ownerAddress,
resolution: _resolution,
);
}

/// Takes the file's newest revision as what the page shows and downloads.
///
/// The freshness check never moves the target; it raises a flag, and the page
Expand Down Expand Up @@ -1683,8 +1731,8 @@ class SharedFileCubit extends Cubit<SharedFileState> {
parentFolderId: '',
name: payload.name ?? '',
size: payload.size ?? 0,
lastModifiedDate: _unknownDate,
dateCreated: _unknownDate,
lastModifiedDate: unknownDate,
dateCreated: unknownDate,
metadataTxId: payload.metadataTxId ?? '',
dataTxId: payload.dataTxId!,
dataContentType: payload.contentType,
Expand Down Expand Up @@ -1805,7 +1853,14 @@ class SharedFileCubit extends Cubit<SharedFileState> {
bool _isStale(int resolution) => isClosed || resolution != _resolution;

/// The link carries no timestamps. Rendered as "unknown", never as 1970.
static final _unknownDate = DateTime.fromMillisecondsSinceEpoch(0);
static final unknownDate = DateTime.fromMillisecondsSinceEpoch(0);

/// Whether [date] is the placeholder a link-derived revision carries.
///
/// A link carries no timestamps, so anything painted from one has this in
/// place of a date. The UI asks rather than rendering it: shown, it reads as
/// 1 January 1970, which is worse than showing nothing.
static bool isUnknownDate(DateTime date) => date == unknownDate;
}

/// A revision resolved straight from its metadata transaction.
Expand Down
32 changes: 24 additions & 8 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2146,6 +2146,10 @@
"@sharedFileAccessKeyStaysOnThisDevice": {
"description": "Reassurance shown under the access key field on the shared file page"
},
"sharedFileTransactionDetails": "Transaction details",
"@sharedFileTransactionDetails": {
"description": "Nested disclosure inside the file details tab, holding the identifiers a recipient never needs to see"
},
"sharedFileDetailsDrawerTitle": "File details",
"@sharedFileDetailsDrawerTitle": {
"description": "Title of the collapsed drawer holding the technical details of a shared file"
Expand Down Expand Up @@ -2242,10 +2246,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "Permanent file sharing",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "Preview this file here without downloading it.",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down Expand Up @@ -2298,10 +2298,6 @@
}
}
},
"sharedFileStoredPermanently": "This file is stored permanently and can be downloaded any time.",
"@sharedFileStoredPermanently": {
"description": "Reassurance shown at the bottom of the shared file page"
},
"sharedFileUnlockedWithAccessKey": "Unlocked with your access key. This file stays encrypted for everyone else.",
"@sharedFileUnlockedWithAccessKey": {
"description": "Shown after a private shared file has been unlocked with an access key"
Expand Down Expand Up @@ -2362,6 +2358,26 @@
"@shareDriveSendKeySeparately": {
"description": "Helper text under the drive key field explaining the two-artifact handover"
},
"sharedFileChooseVersion": "Choose which version to download.",
"@sharedFileChooseVersion": {
"description": "Helper line above the recipient's list of file versions"
},
"sharedFileVersionLatest": "Latest",
"@sharedFileVersionLatest": {
"description": "Chip marking the newest version in the recipient's version list"
},
"sharedFileVersionPinned": "Pinned",
"@sharedFileVersionPinned": {
"description": "Chip marking the version a pinned share link deliberately points at, as opposed to merely the version the link carried"
},
"sharedFileVersionsLooking": "Looking for other versions\u2026",
"@sharedFileVersionsLooking": {
"description": "Shown while the rest of a file's version history is being fetched"
},
"sharedFileVersionsUnavailableShort": "Couldn\u2019t check for other versions.",
"@sharedFileVersionsUnavailableShort": {
"description": "Shown when the version history could not be read; the version the recipient was sent is still listed and downloadable"
},
"attachDriveLookingUp": "Looking up drive…",
"@attachDriveLookingUp": {
"description": "Shown while the entered drive ID is being resolved"
Expand Down
4 changes: 0 additions & 4 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "Compartir archivos de forma permanente",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "Previsualiza este archivo aquí, sin descargarlo.",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down
4 changes: 0 additions & 4 deletions lib/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "स्थायी फ़ाइल शेयरिंग",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "इस फ़ाइल को डाउनलोड किए बिना यहीं देखें।",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down
4 changes: 0 additions & 4 deletions lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "永続的なファイル共有",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "ダウンロードせずに、このファイルをここでプレビューできます。",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down
4 changes: 0 additions & 4 deletions lib/l10n/app_zh-HK.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "永久檔案分享",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "無需下載,即可在這裡預覽此檔案。",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down
4 changes: 0 additions & 4 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -1877,10 +1877,6 @@
"@sharedFilePasteAccessKey": {
"description": "Placeholder of the access key field on the shared file page"
},
"sharedFilePermanentFileSharing": "永久文件共享",
"@sharedFilePermanentFileSharing": {
"description": "Tagline shown under the ArDrive logo on the shared file page"
},
"sharedFilePreviewPaneHint": "无需下载,即可在这里预览此文件。",
"@sharedFilePreviewPaneHint": {
"description": "Caption in the preview pane of the shared file page, on a desktop screen, saying what pressing Preview will do"
Expand Down
11 changes: 1 addition & 10 deletions lib/pages/raw_transaction_view/raw_transaction_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ class _RawTransactionReadyViewState extends State<_RawTransactionReadyView> {

@override
Widget build(BuildContext context) {
final colors = ArDriveTheme.of(context).themeData.colors;
final state = widget.state;

return Column(
Expand All @@ -215,14 +214,6 @@ class _RawTransactionReadyViewState extends State<_RawTransactionReadyView> {
RawTransactionPreview(state: state),
const SizedBox(height: 16),
_RawTransactionDetailsDrawer(state: state),
const SizedBox(height: 12),
Text(
appLocalizationsOf(context).sharedFileStoredPermanently,
textAlign: TextAlign.center,
style: ArDriveTypography.body.captionRegular(
color: colors.themeFgSubtle,
),
),
],
);
}
Expand Down Expand Up @@ -275,7 +266,7 @@ class _RawTransactionReadyViewState extends State<_RawTransactionReadyView> {

/// Where the protocol lives, one deliberate tap away.
///
/// Mirrors `SharedFileDetailsDrawer`, whose row and drawer helpers are private
/// Mirrors `SharedFileDetailsContent`, whose row and drawer helpers are private
/// to `shared_file_ready_view.dart` and are built around a `FileRevision` that a
/// raw transaction does not have. Extracting them would mean reshaping the
/// recipient page's ready view around a second caller for two rows; this copy
Expand Down
8 changes: 0 additions & 8 deletions lib/pages/shared_file/shared_file_frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,6 @@ class SharedFileFrame extends StatelessWidget {
fit: BoxFit.contain,
),
),
const SizedBox(height: 8),
Text(
appLocalizationsOf(context).sharedFilePermanentFileSharing,
textAlign: TextAlign.center,
style: ArDriveTypography.body.captionRegular(
color: SharedFileColors.subtle(context),
),
),
],
);
}
Expand Down
Loading
Loading