~not/sonar

343166ae5ef2744bb55fc278925f00e46638292f — b123400 1 year, 5 months ago af7b530
Fix issue with overlapped view mode update
M Sonar/MediaDB/Album.h => Sonar/MediaDB/Album.h +2 -2
@@ 17,11 17,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSString *id;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSURL *coverArtURL;
@property (nonatomic, strong) NSString *artist;
@property (nonatomic, strong, nullable) NSString *artist;
@property (nonatomic, strong) NSString *artistId;
@property (nonatomic, assign) NSInteger duration;
@property (nonatomic, strong) NSDate *created;
@property (nonatomic, strong) NSDate *starred;
@property (nonatomic, strong, nullable) NSDate *starred;
@property (nonatomic, assign) NSInteger songCount;

@property (nonatomic, assign) BOOL isDirectoryAlbum;

M Sonar/MediaDB/Artist.h => Sonar/MediaDB/Artist.h +1 -1
@@ 16,7 16,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong) NSString *id;
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSDate *starred;
@property (nonatomic, strong, nullable) NSDate *starred;
@property (nonatomic, strong, nullable) NSArray<Album*> *albums; // nil means not loaded, @[] means it has no albums

@property (nonatomic, strong) BRSonicAPIArtist *apiArtist;

M Sonar/MediaDB/MediaDB.m => Sonar/MediaDB/MediaDB.m +0 -1
@@ 360,7 360,6 @@
    self.songIdsByPlaylistId[playlist.id] = newIdsArray;
    NSArray<Song*> *originalSongs = playlist.songs;
    NSMutableArray<Song*> *newSongs = [playlist.songs mutableCopy];
    NSUInteger theIndex = [newSongs indexOfObject:song];
    [newSongs removeObject:song];
    playlist.songs = newSongs;
    callback(nil, playlist);

M Sonar/MediaDB/Song.h => Sonar/MediaDB/Song.h +5 -5
@@ 15,11 15,11 @@ NS_ASSUME_NONNULL_BEGIN

@property (nonatomic, strong) NSString *id;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *album;
@property (nonatomic, strong) NSString *artist;
@property (nonatomic, strong) NSString *genre;
@property (nonatomic, strong, nullable) NSString *album;
@property (nonatomic, strong, nullable) NSString *artist;
@property (nonatomic, strong, nullable) NSString *genre;
@property (nonatomic, strong) NSURL *coverArtURL;
@property (nonatomic, strong) NSString *contentType;
@property (nonatomic, strong, nullable) NSString *contentType;
@property (nonatomic, strong) NSString *suffix;
@property (nonatomic, assign) NSInteger bitRate;
@property (nonatomic, strong) NSString *path;


@@ 31,7 31,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) NSInteger track;
@property (nonatomic, assign) NSInteger discNumber;
@property (nonatomic, strong) NSDate *created;
@property (nonatomic, strong) NSDate *starred;
@property (nonatomic, strong, nullable) NSDate *starred;

@property (nonatomic, strong, nullable) BRSonicAPISong *apiSong;


M Sonar/Player/PlayerWindowController.m => Sonar/Player/PlayerWindowController.m +26 -21
@@ 341,21 341,23 @@ typedef enum : NSUInteger {
    playlistsItem.state =
    artistsItem.state =
    albumsItem.state = NSControlStateValueOff;

    
    typeof(self) __weak weakSelf = self;
    switch (_viewMode) {
        case PlayerWindowControllerViewModeArtists: {
            self.artistsModeButton.highlighted = YES;
            artistsItem.state = NSControlStateValueOff;
            [[MediaDB shared] listArtistsWithCompletion:^(NSError * _Nonnull error, NSArray<Artist *> * _Nonnull artists) {
                if (weakSelf.viewMode != newMode) return;
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self sortAndSetOutlineViewItems:artists];
                    [weakSelf sortAndSetOutlineViewItems:artists];
                    if (error) {
                        [self displayError:error];
                        [weakSelf displayError:error];
                        return;
                    }
                    [self.outlineView reloadData];
                    [self restoreCurrentViewModeState];
                    self.viewModeStates[@(self.viewMode)].initialLoaded = YES;
                    [weakSelf.outlineView reloadData];
                    [weakSelf restoreCurrentViewModeState];
                    weakSelf.viewModeStates[@(weakSelf.viewMode)].initialLoaded = YES;
                });
            }
                                            fetchRemote:update];


@@ 365,15 367,16 @@ typedef enum : NSUInteger {
            self.playlistsModeButton.highlighted = YES;
            playlistsItem.state = NSControlStateValueOff;
            [[MediaDB shared] listPlaylistsWithCompletion:^(NSError * _Nullable error, NSArray<Playlist *> * _Nullable playlists) {
                if (weakSelf.viewMode != newMode) return;
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self sortAndSetOutlineViewItems:playlists];
                    [weakSelf sortAndSetOutlineViewItems:playlists];
                    if (error) {
                        [self displayError:error];
                        [weakSelf displayError:error];
                        return;
                    }
                    [self.outlineView reloadData];
                    [self restoreCurrentViewModeState];
                    self.viewModeStates[@(self.viewMode)].initialLoaded = YES;
                    [weakSelf.outlineView reloadData];
                    [weakSelf restoreCurrentViewModeState];
                    weakSelf.viewModeStates[@(weakSelf.viewMode)].initialLoaded = YES;
                });
            }
                                              fetchRemote:update];


@@ 383,15 386,16 @@ typedef enum : NSUInteger {
            self.albumsModeButton.highlighted = YES;
            albumsItem.state = NSControlStateValueOff;
            [[MediaDB shared] listAlbumsWithCompletion:^(NSError * _Nullable error, NSArray<Album *> * _Nullable albums) {
                if (weakSelf.viewMode != newMode) return;
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self sortAndSetOutlineViewItems:albums];
                    [weakSelf sortAndSetOutlineViewItems:albums];
                    if (error) {
                        [self displayError:error];
                        [weakSelf displayError:error];
                        return;
                    }
                    [self.outlineView reloadData];
                    [self restoreCurrentViewModeState];
                    self.viewModeStates[@(self.viewMode)].initialLoaded = YES;
                    [weakSelf.outlineView reloadData];
                    [weakSelf restoreCurrentViewModeState];
                    weakSelf.viewModeStates[@(weakSelf.viewMode)].initialLoaded = YES;
                });
            }
                                           fetchRemote:update];


@@ 401,15 405,16 @@ typedef enum : NSUInteger {
            self.favouritesModeButton.highlighted = YES;
            favouritesItem.state = NSControlStateValueOff;
            [[MediaDB shared] listStarredItems:^(NSError * _Nullable error, NSArray<BaseModel *> * _Nullable items) {
                if (weakSelf.viewMode != newMode) return;
                dispatch_async(dispatch_get_main_queue(), ^{
                    [self sortAndSetOutlineViewItems:items];
                    [weakSelf sortAndSetOutlineViewItems:items];
                    if (error) {
                        [self displayError:error];
                        [weakSelf displayError:error];
                        return;
                    }
                    [self.outlineView reloadData];
                    [self restoreCurrentViewModeState];
                    self.viewModeStates[@(self.viewMode)].initialLoaded = YES;
                    [weakSelf.outlineView reloadData];
                    [weakSelf restoreCurrentViewModeState];
                    weakSelf.viewModeStates[@(weakSelf.viewMode)].initialLoaded = YES;
                });
            }
                                   fetchRemote:update];