Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alvinosh committed Aug 16, 2024
1 parent 716ca61 commit 9aabccc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
args: ''

runs-on: ${{ matrix.settings.platform }}
env:
CI: true
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl IrohInstance {
// we can send these events to the client to update the progress
while let Some(event) = download_stream.next().await {
let event = event.map_err(|e| IrohError::DownloadError(e.to_string()))?;

match event {
DownloadProgress::FoundHashSeq { hash, .. } => {
let hashseq = self
Expand Down Expand Up @@ -275,9 +276,8 @@ impl IrohInstance {
} else {
return Err(IrohError::Unreachable(file!().to_string(), line!().to_string()));
}
} else {
return Err(IrohError::Unreachable(file!().to_string(), line!().to_string()));
}
// If we don't have metadata, it means it hasn't been found yet
}

DownloadProgress::Progress { id, offset } => {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ async fn receive_files(
.map_err(|e| InvokeError::from_anyhow(anyhow!(e)))?;

for handle in handles {
handle.abort();
handle.await.unwrap();
}

let outpath = dirs::download_dir().unwrap();
Expand Down
27 changes: 13 additions & 14 deletions src/lib/components/FileTransfer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,15 @@
let timeLeft = 0; // seconds
onMount(() => {
const interval = setInterval(() => {
if (previousFile.transfered !== file.transfered) {
internetSpeed = file.transfered - previousFile.transfered;
timeLeft = (file.total - file.transfered) / internetSpeed;
const updateTransfer = () => {
if (previousFile.transferred !== file.transferred) {
internetSpeed = file.transferred - previousFile.transferred;
timeLeft = (file.total - file.transferred) / internetSpeed;
previousFile = file;
}
}, 1000);
return () => {
clearInterval(interval);
};
requestAnimationFrame(updateTransfer);
}
requestAnimationFrame(updateTransfer);
});
function percentComplete(done: number, all: number) {
Expand All @@ -36,18 +34,19 @@
const dispatch = createEventDispatcher();
let openModal = false;
</script>

{#if file.transfered < file.total}
<div class="flex w-full flex-col gap-3 rounded-2xl border-1 p-3">
{#if file.transferred < file.total}
<div class="flex w-full flex-col gap-3 rounded-2xl border-1 p-3">
<div class="flex flex-row items-center gap-3">
<div class="h-11 w-11 rounded-full border-1 p-[10px]">
<FileType />
</div>
<div class="flex flex-1 flex-col justify-between py-1">
<span class="text-sm font-medium text-gray-modern-900">{file.name}</span>
<p class="flex flex-row items-center gap-1 text-xs text-gray-modern-500">
{formatBytes(file.transfered)} of {formatBytes(file.total)}
{formatBytes(file.transferred)} of {formatBytes(file.total)}
<svg
class="fill-gray-modern-500"
width="4"
Expand All @@ -72,10 +71,10 @@
</button> -->
</div>

{#if file.transfered < file.total}
{#if file.transferred < file.total}
<div class="relative h-[6px] w-full rounded-full bg-gray-modern-300">
<div
style={`--percent-complete: ${100 - percentComplete(file.transfered, file.total)}%`}
style={`--percent-complete: ${100 - percentComplete(file.transferred, file.total)}%`}
class={`absolute left-0 right-[var(--percent-complete)] h-full rounded-full bg-blue-dark-500`}
></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export type FileUploaded = FileTransfer & {

export type FileTransfer = {
name: string;
transfered: number;
transferred: number;
total: number;
};

0 comments on commit 9aabccc

Please sign in to comment.