@@ -23,6 +23,7 @@ import { delete_collection } from "../api/api.js";
2323import { SERVER } from "../constants.js" ;
2424import { Collection , CollectionType } from "../models/collection.js" ;
2525import { collectionsCache } from "../utils/collections_cache.js" ;
26+ import { ErrorHandler } from "../utils/error.js" ;
2627import { bytesToHumanReadable } from "../utils/misc.js" ;
2728import { CreateEditCollectionScene } from "./CreateEditCollectionScene.js" ;
2829import { DeleteConfirmationScene } from "./DeleteConfirmationScene.js" ;
@@ -48,8 +49,10 @@ export class CollectionsScene {
4849 /** @type {HTMLElement } */ let new_btn = html_scene . querySelector ( "[data-name=new]" ) ;
4950 /** @type {HTMLElement } */ let upload_btn = html_scene . querySelector ( "[data-name=upload]" ) ;
5051 /** @type {HTMLElement } */ let incomingshares_btn = html_scene . querySelector ( "[data-name=incomingshares]" ) ;
52+ /** @type {HTMLElement } */ let error_div = html_scene . querySelector ( "[data-name=collectionsscene_error]" ) ;
5153
5254 /** @type {Array<HTMLElement> } */ let nodes = [ ] ;
55+ let errorHandler = new ErrorHandler ( error_div ) ;
5356
5457 function onnew ( ) {
5558 try {
@@ -126,13 +129,18 @@ export class CollectionsScene {
126129 /**
127130 * @param {any[] } collections
128131 * @param {import("../api/sharing.js").Share[] } shares
132+ * @param {boolean } clear_error
129133 */
130- function show_collections ( collections , shares ) {
134+ function show_collections ( collections , shares , clear_error ) {
131135 /** @type {HTMLElement } */ let navBar = document . querySelector ( "#logoutview" ) ;
132136 let heightOfNavBar = navBar . offsetHeight + "px" ;
133137 html_scene . style . marginTop = heightOfNavBar ;
134138 html_scene . style . height = "calc(100vh - " + heightOfNavBar + ")" ;
135139
140+ if ( clear_error ) {
141+ errorHandler . clearError ( ) ;
142+ }
143+
136144 // Clear old nodes
137145 nodes . forEach ( function ( node ) {
138146 node . parentNode . removeChild ( node ) ;
@@ -223,14 +231,18 @@ export class CollectionsScene {
223231 } ) ;
224232 }
225233
234+ this . errorwrapper = function ( /** @type {string } */ error ) {
235+ errorHandler . setError ( error ) ;
236+ if ( onerror ) onerror ( error ) ;
237+ } ;
226238
227239 this . show = function ( ) {
228240 html_scene . classList . remove ( "hidden" ) ;
229241 new_btn . onclick = onnew ;
230242 upload_btn . onclick = onupload ;
231243 incomingshares_btn . onclick = onincomingshares ;
232- collectionsCache . getChildCollections ( user , password , principal_collection , onerror , show_collections ) ;
233- collectionsCache . getServerFeatures ( user , password , null , maybe_enable_sharing_options ) ;
244+ collectionsCache . getChildCollections ( user , password , principal_collection , this . errorwrapper , show_collections ) ;
245+ collectionsCache . getServerFeatures ( user , password , this . errorwrapper , maybe_enable_sharing_options ) ;
234246 } ;
235247 this . hide = function ( ) {
236248 html_scene . classList . add ( "hidden" ) ;
0 commit comments