@@ -93,15 +93,22 @@ <h2 slot="header">Project Details <a id="projectManagementBtn" title="Manage Pro
9393 import TPEN from '../../api/TPEN.js'
9494 import CheckPermissions from '../../components/check-permissions/checkPermissions.js'
9595
96+ // [tpen-race C] /project inline-script about to register listener. Issue #541 diagnostic.
97+ const _alreadyLoaded = ! ! TPEN . activeProject ?. _createdAt
98+ console . log ( `%c[tpen-race C]%c /project inline-script registering tpen-project-loaded listener; activeProject._createdAt=${ _alreadyLoaded ? TPEN . activeProject . _createdAt : 'UNSET' } @${ performance . now ( ) . toFixed ( 1 ) } ms` , _alreadyLoaded ? 'color:#cc0000;font-weight:bold' : 'color:#008800;font-weight:bold' , 'color:inherit' )
99+ let _listenerFired = false
100+
96101 TPEN . eventDispatcher . on ( 'tpen-project-loaded' , ( ev ) => {
102+ _listenerFired = true
103+ console . log ( `%c[tpen-race D]%c /project listener fired @${ performance . now ( ) . toFixed ( 1 ) } ms` , 'color:#008800;font-weight:bold' , 'color:inherit' )
97104 const goParse = document . getElementById ( "goParse" )
98105 const goTranscribe = document . getElementById ( "goTranscribe" )
99106 const leaveProject = document . getElementById ( "leaveProject" )
100107 if ( leaveProject ) {
101108 leaveProject . href = `/project/leave?projectID=${ ev . detail . _id } `
102109 }
103- if ( goParse &&
104- CheckPermissions . checkEditAccess ( "LINE" , "SELECTOR" ) &&
110+ if ( goParse &&
111+ CheckPermissions . checkEditAccess ( "LINE" , "SELECTOR" ) &&
105112 CheckPermissions . checkCreateAccess ( "LINE" , "SELECTOR" ) ) {
106113 goParse . setAttribute ( "href" , `/annotator?projectID=${ ev . detail . _id } ` )
107114 goParse . hidden = false
@@ -119,6 +126,12 @@ <h2 slot="header">Project Details <a id="projectManagementBtn" title="Manage Pro
119126 }
120127 }
121128 } )
122-
129+
130+ // [tpen-race !] Detect listener-never-fired (i.e. race lost). Issue #541 diagnostic.
131+ setTimeout ( ( ) => {
132+ if ( ! _listenerFired ) {
133+ console . log ( `%c[tpen-race !]%c /project LISTENER NEVER FIRED — race lost (event dispatched before listener registered) @${ performance . now ( ) . toFixed ( 1 ) } ms` , 'color:#fff;background:#cc0000;font-weight:bold;padding:2px 4px' , 'color:inherit' )
134+ }
135+ } , 4000 )
123136</ script >
124137</ html >
0 commit comments