feat: Remove from Favorites (Part 3)
This commit is contained in:
parent
78964c0520
commit
ce831f7906
1 changed files with 13 additions and 2 deletions
|
|
@ -388,6 +388,16 @@ static void FavoriteArray_free(Array* self) {
|
|||
}
|
||||
Array_free(self);
|
||||
}
|
||||
static int FavoriteArray_splice(Array* self, int index) {
|
||||
if (index != -1) {
|
||||
for(int i=index; i<self->count-1; i++) {
|
||||
self->items[i] = self->items[i+1];
|
||||
}
|
||||
--self->count;
|
||||
return index;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
///////////////////////////////////////
|
||||
|
||||
|
|
@ -457,8 +467,9 @@ static void toggleFavorite(char* path) {
|
|||
if (id==-1) { // add
|
||||
Array_unshift(favorites, Favorite_new(path));
|
||||
}
|
||||
else if (id>0) { // remove
|
||||
// TODO: remove from favorite
|
||||
|
||||
else { // remove
|
||||
FavoriteArray_splice(favorites, id);
|
||||
}
|
||||
saveFavorites();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue