Skip to content

Commit

Permalink
Merge pull request #1211 from burnash/fix/update-local-state
Browse files Browse the repository at this point in the history
Update (and test for) internal properties on change
  • Loading branch information
alifeee authored Jun 8, 2023
2 parents 7cbf187 + 34dd201 commit 8f25aa1
Show file tree
Hide file tree
Showing 4 changed files with 1,025 additions and 172 deletions.
22 changes: 18 additions & 4 deletions gspread/worksheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,12 @@ def resize(self, rows=None, cols=None):
]
}

return self.spreadsheet.batch_update(body)
res = self.spreadsheet.batch_update(body)
if rows is not None:
self._properties["gridProperties"]["rowCount"] = rows
if cols is not None:
self._properties["gridProperties"]["columnCount"] = cols
return res

# TODO(post Python 2): replace the method signature with
# def sort(self, *specs, range=None):
Expand Down Expand Up @@ -1486,7 +1491,9 @@ def update_index(self, index):
]
}

return self.spreadsheet.batch_update(body)
res = self.spreadsheet.batch_update(body)
self._properties["index"] = index
return res

def _auto_resize(self, start_index, end_index, dimension):
"""Updates the size of rows or columns in the worksheet.
Expand Down Expand Up @@ -2129,7 +2136,12 @@ def freeze(self, rows=None, cols=None):
]
}

return self.spreadsheet.batch_update(body)
res = self.spreadsheet.batch_update(body)
if rows is not None:
self._properties["gridProperties"]["frozenRowCount"] = rows
if cols is not None:
self._properties["gridProperties"]["frozenColumnCount"] = cols
return res

@cast_to_a1_notation
def set_basic_filter(self, name=None):
Expand Down Expand Up @@ -2749,7 +2761,9 @@ def _set_hidden_flag(self, hidden):
]
}

return self.spreadsheet.batch_update(body)
res = self.spreadsheet.batch_update(body)
self._properties["hidden"] = hidden
return res

def hide(self):
"""Hides the current worksheet from the UI."""
Expand Down
Loading

0 comments on commit 8f25aa1

Please sign in to comment.