Merge changes I815284fe,I2e815d17
* changes:
Move mentionedUsersInUnresolvedDrafts to state
Add AccountsModel to CommentsModel
diff --git a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
index 20efa7a..3ddcae4 100644
--- a/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
+++ b/polygerrit-ui/app/elements/change/gr-reply-dialog/gr-reply-dialog.ts
@@ -324,6 +324,9 @@
mentionedUsers: AccountInput[] = [];
@state()
+ mentionedUsersInUnresolvedDrafts: AccountInfo[] = [];
+
+ @state()
attentionCcsCount = 0;
@state()
@@ -406,8 +409,6 @@
private readonly accountsModel = getAppContext().accountsModel;
- private mentionedUsersInUnresolvedDrafts: AccountInfo[] = [];
-
private latestPatchNum?: PatchSetNumber;
storeTask?: DelayedTask;
@@ -808,6 +809,7 @@
changedProperties.has('ccs') ||
changedProperties.has('change') ||
changedProperties.has('draftCommentThreads') ||
+ changedProperties.has('mentionedUsersInUnresolvedDrafts') ||
changedProperties.has('includeComments') ||
changedProperties.has('labelsChanged') ||
changedProperties.has('patchsetLevelDraftMessage') ||
diff --git a/polygerrit-ui/app/models/accounts-model/accounts-model.ts b/polygerrit-ui/app/models/accounts-model/accounts-model.ts
index d29d30e..74eb813 100644
--- a/polygerrit-ui/app/models/accounts-model/accounts-model.ts
+++ b/polygerrit-ui/app/models/accounts-model/accounts-model.ts
@@ -9,12 +9,15 @@
import {Finalizable} from '../../services/registry';
import {UserId} from '../../types/common';
import {getUserId, isDetailedAccount} from '../../utils/account-util';
+import {define} from '../dependency';
import {Model} from '../model';
export interface AccountsState {
accounts: {[id: UserId]: AccountDetailInfo};
}
+export const accountsModelToken = define<AccountsModel>('accounts-model');
+
export class AccountsModel extends Model<AccountsState> implements Finalizable {
constructor(readonly restApiService: RestApiService) {
super({
diff --git a/polygerrit-ui/app/models/comments/comments-model.ts b/polygerrit-ui/app/models/comments/comments-model.ts
index 5137407..e737005 100644
--- a/polygerrit-ui/app/models/comments/comments-model.ts
+++ b/polygerrit-ui/app/models/comments/comments-model.ts
@@ -45,6 +45,7 @@
import {extractMentionedUsers, getUserId} from '../../utils/account-util';
import {EventType} from '../../types/events';
import {SpecialFilePath} from '../../constants/constants';
+import {AccountsModel} from '../accounts-model/accounts-model';
export interface CommentState {
/** undefined means 'still loading' */
@@ -358,6 +359,7 @@
constructor(
readonly routerModel: RouterModel,
readonly changeModel: ChangeModel,
+ readonly accountsModel: AccountsModel,
readonly restApiService: RestApiService,
readonly reporting: ReportingService
) {
diff --git a/polygerrit-ui/app/models/comments/comments-model_test.ts b/polygerrit-ui/app/models/comments/comments-model_test.ts
index 9a4a69d..ba7bd2d 100644
--- a/polygerrit-ui/app/models/comments/comments-model_test.ts
+++ b/polygerrit-ui/app/models/comments/comments-model_test.ts
@@ -67,6 +67,7 @@
const model = new CommentsModel(
getAppContext().routerModel,
testResolver(changeModelToken),
+ getAppContext().accountsModel,
getAppContext().restApiService,
getAppContext().reportingService
);
@@ -122,6 +123,7 @@
const model = new CommentsModel(
getAppContext().routerModel,
testResolver(changeModelToken),
+ getAppContext().accountsModel,
getAppContext().restApiService,
getAppContext().reportingService
);
diff --git a/polygerrit-ui/app/services/app-context-init.ts b/polygerrit-ui/app/services/app-context-init.ts
index 244e94f..2dca9a9 100644
--- a/polygerrit-ui/app/services/app-context-init.ts
+++ b/polygerrit-ui/app/services/app-context-init.ts
@@ -92,9 +92,12 @@
);
dependencies.set(changeModelToken, changeModel);
+ const accountsModel = new AccountsModel(appContext.restApiService);
+
const commentsModel = new CommentsModel(
appContext.routerModel,
changeModel,
+ accountsModel,
appContext.restApiService,
appContext.reportingService
);
diff --git a/polygerrit-ui/app/test/test-app-context-init.ts b/polygerrit-ui/app/test/test-app-context-init.ts
index 5bbec45..15857c8 100644
--- a/polygerrit-ui/app/test/test-app-context-init.ts
+++ b/polygerrit-ui/app/test/test-app-context-init.ts
@@ -33,7 +33,10 @@
import {BrowserModel, browserModelToken} from '../models/browser/browser-model';
import {PluginsModel} from '../models/plugins/plugins-model';
import {MockHighlightService} from '../services/highlight/highlight-service-mock';
-import {AccountsModel} from '../models/accounts-model/accounts-model';
+import {
+ AccountsModel,
+ accountsModelToken,
+} from '../models/accounts-model/accounts-model';
export function createTestAppContext(): AppContext & Finalizable {
const appRegistry: Registry<AppContext> = {
@@ -97,10 +100,15 @@
);
dependencies.set(changeModelToken, changeModelCreator);
+ const accountsModelCreator = () =>
+ new AccountsModel(appContext.restApiService);
+ dependencies.set(accountsModelToken, accountsModelCreator);
+
const commentsModelCreator = () =>
new CommentsModel(
appContext.routerModel,
resolver(changeModelToken),
+ resolver(accountsModelToken),
appContext.restApiService,
appContext.reportingService
);