Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion ownCloud/Bookmarks/BookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ class BookmarkViewController: StaticTableViewController {
connection.connect { [weak self] (error, issue) in
if let strongSelf = self {
if error == nil {
bookmark.displayName = connection.loggedInUser?.displayName
bookmark.userDisplayName = connection.loggedInUser?.displayName

connection.disconnect(completionHandler: {
switch strongSelf.mode {
case .create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class StaticLoginSingleAccountServerListViewController: ServerListTableViewContr

private var settingsRows: [SettingsRowIndex] = [.settings]

private var bookmarkChangesObserver : NSObjectProtocol?

var themeApplierToken : ThemeApplierToken?

deinit {
Expand Down Expand Up @@ -91,6 +93,10 @@ class StaticLoginSingleAccountServerListViewController: ServerListTableViewContr
}

retrieveDisplayName()

bookmarkChangesObserver = NotificationCenter.default.addObserver(forName: .OCBookmarkManagerListChanged, object: nil, queue: OperationQueue.main) { [weak self] (_) in
self?.retrieveDisplayName()
}
}

override func viewWillAppear(_ animated: Bool) {
Expand Down Expand Up @@ -374,21 +380,17 @@ class StaticLoginSingleAccountServerListViewController: ServerListTableViewContr
extension StaticLoginSingleAccountServerListViewController {

func retrieveDisplayName() {
guard let bookmark : OCBookmark = OCBookmarkManager.shared.bookmarks.first else { return }
let connection = OCConnection(bookmark: bookmark)

connection.connect { error, issue in
guard error == nil, issue == nil, let displayName = connection.loggedInUser?.displayName else { return }
self.displayName = displayName
self.headerView = nil
OnMainThread {
self.tableView.reloadData()
}
connection.disconnect {
if let userDisplayName = OCBookmarkManager.shared.bookmarks.first?.displayName {
if self.displayName != userDisplayName {
OnMainThread {
self.displayName = userDisplayName
self.headerView = nil

self.tableView.reloadData()
}
}
}
}

}

extension StaticLoginSingleAccountServerListViewController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ NS_ASSUME_NONNULL_BEGIN

@interface OCBookmark (AppExtensions)

@property(strong,nonatomic,nullable) NSString *displayName;
@property(readonly,nonatomic,nullable) NSString *displayName; // Returns the user.displayName, using bookmark.userDisplayName - or data from the userInfo dictionary (legacy)
@property(readonly,strong,nonatomic) NSString *shortName;

@end

extern OCBookmarkUserInfoKey OCBookmarkUserInfoKeyDisplayName;

NS_ASSUME_NONNULL_END
24 changes: 14 additions & 10 deletions ownCloudAppFramework/SDK Extensions/OCBookmark+AppExtensions.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,18 @@

#import "OCBookmark+AppExtensions.h"

static OCBookmarkUserInfoKey OCBookmarkUserInfoKeyDisplayName = @"OCBookmarkDisplayName";

@implementation OCBookmark (AppExtensions)

- (NSString *)displayName
{
return ((NSString *)self.userInfo[OCBookmarkUserInfoKeyDisplayName]);
}
if (self.userDisplayName != nil)
{
return (self.userDisplayName);
}

- (void)setDisplayName:(NSString *)displayName
{
self.userInfo[OCBookmarkUserInfoKeyDisplayName] = displayName;
return ((NSString *)self.userInfo[OCBookmarkUserInfoKeyDisplayName]);
}

- (NSString *)shortName
Expand All @@ -39,11 +41,15 @@ - (NSString *)shortName
else
{
NSString *userNamePrefix = @"";
NSString *displayName = nil, *userName = nil;
NSString *userDisplayName = nil, *userName = nil;

if (((displayName = self.displayName) != nil) && (displayName.length > 0))
if (((userDisplayName = self.userDisplayName) != nil) && (userDisplayName.length > 0))
{
userNamePrefix = [displayName stringByAppendingString:@"@"];
userNamePrefix = [userDisplayName stringByAppendingString:@"@"];
}
else if (((userDisplayName = self.displayName) != nil) && (userDisplayName.length > 0))
{
userNamePrefix = [userDisplayName stringByAppendingString:@"@"];
}

if ((userNamePrefix.length == 0) && ((userName = self.userName) != nil) && (userName.length > 0))
Expand All @@ -67,5 +73,3 @@ - (NSString *)shortName
}

@end

OCBookmarkUserInfoKey OCBookmarkUserInfoKeyDisplayName = @"OCBookmarkDisplayName";