| 35 | } |
| 36 | |
| 37 | edit(item: QueryStoreItem, index?: number) { |
| 38 | if (typeof index === 'number' && this.items[index]) { |
| 39 | const found = this.items[index]; |
| 40 | if ( |
| 41 | found.query === item.query && |
| 42 | found.variables === item.variables && |
| 43 | found.headers === item.headers && |
| 44 | found.operationName === item.operationName |
| 45 | ) { |
| 46 | this.items.splice(index, 1, item); |
| 47 | this.save(); |
| 48 | return; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | const itemIndex = this.items.findIndex( |
| 53 | x => |
| 54 | x.query === item.query && |
| 55 | x.variables === item.variables && |
| 56 | x.headers === item.headers && |
| 57 | x.operationName === item.operationName, |
| 58 | ); |
| 59 | if (itemIndex !== -1) { |
| 60 | this.items.splice(itemIndex, 1, item); |
| 61 | this.save(); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | delete(item: QueryStoreItem) { |
| 66 | const itemIndex = this.items.findIndex( |