Skip to content

Commit

Permalink
Fixing Fileaction cache with reload (Major UX problem)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoaoSRaposo authored and mahiarirani committed Oct 14, 2024
1 parent 23f1fad commit 943f2fb
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/fileactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

import { emit } from '@nextcloud/event-bus';
import { emit,subscribe } from '@nextcloud/event-bus';
import { FileAction, registerDavProperty, registerFileAction, FileType } from "@nextcloud/files";
import HideSource from "@material-design-icons/svg/filled/hide_source.svg";
import SwarmSvg from "../img/swarm-logo.svg";
Expand Down Expand Up @@ -264,3 +264,20 @@ const actionDataUnviewFile ={
const AddUnviewAction = new FileAction(actionDataUnviewFile);

registerFileAction(AddUnviewAction);

let previousPathHasSwarm = false;

subscribe('files:list:updated', (data) => {
console.log('JR-files:list:updated');

if (data.contents.length > 1){
if (previousPathHasSwarm && !data.contents[1]._data.attributes["ethswarm-node"]){
previousPathHasSwarm = false;
window.location.reload();
}
if (data.contents[1]._data.attributes["ethswarm-node"]){
previousPathHasSwarm = true;
}
}

});

0 comments on commit 943f2fb

Please sign in to comment.