js/app.js
// Currently, updates are reloaded every 5 seconds -- this should be improved in the future by means of a websocket or server-sent events
Currently, updates are reloaded every 5 seconds -- this should be improved in the future by means of a websocket or server-sent events
Currently updates are reloaded every 5 seconds -- this should be improved in the future by means of a websocket or server - sent events
async function subscribeToServerUpdates() {
    if (!ioHelper.hasServerURL()) return;
    const lastHintShowed = {};
    setInterval(async () => {
        if (clinicaldataModule.surveyViewIsActive()) return;
        const lastUpdate = await ioHelper.getLastServerUpdate();
        if (metadataWrapper.getLastUpdate() != lastUpdate.metadata && lastHintShowed.metadata != lastUpdate.metadata) {
            ioHelper.showMessage(languageHelper.getTranslation("note"), languageHelper.getTranslation("metadata-reload-question"),
                {
                    [languageHelper.getTranslation("reload")]: () => reloadApp({ reloadMetadata: true })
                }
            );
            lastHintShowed.metadata = lastUpdate.metadata;
        };
        if (clinicaldataWrapper.getLastUpdate() != lastUpdate.clinicaldata) {
            await clinicaldataWrapper.loadSubjects();
            clinicaldataModule.loadSubjectKeys();
        };
        await ioHelper.emptyMessageQueue();
    }, 5000);
    ioHelper.disposeExpiredCaches();
}
async function subscribeToServerUpdates ( ) { if ( ! ioHelper . hasServerURL ( ) ) return ; const lastHintShowed = { } ; setInterval ( async ( ) => { if ( clinicaldataModule . surveyViewIsActive ( ) ) return ; const lastUpdate = await ioHelper . getLastServerUpdate ( ) ; if ( metadataWrapper . getLastUpdate ( ) != lastUpdate . metadata && lastHintShowed . metadata != lastUpdate . metadata ) { ioHelper . showMessage ( languageHelper . getTranslation ( "note" ) , languageHelper . getTranslation ( "metadata-reload-question" ) , { [ languageHelper . getTranslation ( "reload" ) ] : ( ) => reloadApp ( { reloadMetadata : true } ) } ) ; lastHintShowed . metadata = lastUpdate . metadata ; } ; if ( clinicaldataWrapper . getLastUpdate ( ) != lastUpdate . clinicaldata ) { await clinicaldataWrapper . loadSubjects ( ) ; clinicaldataModule . loadSubjectKeys ( ) ; } ; await ioHelper . emptyMessageQueue ( ) ; } , 5000 ) ; ioHelper . disposeExpiredCaches ( ) ; }
Currently, updates are reloaded every 5 seconds -- this should be improved in the future by means of a websocket or server-sent events
Currently updates are reloaded every 5 seconds -- this should be improved in the future by means of a websocket or server - sent events
// Test whether the metadata was updated // Test whether the clinicaldata was updated // Also, empty the message queue // Finally, remove expired ODM cache entries