@danhachuel/thunderbolt 0.4.13 → 0.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/main.py +45 -44
- package/package.json +1 -1
package/app/main.py
CHANGED
|
@@ -1280,8 +1280,30 @@ def render_channel_edit_form(channel: dict, youtube_account_ids: list[str], yout
|
|
|
1280
1280
|
|
|
1281
1281
|
|
|
1282
1282
|
def render_home_update_controls() -> None:
|
|
1283
|
-
"""Render
|
|
1284
|
-
|
|
1283
|
+
"""Render update controls and only show actionable or execution-related notices."""
|
|
1284
|
+
cache_key = "home_update_version_check"
|
|
1285
|
+
checked_at_key = "home_update_version_checked_at"
|
|
1286
|
+
if not st.session_state.get(cache_key) or time.monotonic() - float(st.session_state.get(checked_at_key, 0)) > 300:
|
|
1287
|
+
st.session_state[cache_key] = check_version(APP_VERSION)
|
|
1288
|
+
st.session_state[checked_at_key] = time.monotonic()
|
|
1289
|
+
version_status = st.session_state[cache_key]
|
|
1290
|
+
notice_signature = f"{version_status.latest_version}|{version_status.update_available}|{version_status.error}"
|
|
1291
|
+
if st.session_state.get("home_update_notice_signature") != notice_signature:
|
|
1292
|
+
st.session_state["home_update_notice_signature"] = notice_signature
|
|
1293
|
+
st.session_state["home_update_notice_dismissed"] = False
|
|
1294
|
+
|
|
1295
|
+
update_result = st.session_state.get("home_update_result")
|
|
1296
|
+
notice_message = ""
|
|
1297
|
+
notice_kind = ""
|
|
1298
|
+
if update_result is not None and (not update_result.ok or update_result.restart_required):
|
|
1299
|
+
notice_message = str(update_result.message or "").strip()
|
|
1300
|
+
notice_kind = "success" if update_result.ok else "error"
|
|
1301
|
+
elif version_status.update_available:
|
|
1302
|
+
notice_message = f"Nova versão disponível: {display_version(version_status.latest_version)}. A versão actual é {APP_VERSION_LABEL or 'desconhecida'}."
|
|
1303
|
+
notice_kind = "info"
|
|
1304
|
+
notice_visible = bool(notice_message) and not st.session_state.get("home_update_notice_dismissed")
|
|
1305
|
+
|
|
1306
|
+
update_area, notice_area, close_area = st.columns([1.45, 3.55, 0.42], gap="small")
|
|
1285
1307
|
with update_area:
|
|
1286
1308
|
st.markdown(
|
|
1287
1309
|
"""
|
|
@@ -1297,6 +1319,18 @@ def render_home_update_controls() -> None:
|
|
|
1297
1319
|
border-color: #c4b5fd;
|
|
1298
1320
|
filter: brightness(1.08);
|
|
1299
1321
|
}
|
|
1322
|
+
div[data-testid="stAlert"] {
|
|
1323
|
+
width: fit-content;
|
|
1324
|
+
max-width: 100%;
|
|
1325
|
+
min-height: 0;
|
|
1326
|
+
padding: 0.45rem 0.75rem;
|
|
1327
|
+
margin: 0.2rem 0 0;
|
|
1328
|
+
display: inline-flex;
|
|
1329
|
+
align-items: center;
|
|
1330
|
+
}
|
|
1331
|
+
div[data-testid="stAlert"] p {
|
|
1332
|
+
margin: 0;
|
|
1333
|
+
}
|
|
1300
1334
|
</style>
|
|
1301
1335
|
""",
|
|
1302
1336
|
unsafe_allow_html=True,
|
|
@@ -1310,49 +1344,16 @@ def render_home_update_controls() -> None:
|
|
|
1310
1344
|
st.success("Actualização concluída. A reiniciar o Thunderbolt para aplicar a nova versão…")
|
|
1311
1345
|
time.sleep(0.8)
|
|
1312
1346
|
restart_current_process()
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
version_status = st.session_state[cache_key]
|
|
1320
|
-
notice_signature = f"{version_status.latest_version}|{version_status.update_available}|{version_status.error}"
|
|
1321
|
-
if st.session_state.get("home_update_notice_signature") != notice_signature:
|
|
1322
|
-
st.session_state["home_update_notice_signature"] = notice_signature
|
|
1323
|
-
st.session_state["home_update_notice_dismissed"] = False
|
|
1324
|
-
if version_status.update_available:
|
|
1325
|
-
notice_message = f"Nova versão disponível: {display_version(version_status.latest_version)}. A versão actual é {APP_VERSION_LABEL or 'desconhecida'}."
|
|
1326
|
-
notice_kind = "info"
|
|
1327
|
-
elif version_status.error:
|
|
1328
|
-
notice_message = f"Versão actual: {APP_VERSION_LABEL or 'desconhecida'} · verificação de actualização indisponível."
|
|
1329
|
-
notice_kind = "caption"
|
|
1330
|
-
else:
|
|
1331
|
-
notice_message = f"Versão actual: {APP_VERSION_LABEL or 'desconhecida'} · já está actualizada ({display_version(version_status.latest_version)})."
|
|
1332
|
-
notice_kind = "success"
|
|
1333
|
-
if not st.session_state.get("home_update_notice_dismissed"):
|
|
1334
|
-
notice_col, close_col = st.columns([8.5, 1])
|
|
1335
|
-
with notice_col:
|
|
1336
|
-
if notice_kind == "info":
|
|
1337
|
-
st.info(notice_message)
|
|
1338
|
-
elif notice_kind == "success":
|
|
1339
|
-
st.success(notice_message)
|
|
1340
|
-
else:
|
|
1341
|
-
st.caption(notice_message)
|
|
1342
|
-
with close_col:
|
|
1343
|
-
if st.button("×", key="home_update_notice_close", help="Fechar este aviso"):
|
|
1344
|
-
st.session_state["home_update_notice_dismissed"] = True
|
|
1345
|
-
st.rerun()
|
|
1346
|
-
update_result = st.session_state.get("home_update_result")
|
|
1347
|
-
if update_result is not None and not st.session_state.get("home_update_notice_dismissed"):
|
|
1348
|
-
result_col, result_close_col = st.columns([8.5, 1])
|
|
1349
|
-
with result_col:
|
|
1350
|
-
if update_result.ok:
|
|
1351
|
-
st.success(update_result.message)
|
|
1347
|
+
if notice_visible:
|
|
1348
|
+
with notice_area:
|
|
1349
|
+
if notice_kind == "info":
|
|
1350
|
+
st.info(notice_message)
|
|
1351
|
+
elif notice_kind == "success":
|
|
1352
|
+
st.success(notice_message)
|
|
1352
1353
|
else:
|
|
1353
|
-
st.error(
|
|
1354
|
-
with
|
|
1355
|
-
if st.button("×", key="
|
|
1354
|
+
st.error(notice_message)
|
|
1355
|
+
with close_area:
|
|
1356
|
+
if st.button("×", key="home_update_notice_close", help="Fechar este aviso"):
|
|
1356
1357
|
st.session_state["home_update_notice_dismissed"] = True
|
|
1357
1358
|
st.rerun()
|
|
1358
1359
|
|
package/package.json
CHANGED