Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings shows user's timezone, provide ptr to fetch user #594

Merged
Changes from 2 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
20 changes: 18 additions & 2 deletions BeeSwift/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ class SettingsViewController: UIViewController {

self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.isScrollEnabled = false
self.tableView.tableFooterView = UIView()
self.tableView.register(SettingsTableViewCell.self, forCellReuseIdentifier: self.cellReuseIdentifier)

self.tableView.refreshControl = {
let refreshControl = UIRefreshControl()
refreshControl.addTarget(self, action: #selector(self.fetchUser), for: UIControl.Event.valueChanged)
return refreshControl
}()

let versionLabel = BSLabel()
self.view.addSubview(versionLabel)
Expand Down Expand Up @@ -87,6 +90,19 @@ class SettingsViewController: UIViewController {
func showLogsTapped() {
self.navigationController?.pushViewController(LogsViewController(), animated: true)
}

@objc private func fetchUser() {
Task { [weak self] @MainActor in
krugerk marked this conversation as resolved.
Show resolved Hide resolved
self?.tableView.isUserInteractionEnabled = false
try? await ServiceLocator.currentUserManager.refreshUser()

self?.tableView.reloadData()
self?.tableView.layoutIfNeeded()
self?.tableView.refreshControl?.endRefreshing()

self?.tableView.isUserInteractionEnabled = true
}
}

}

Expand Down
Loading