Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion mobile_control/api/helpers/mobile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
import frappe


def _meta_modified_for(form_doctype: str, fallback: Any) -> str:
"""Derive the mobile meta-refresh signal for a form: MAX(modified) across its
DocType + child DocTypes + Property Setters + Custom Fields. Customize-Form
artifacts don't bump DocType.modified, so without this the signal is stale.

Reuses the same helper that stamps the meta response in rf_mis (single source of
truth, so the device's cached `modified` converges with this signal and it does
not re-fetch every launch). Falls back to the manually-stored value if rf_mis is
unavailable or the form doctype is missing.
"""
if not form_doctype:
return fallback or ""
try:
from rf_mis.rf_mis.api.meta_override import compute_meta_modified

derived = compute_meta_modified(form_doctype)
if derived:
return derived
except Exception:
pass
return fallback or ""


def get_mobile_configuration_payload() -> dict[str, Any]:
"""Get mobile configuration and app status from Single doctype."""
try:
Expand All @@ -16,9 +39,16 @@ def get_mobile_configuration_payload() -> dict[str, Any]:
for row in config.table_lwis:
configuration.append(
{
# `mobile_doctype` is the key the SDK actually reads
# (mobile_form_name.dart). `mobile_workspace_item` is kept for
# server-side consumers (permissions.py). Both carry the form
# doctype name.
"mobile_doctype": row.mobile_workspace_item,
"mobile_workspace_item": row.mobile_workspace_item,
"group_name": row.workspace_group_name or "",
"doctype_meta_modifed_at": row.doctype_meta_modifed_at or "",
"doctype_meta_modifed_at": _meta_modified_for(
row.mobile_workspace_item, row.doctype_meta_modifed_at
),
"doctype_icon": row.doctype_icon or "",
"order": row.order or 0,
}
Expand Down
Loading