Skip to content

Commit

Permalink
cache channels and lora config and add button to refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle committed Dec 7, 2024
1 parent 3e707dc commit 2c8ece2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/components/pages/settings/NodeChannelsSettingsPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
<template v-slot:leading>
<NodeIcon v-if="node" :node-id="node.num" class="mr-3"/>
</template>
<template v-slot:trailing>
<IconButton v-if="channels && loraConfig" @click="getChannels" class="bg-gray-100">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 13.803-3.7M4.031 9.865a8.25 8.25 0 0 1 13.803-3.7l3.181 3.182m0-4.991v4.99" />
</svg>
</IconButton>
</template>
</AppBar>

<!-- loading -->
Expand Down Expand Up @@ -115,7 +122,19 @@ export default {
};
},
mounted() {
// use cached channels and lora config if available
const channels = GlobalState.remoteNodeChannels[this.nodeId];
const loraConfig = GlobalState.remoteNodeLoraConfig[this.nodeId];
if(channels && loraConfig){
this.channels = channels;
this.loraConfig = loraConfig;
return;
}
// nothing is cached, request from device
this.getChannels();
},
methods: {
getNodeLongName: (nodeId) => NodeUtils.getNodeLongName(nodeId),
Expand Down Expand Up @@ -184,6 +203,7 @@ export default {
// update global state
// fixme: this is used to access cached channels from channel settings page
GlobalState.remoteNodeChannels[this.nodeId] = channels;
GlobalState.remoteNodeLoraConfig[this.nodeId] = loraConfig;
} catch(e) {
Expand Down
1 change: 1 addition & 0 deletions src/js/GlobalState.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const globalState = reactive({

// cache channels fetched from remote nodes
remoteNodeChannels: {},
remoteNodeLoraConfig: {},

});

Expand Down

0 comments on commit 2c8ece2

Please sign in to comment.