Add support for spoilers on images (MSC4193) (#2212)
* Add support for MSC4193: Spoilers on Media * Clarify variable names and wording * Restore list atom * Improve spoilered image UX with autoload off * Use `aria-pressed` to indicate attachment spoiler state * Improve spoiler button tooltip wording, keep reveal button from conflicting with load errors
This commit is contained in:
@@ -5,6 +5,11 @@ export type ListAction<T> =
|
||||
type: 'PUT';
|
||||
item: T | T[];
|
||||
}
|
||||
| {
|
||||
type: 'REPLACE';
|
||||
item: T;
|
||||
replacement: T;
|
||||
}
|
||||
| {
|
||||
type: 'DELETE';
|
||||
item: T | T[];
|
||||
@@ -26,8 +31,12 @@ export const createListAtom = <T>() => {
|
||||
}
|
||||
if (action.type === 'PUT') {
|
||||
set(baseListAtom, [...items, ...newItems]);
|
||||
return;
|
||||
}
|
||||
if (action.type === 'REPLACE') {
|
||||
set(baseListAtom, items.map((item) => item === action.item ? action.replacement : item));
|
||||
}
|
||||
}
|
||||
);
|
||||
};
|
||||
export type TListAtom<T> = ReturnType<typeof createListAtom<T>>;
|
||||
export type TListAtom<T> = ReturnType<typeof createListAtom<T>>;
|
||||
Reference in New Issue
Block a user