divkit / divkit

DivKit is an open source Server-Driven UI (SDUI) framework. SDUI is a an emerging technique that leverage the server to build the user interfaces of their mobile app

Home Page:https://divkit.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is the correct response format for apply the patch?

hulygun opened this issue · comments

I have config:

{
  "templates": {
    "main": {
      "type": "container",
      "height": {
        "type": "match_parent"
      },
      "visibility_action": {
        "log_id": "load_data",
        "url": "div-action://download?url=http://example.com/patch",
        "visibility_duration": 1,
        "visibility_percentage": 1
      }
    }
  },
  "card": {
    "log_id": "card",
    "states": [
      {
        "div": {
          "type": "main",
          "id": "main",
          "items": [
            {
              "type": "text",
              "id": "wellcome",
              "text": "wellcome"
            }
          ]
        },
        "state_id": 0
      }
    ]
  }
}

http://example.com/patch:

{
  "changes": [
    {
      "id": "main",
      "items": [
        {
          "type": "text",
          "id": "goodbye",
          "text": "goodbye"
        }
      ]
    }
  ]
}

In the logs I see that a request for a patch occurs but is not applied. Testing in DivKit Playground demo android

Hello! You need a templates field in the patch, even if it is empty

That?

{
  "patch": {
       "changes": [...],
       "mode": "partial"
  },
  "templates": {}
}

In this form, throws out of the screen. Please get correct structure.

Please make sure that all json in the changes property uses only templates from the patch and not from the main card