Fix real-time sync for projectTagOption

This commit is contained in:
Brieuc Dubois 2024-01-24 01:29:41 +01:00
parent d5feb492e1
commit cc7862b0d4
2 changed files with 7 additions and 10 deletions

View File

@ -177,7 +177,7 @@ export default class ProjectTag {
parseOptionUpdate(json: any) { parseOptionUpdate(json: any) {
if (!json) return; if (!json) return;
const option = this._options.find((option) => option.id === json.id); const option = this._options.find((option) => option.id === json.option_id);
if (!option) return; if (!option) return;
option.parseUpdate(json); option.parseUpdate(json);

View File

@ -221,18 +221,15 @@ function applyProjectTag(data: any) {
} }
function applyProjectTagOption(data: any) { function applyProjectTagOption(data: any) {
const projectTag = ProjectTag.fromId(data.project_tag_id);
if (!projectTag) {
toastWarning('Failed to parse project tag option update: project tag not found');
return;
}
if (data.action === 'create') { if (data.action === 'create') {
projectTag.parseOption(data.data); const projectTag = ProjectTag.fromId(data.data.tag_id);
projectTag?.parseOption(data.data);
} else if (data.action === 'update') { } else if (data.action === 'update') {
projectTag.parseOptionUpdate(data.changes); const projectTag = ProjectTag.fromId(data.tag_id);
projectTag?.parseOptionUpdate(data.changes);
} else if (data.action === 'delete') { } else if (data.action === 'delete') {
projectTag.parseOptionDelete(data.id); const projectTag = ProjectTag.fromId(data.tag_id);
projectTag?.parseOptionDelete(data.option_id);
} else { } else {
toastWarning('Failed to parse project tag option update: unknown action'); toastWarning('Failed to parse project tag option update: unknown action');
return; return;