add discard_elapsed_time option

This commit is contained in:
shibafu 2020-11-08 15:38:38 +09:00
parent bb7b05435e
commit 855011c624
5 changed files with 34 additions and 6 deletions

View File

@ -19,7 +19,7 @@ class Ejaculation extends Model
protected $fillable = [
'user_id', 'ejaculated_date',
'note', 'geo_latitude', 'geo_longitude', 'link', 'source',
'is_private', 'is_too_sensitive',
'is_private', 'is_too_sensitive', 'discard_elapsed_time',
'checkin_webhook_id'
];

View File

@ -35,6 +35,7 @@ class WebhookController extends Controller
'tags.*' => ['string', 'not_regex:/[\s\r\n]/u', 'max:255'],
'is_private' => 'nullable|boolean',
'is_too_sensitive' => 'nullable|boolean',
'discard_elapsed_time' => 'nullable|boolean',
], [
'tags.*.not_regex' => 'The :attribute cannot contain spaces, tabs and newlines.'
]);
@ -71,6 +72,7 @@ class WebhookController extends Controller
'source' => Ejaculation::SOURCE_WEBHOOK,
'is_private' => (bool)($inputs['is_private'] ?? false),
'is_too_sensitive' => (bool)($inputs['is_too_sensitive'] ?? false),
'discard_elapsed_time' => (bool)($inputs['discard_elapsed_time'] ?? false),
'checkin_webhook_id' => $webhook->id
]);

View File

@ -32,7 +32,8 @@ class EjaculationController extends Controller
'note' => old('note') ?? $request->input('note', ''),
'is_private' => old('is_private') ?? $request->input('is_private', 0) == 1,
'is_too_sensitive' => old('is_too_sensitive') ?? $request->input('is_too_sensitive', 0) == 1,
'is_realtime' => old('is_realtime', true)
'is_realtime' => old('is_realtime', true),
'discard_elapsed_time' => old('discard_elapsed_time') ?? $request->input('discard_elapsed_time') == 1,
],
'errors' => isset($errors) ? $errors->getMessages() : null
];
@ -85,7 +86,8 @@ class EjaculationController extends Controller
'link' => $inputs['link'] ?? '',
'source' => Ejaculation::SOURCE_WEB,
'is_private' => $request->has('is_private') ?? false,
'is_too_sensitive' => $request->has('is_too_sensitive') ?? false
'is_too_sensitive' => $request->has('is_too_sensitive') ?? false,
'discard_elapsed_time' => $request->has('discard_elapsed_time') ?? false,
]);
$tagIds = [];
@ -161,7 +163,8 @@ class EjaculationController extends Controller
'tags' => $tags,
'note' => old('note') ?? $ejaculation->note,
'is_private' => is_bool(old('is_private')) ? old('is_private') : $ejaculation->is_private,
'is_too_sensitive' => is_bool(old('is_too_sensitive')) ? old('is_too_sensitive') : $ejaculation->is_too_sensitive
'is_too_sensitive' => is_bool(old('is_too_sensitive')) ? old('is_too_sensitive') : $ejaculation->is_too_sensitive,
'discard_elapsed_time' => is_bool(old('discard_elapsed_time')) ? old('discard_elapsed_time') : $ejaculation->discard_elapsed_time,
],
'errors' => isset($errors) ? $errors->getMessages() : null
];
@ -203,7 +206,8 @@ class EjaculationController extends Controller
'note' => $inputs['note'] ?? '',
'link' => $inputs['link'] ?? '',
'is_private' => $request->has('is_private') ?? false,
'is_too_sensitive' => $request->has('is_too_sensitive') ?? false
'is_too_sensitive' => $request->has('is_too_sensitive') ?? false,
'discard_elapsed_time' => $request->has('discard_elapsed_time') ?? false,
])->save();
$tagIds = [];

View File

@ -4,7 +4,7 @@ info:
description: |
夜のライフログサービス Tissue の公開API仕様です。
全てのAPIのURLは `https://shikorism.net/api` から始まります。
version: 0.1.0
version: 0.1.1
servers:
- url: 'https://shikorism.net/api'
paths:
@ -51,6 +51,10 @@ paths:
type: boolean
default: false
description: チェックイン対象のオカズをより過激なオカズとして設定
discard_elapsed_time:
type: boolean
default: false
description: 前回チェックインからの経過時間を記録しない
examples:
simple:
description: 何も指定しなければ、現在時刻で公開チェックインをおこないます。

View File

@ -21,6 +21,7 @@ export const CheckinForm: React.FC<CheckinFormProps> = ({ initialState }) => {
const [isRealtime, setRealtime] = useState<boolean>(mode === 'create' && initialState.fields.is_realtime);
const [isPrivate, setPrivate] = useState<boolean>(!!initialState.fields.is_private);
const [isTooSensitive, setTooSensitive] = useState<boolean>(!!initialState.fields.is_too_sensitive);
const [discardElapsedTime, setDiscardElapsedTime] = useState<boolean>(!!initialState.fields.discard_elapsed_time);
useEffect(() => {
if (mode === 'create' && isRealtime) {
const id = setInterval(() => {
@ -164,6 +165,23 @@ export const CheckinForm: React.FC<CheckinFormProps> = ({ initialState }) => {
>
<span className="oi oi-warning" />
</CheckBox>
<CheckBox
id="discardElapsedTime"
name="discard_elapsed_time"
className="mb-3"
checked={discardElapsedTime}
onChange={(v) => setDiscardElapsedTime(v)}
>
<span className="oi oi-timer" />
<br />
<small className="form-text text-muted">
使
<ul className="pl-3">
<li></li>
<li></li>
</ul>
</small>
</CheckBox>
</div>
</div>
<div className="text-center">