Show pending ISAC contributions immediately
This commit is contained in:
@@ -50,7 +50,7 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
|
||||
: filter === 'archived' ? 'WHERE sets.active=0'
|
||||
: filter === 'configured' ? `WHERE EXISTS (SELECT 1 FROM skill_chip_two_piece_bonuses bonus WHERE bonus.skill_chip_set_id=sets.id)
|
||||
AND EXISTS (SELECT 1 FROM skill_chip_talents talent WHERE talent.skill_chip_set_id=sets.id)` : '';
|
||||
const [summary, filtered, pendingStats, pendingTriggers] = await Promise.all([
|
||||
const [summary, filtered, pendingStats, pendingTriggers, pendingSets] = await Promise.all([
|
||||
(await database.prepare(`SELECT COUNT(*) AS total,
|
||||
SUM(CASE WHEN active=1 THEN 1 ELSE 0 END) AS active,
|
||||
SUM(CASE WHEN active=0 THEN 1 ELSE 0 END) AS archived,
|
||||
@@ -58,7 +58,8 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
|
||||
FROM skill_chip_sets`)).get(),
|
||||
(await database.prepare(`SELECT COUNT(*) AS total FROM skill_chip_sets sets ${where}`)).get(),
|
||||
getPendingEntities(user.id, [{ module: 'attributes', action: 'save', kind: 'stat', fields: ['unit', 'chipMin', 'chipMax'] }]),
|
||||
getPendingEntities(user.id, [{ module: 'talents', action: 'saveTrigger', kind: 'trigger', fields: ['description'] }])
|
||||
getPendingEntities(user.id, [{ module: 'talents', action: 'saveTrigger', kind: 'trigger', fields: ['description'] }]),
|
||||
getPendingEntities(user.id, [{ module: 'skillchips', action: 'save', kind: 'skillchip', fields: ['twoPieceStatId', 'twoPieceMin', 'twoPieceMax', 'primaryStatIds', 'secondaryStatIds', 'talentName', 'descriptionTemplate', 'talentEffects', 'triggerIds'] }])
|
||||
]);
|
||||
const pagination = getPagination(url, Number(filtered?.total ?? 0));
|
||||
const [sets, twoPiece, primaryOptions, secondaryOptions, talents, talentTriggers, talentEffects, stats, triggers, icons] = await Promise.all([
|
||||
@@ -79,8 +80,25 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
|
||||
skill_chip_min: item.chipMin === '' ? null : Number(item.chipMin),
|
||||
skill_chip_max: item.chipMax === '' ? null : Number(item.chipMax)
|
||||
})), ...stats];
|
||||
const pendingSetRows = filter === 'archived' ? [] : pendingSets.map((set) => ({
|
||||
...set,
|
||||
iconUrl: '',
|
||||
twoPiece: {
|
||||
stat_attribute_id: set.twoPieceStatId,
|
||||
min_value: Number(set.twoPieceMin),
|
||||
max_value: Number(set.twoPieceMax)
|
||||
},
|
||||
primaryStatIds: Array.isArray(set.primaryStatIds) ? set.primaryStatIds : [set.primaryStatIds].filter(Boolean),
|
||||
secondaryStatIds: Array.isArray(set.secondaryStatIds) ? set.secondaryStatIds : [set.secondaryStatIds].filter(Boolean),
|
||||
talent: {
|
||||
name: set.talentName,
|
||||
description_template: set.descriptionTemplate,
|
||||
effects: (() => { try { return JSON.parse(String(set.talentEffects ?? '[]')); } catch { return []; } })(),
|
||||
triggerIds: Array.isArray(set.triggerIds) ? set.triggerIds : [set.triggerIds].filter(Boolean)
|
||||
}
|
||||
}));
|
||||
return {
|
||||
sets: sets.map((set) => {
|
||||
sets: [...pendingSetRows, ...sets.map((set) => {
|
||||
const talent = talents.find((item) => item.skill_chip_set_id === set.id);
|
||||
const icon = icons.find((item) => item.entity_id === set.id);
|
||||
return {
|
||||
@@ -95,11 +113,11 @@ export const load: PageServerLoad = async ({ cookies, url }) => {
|
||||
effects: talentEffects.filter((item) => item.talent_id === talent.id)
|
||||
} : null
|
||||
};
|
||||
}),
|
||||
})],
|
||||
stats: availableStats,
|
||||
rollStats: availableStats.filter((stat) => stat.skill_chip_min !== null && stat.skill_chip_max !== null),
|
||||
triggers: [...pendingTriggers, ...triggers],
|
||||
summary, filter, pagination
|
||||
summary: { ...summary, total: Number(summary?.total ?? 0) + pendingSets.length, pending: pendingSets.length }, filter, pagination
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user