Skip to content

Commit

Permalink
session: Fix updateProjectList() failing to find project list
Browse files Browse the repository at this point in the history
updateProjectList() was looking for the project list in a meta tag with
name=ol-projects, which no longer exists. Fix this by using meta tag
with name=ol-prefetchedProjectsBlob instead.

Fixes da-h#45.
  • Loading branch information
kgmt0 committed Mar 14, 2023
1 parent cc7caff commit 3870b64
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions rplugin/python3/airlatex/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ async def updateProjectList(self):
projectPage = (await self.nvim.loop.run_in_executor(None, get))
anim_status.cancel()

meta = re.search('<meta\s[^>]*name="ol-projects"[^>]*>', projectPage.text) if projectPage.ok else None
meta = re.search('<meta\s[^>]*name="ol-prefetchedProjectsBlob"[^>]*>', projectPage.text) if projectPage.ok else None
if not projectPage.ok or meta is None:
with tempfile.NamedTemporaryFile(delete=False) as f:
f.write(projectPage.text.encode())
Expand All @@ -193,7 +193,21 @@ async def updateProjectList(self):
create_task(self.sidebar.updateStatus("Online"))
self.log.debug(data)

self.projectList = data
self.projectList = data["projects"]

for project in self.projectList:
owner = project["owner"]
if "firstName" in owner:
owner["first_name"] = owner.pop("firstName")
if "lastName" in owner:
owner["last_name"] = owner.pop("lastName")

last_updated_by = project["lastUpdatedBy"]
if "firstName" in last_updated_by:
last_updated_by["first_name"] = last_updated_by.pop("firstName")
if "lastName" in last_updated_by:
last_updated_by["last_name"] = last_updated_by.pop("lastName")

self.projectList.sort(key=lambda p: p["lastUpdated"], reverse=True)
create_task(self.sidebar.triggerRefresh())
except Exception as e:
Expand Down

0 comments on commit 3870b64

Please sign in to comment.