Skip to content

Commit

Permalink
show if user has incoming file transfers from node when viewing conve…
Browse files Browse the repository at this point in the history
…rsation
  • Loading branch information
liamcottle committed Dec 17, 2024
1 parent 7bb5620 commit 9a3db76
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/components/pages/NodeMessagesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
</template>
</AppBar>

<!-- offered file transfers banner -->
<div v-if="offeredFilesCount" class="flex bg-blue-500 font-semibold text-white p-2 items-center">
<div class="mr-2">You have {{ offeredFilesCount }} incoming file {{ offeredFilesCount === 1 ? 'transfer' : 'transfers' }}</div>
<div class="ml-auto">
<RouterLink :to="{ name: 'node.files', params: { nodeId: node.num } }">
<button type="button" class="bg-white text-black font-semibold px-2 py-1 rounded shadow hover:bg-gray-100">
Show Files
</button>
</RouterLink>
</div>
</div>

<!-- list -->
<div class="flex h-full w-full overflow-hidden">
<MessageViewer v-if="node != null" type="node" :node-id="node.num"/>
Expand All @@ -53,10 +65,13 @@ import NodeIcon from "../nodes/NodeIcon.vue";
import Page from "./Page.vue";
import NodeUtils from "../../js/NodeUtils.js";
import NodeDropDownMenu from "../nodes/NodeDropDownMenu.vue";
import TextButton from "../TextButton.vue";
import FileTransferrer from "../../js/FileTransferrer.js";
export default {
name: 'NodeMessagesPage',
components: {
TextButton,
NodeDropDownMenu,
Page,
NodeIcon,
Expand Down Expand Up @@ -102,6 +117,14 @@ export default {
subtitle() {
return this.node ? this.getNodeLongName(this.node.num) : "Unknown Node";
},
offeredFilesCount() {
return this.node ? GlobalState.fileTransfers.filter((fileTransfer) => {
const isFromThisNode = fileTransfer.from === this.node.num;
const isIncoming = fileTransfer.direction === FileTransferrer.DIRECTION_INCOMING;
const isOffering = fileTransfer.status === FileTransferrer.STATUS_OFFERING;
return isFromThisNode && isIncoming && isOffering;
}).length : 0;
},
},
}
</script>

0 comments on commit 9a3db76

Please sign in to comment.