gristlabs_grist-core/app/gen-server/lib/Activations.ts
George Gevoian 35237a5835 (core) Add Support Grist page and nudge
Summary:
Adds a new Support Grist page (accessible only in grist-core), containing
options to opt in to telemetry and sponsor Grist Labs on GitHub.

A nudge is also shown in the doc menu, which can be collapsed or permanently
dismissed.

Test Plan: Browser and server tests.

Reviewers: paulfitz, dsagal

Reviewed By: paulfitz

Subscribers: jarek, dsagal

Differential Revision: https://phab.getgrist.com/D3926
2023-07-04 17:36:59 -04:00

30 lines
1017 B
TypeScript

import { makeId } from 'app/server/lib/idUtils';
import { Activation } from 'app/gen-server/entity/Activation';
import { HomeDBManager } from 'app/gen-server/lib/HomeDBManager';
/**
* Manage activations. Not much to do currently, there is at most one
* activation. The activation singleton establishes an id and creation
* time for the installation.
*/
export class Activations {
constructor(private _db: HomeDBManager) {
}
// Get the current activation row, creating one if necessary.
// It will be created with an empty key column, which will get
// filled in once an activation key is presented.
public current(): Promise<Activation> {
return this._db.connection.manager.transaction(async manager => {
let activation = await manager.findOne(Activation, {where: {}});
if (!activation) {
activation = manager.create(Activation);
activation.id = makeId();
activation.prefs = {};
await activation.save();
}
return activation;
});
}
}