Keep all previously approved widget capabilities when requesting new capabilities (#7340)
parent
3b3776222b
commit
908e938996
|
@ -34,7 +34,7 @@ import { IContent, IEvent, MatrixEvent } from "matrix-js-sdk/src/models/event";
|
|||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import { iterableDiff, iterableUnion } from "../../utils/iterables";
|
||||
import { iterableDiff, iterableMerge } from "../../utils/iterables";
|
||||
import { MatrixClientPeg } from "../../MatrixClientPeg";
|
||||
import ActiveRoomObserver from "../../ActiveRoomObserver";
|
||||
import Modal from "../../Modal";
|
||||
|
@ -131,7 +131,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
|
|||
}
|
||||
}
|
||||
|
||||
const allAllowed = new Set(iterableUnion(allowedSoFar, requested));
|
||||
const allAllowed = new Set(iterableMerge(allowedSoFar, requested));
|
||||
|
||||
if (rememberApproved) {
|
||||
setRememberedCapabilitiesForWidget(this.forWidget, Array.from(allAllowed));
|
||||
|
|
|
@ -14,7 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { arrayDiff, arrayUnion } from "./arrays";
|
||||
import { arrayDiff, arrayMerge, arrayUnion } from "./arrays";
|
||||
|
||||
export function iterableMerge<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T> {
|
||||
return arrayMerge(Array.from(a), Array.from(b));
|
||||
}
|
||||
|
||||
export function iterableUnion<T>(a: Iterable<T>, b: Iterable<T>): Iterable<T> {
|
||||
return arrayUnion(Array.from(a), Array.from(b));
|
||||
|
|
|
@ -14,9 +14,20 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { iterableDiff, iterableUnion } from "../../src/utils/iterables";
|
||||
import { iterableDiff, iterableMerge, iterableUnion } from "../../src/utils/iterables";
|
||||
|
||||
describe('iterables', () => {
|
||||
describe('iterableMerge', () => {
|
||||
it('should return a merged array', () => {
|
||||
const a = [1, 2, 3];
|
||||
const b = [1, 2, 4]; // note diff
|
||||
const result = iterableMerge(a, b);
|
||||
expect(result).toBeDefined();
|
||||
expect(result).toHaveLength(4);
|
||||
expect(result).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('iterableUnion', () => {
|
||||
it('should return a union', () => {
|
||||
const a = [1, 2, 3];
|
||||
|
|
Loading…
Reference in New Issue