Skip to content

Commit

Permalink
crate.settings: Remove owner by native array method splice
Browse files Browse the repository at this point in the history
This fixes the following deprecations:
- The removeObject method on ember-data's PromiseManyArray is deprecated.
- The `removeObject` method on the class ManyArray is deprecated.
  • Loading branch information
eth3lbert committed Dec 13, 2024
1 parent c7a5fbf commit 5c55262
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/controllers/crate/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ export default class CrateSettingsController extends Controller {

if (owner.kind === 'team') {
this.notifications.success(`Team ${owner.get('display_name')} removed as crate owner`);
this.crate.owner_team.removeObject(owner);
let owner_team = await this.crate.owner_team;
removeOwner(owner_team, owner);
} else {
this.notifications.success(`User ${owner.get('login')} removed as crate owner`);
this.crate.owner_user.removeObject(owner);
let owner_user = await this.crate.owner_user;
removeOwner(owner_user, owner);
}
} catch (error) {
let subject = owner.kind === 'team' ? `team ${owner.get('display_name')}` : `user ${owner.get('login')}`;
Expand All @@ -54,3 +56,10 @@ export default class CrateSettingsController extends Controller {
}
});
}

function removeOwner(owners, target) {
let idx = owners.indexOf(target);
if (idx !== -1) {
owners.splice(idx, 1);
}
}

0 comments on commit 5c55262

Please sign in to comment.