delete unused apis

This commit is contained in:
pypy
2020-01-11 23:48:56 +09:00
parent e6be1c6879
commit 5915c6bafd

View File

@@ -2739,367 +2739,6 @@ if (window.CefSharp) {
});
};
// API: Feedback
API.feedback = {};
API.isFeedbackLoading = false;
API.$on('LOGIN', function () {
this.feedback = {};
this.isFeedbackLoading = false;
});
API.$on('FEEDBACK', function (args) {
args.ref = this.updateFeedback(args.json);
});
API.$on('FEEDBACK:LIST', function (args) {
args.json.forEach((json) => {
this.$emit('FEEDBACK', {
param: {
feedbackId: json.id
},
json
});
});
});
API.$on('FEEDBACK:DELETE', function (args) {
var ctx = this.feedback[args.param.feedbackId];
if (ctx &&
!ctx.$isExpired) {
ctx.$isExpired = true;
args.ref = ctx;
this.$emit('FEEDBACK:@DELETE', {
param: {
feedbackId: ctx.id
},
ref: ctx
});
}
});
API.markAllFeedbacksAsExpired = function () {
for (var key in this.feedback) {
var ctx = this.feedback[key];
if (!ctx.$isExpired) {
ctx.$isExpired = true;
}
}
};
API.checkExpiredFeedbacks = function () {
for (var key in this.feedback) {
var ctx = this.feedback[key];
if (ctx.$isExpired &&
!ctx.$isExpired) {
ctx.$isExpired = true;
this.$emit('FEEDBACK:@DELETE', {
param: {
feedbackId: ctx.id
},
ref: ctx
});
}
}
};
API.refreshFeedback = function () {
if (!this.isFeedbackLoading) {
this.isFeedbackLoading = true;
this.markAllFeedbacksAsExpired();
this.bulk({
fn: 'getFeedbacks',
N: -1,
param: {
n: 100,
offset: 0
},
done: (ok) => {
if (ok) {
this.checkExpiredFeedbacks();
}
this.isFeedbackLoading = false;
}
});
}
};
API.updateFeedback = function (ref) {
var ctx = this.feedback[ref.id];
if (ctx) {
Object.assign(ctx, ref);
} else {
ctx = {
id: ref.id,
type: '',
reason: '',
commenterId: '',
commenterName: '',
contentId: '',
contentType: '',
contentVersion: '',
contentName: '',
contentAuthorId: '',
contentAuthorName: '',
tags: [],
// custom
$isExpired: false,
//
...ref
};
this.feedback[ctx.id] = ctx;
}
ctx.$isExpired = false;
return ctx;
};
/*
param: {
n: number,
offset: number
}
*/
API.getFeedbacks = function (param) {
return this.call(`users/${this.currentUser.id}/feedback`, {
method: 'GET',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('FEEDBACK:LIST', args);
return args;
});
};
/*
param: {
feedbackId: string
}
*/
API.deleteFeedback = function (param) {
return this.call(`feedback/${param.feedbackId}`, {
method: 'DELETE',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('FEEDBACK:DELETE', args);
return args;
});
};
// API: Thing
API.thing = {};
API.isThingLoading = false;
API.$on('LOGIN', function () {
this.thing = {};
this.isThingLoading = false;
});
API.$on('THING', function (args) {
args.ref = this.updateThing(args.json);
});
API.$on('THING:LIST', function (args) {
args.json.forEach((json) => {
this.$emit('THING', {
param: {
thingId: json.id
},
json
});
});
});
API.$on('THING:ADD', function (args) {
this.$emit('THING', {
param: {
thingId: args.json.id
},
json: args.json
});
});
API.$on('THING:SAVE', function (args) {
this.$emit('THING', {
param: {
thingId: args.json.id
},
json: args.json
});
});
API.$on('THING:DELETE', function (args) {
var ctx = this.thing[args.param.thingId];
if (ctx &&
!ctx.$isExpired) {
ctx.$isExpired = true;
args.ref = ctx;
this.$emit('THING:@DELETE', {
param: {
thingId: ctx.id
},
ref: ctx
});
}
});
API.markAllThingsAsExpired = function () {
for (var key in this.thing) {
var ctx = this.thing[key];
if (!ctx.$isExpired) {
ctx.$isExpired = true;
}
}
};
API.checkExpiredThings = function () {
for (var key in this.thing) {
var ctx = this.thing[key];
if (ctx.$isExpired &&
!ctx.$isExpired) {
ctx.$isExpired = true;
this.$emit('THING:@DELETE', {
param: {
thingId: ctx.id
},
ref: ctx
});
}
}
};
API.refreshThing = function () {
if (!this.isThingLoading) {
this.isThingLoading = true;
this.markAllThingsAsExpired();
this.bulk({
fn: 'getThings',
N: -1,
param: {
n: 100,
offset: 0
},
done: (ok) => {
if (ok) {
this.checkExpiredThings();
}
this.isThingLoading = false;
}
});
}
};
API.updateThing = function (ref) {
var ctx = this.thing[ref.id];
if (ctx) {
Object.assign(ctx, ref);
} else {
ctx = {
id: ref.id,
ownerId: '',
ownerDisplayName: '',
thingProperty: '',
otherThingProperty: '',
tags: [],
// custom
$isExpired: false,
//
...ref
};
this.thing[ctx.id] = ctx;
}
ctx.$isExpired = false;
};
/*
param: {
n: number,
offset: number
}
*/
API.getThings = function (param) {
return this.call('things', {
method: 'GET',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('THING:LIST', args);
return args;
});
};
/*
param: {
thingId: string,
thingProperty: string,
tags: string
}
*/
API.addThing = function (param) {
return this.call('things', {
method: 'POST',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('THING:ADD', args);
return args;
});
};
/*
param: {
thingId: string,
thingProperty: string,
tags: string
}
*/
API.saveThing = function (param) {
return this.call(`things/${param.thingId}`, {
method: 'PUT',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('THING:SAVE', args);
return args;
});
};
/*
param: {
thingId: string
}
*/
API.deleteThing = function (param) {
return this.call(`things/${param.thingId}`, {
method: 'DELETE',
body: param
}).then((json) => {
var args = {
param,
json
};
this.$emit('THING:DELETE', args);
return args;
});
};
// API: WebSocket
API.webSocket = false;