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

Feat/mpv profiles #108

Merged
merged 16 commits into from
Nov 19, 2023
Merged
Changes from 1 commit
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
15 changes: 10 additions & 5 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,29 @@
.trim().split('\n')
.map(line => line.trim());

// We need at least a name to save the profile
// or it won't have text on the menu context
if (!name) {
return;
}

const backgroundPage = browser.extension.getBackgroundPage();
let profileFunction = 'updateProfile';

// Save new profile
// Save profile if it doesn't have an id
if (!targetProfile.dataset.id) {
targetProfile.dataset.id = crypto.randomUUID();
targetProfile.classList.remove('new-profile');
profileFunction = 'createProfile';

const id = targetProfile.dataset.id;
const profile = { id, name, content };
backgroundPage.createProfile(profile);
woodruffw marked this conversation as resolved.
Show resolved Hide resolved

return saveProfile(profile);
}

const id = targetProfile.dataset.id;
const profile = { id, name, content };

backgroundPage[profileFunction](profile);
backgroundPage.updateProfile(profile);

return saveProfile(profile);
};
Expand Down