[MM-33600, MM-34679] Apps commands invalidate form cache (#5333)
* invalidate parser form cache on channel navigate and when changing commands * lint Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
parent
f7eecacccb
commit
6e35286051
1 changed files with 8 additions and 2 deletions
|
|
@ -912,6 +912,9 @@ export class AppCommandParser {
|
|||
}
|
||||
|
||||
setChannelContext = (channelID: string, rootPostID?: string) => {
|
||||
if (this.channelID !== channelID || this.rootPostID !== rootPostID) {
|
||||
this.forms = {};
|
||||
}
|
||||
this.channelID = channelID;
|
||||
this.rootPostID = rootPostID;
|
||||
}
|
||||
|
|
@ -1000,14 +1003,17 @@ export class AppCommandParser {
|
|||
}
|
||||
|
||||
getForm = async (location: string, binding: AppBinding): Promise<{form?: AppForm; error?: string} | undefined> => {
|
||||
const form = this.forms[location];
|
||||
const rootID = this.rootPostID || '';
|
||||
const key = `${this.channelID}-${rootID}-${location}`;
|
||||
const form = this.forms[key];
|
||||
if (form) {
|
||||
return {form};
|
||||
}
|
||||
|
||||
this.forms = {};
|
||||
const fetched = await this.fetchForm(binding);
|
||||
if (fetched?.form) {
|
||||
this.forms[location] = fetched.form;
|
||||
this.forms[key] = fetched.form;
|
||||
}
|
||||
return fetched;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue